npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@infra-design/infra-view

v0.0.1

Published

Create your UI in a simple way.

Downloads

2

Readme

infra-view

Work in progress. Not yet ready for public use.

Create your UI in a simple way.

Compile

Installation

npm install infra-view
yarn add infra-view
pnpm add infra-view

Components

Base

Div

Try to use full spellings instead of abbreviations, which will reduce the mental burden when developing. And we provide intelligent completions, so the time spent using abbreviations and full spellings is not too different.

import { Div } from 'infra-view'

export const App = () => {
  return (
    <Div
      display='block'
      margin={100}
      width={20}
      height={20}
      background='black'
      hoverStyle={{
        background: 'red',
      }}
      md={{
        margin: 200,
        width: 30,
        height: 30,
      }}
      lg={{
        margin: 300,
        width: 30,
        height: 30,
      }}>
      UI
    </Div>
  )
}
Merge and extend
import { Div } from 'infra-view'

const Component = (props) => {
  return <Div margin={20} md={{ margin: 30 }} externalProps={props} />
}

export const App = () => {
  return (
    <Component padding={10} md={{ margin: 20 }}>
      UI
    </Component>
  )
}
Responsive
import { Div } from 'infra-view'

export const App = () => {
  return (
    <Div
      margin={1}
      padding={1}
      md={{ margin: 2, padding: 2 }}
      lg={{ margin: 3, padding: 3 }}
      xl={{ margin: 4, padding: 4 }}
    />
  )
}
DisplayName
import { Div } from 'infra-view'

export const App = () => {
  return <Div displayName='test'></Div>
}
Selector
import { Button } from 'infra-view'

export const App = (props) => {
  return (
    <Button
      color='gray'
      background='red'
      hoverStyle={{ background: 'blue' }}
      activeStyle={{ background: 'yellow' }}
      focusStyle={{ borderColor: 'green' }}>
      {props.children}
    </Button>
  )
}
As

Easy switch between components. Defaults to div.

import { Div } from 'infra-view'

export const App = () => {
  return (
    <Div as='div'>
      <Div as='button'>Button</Div>
    </Div>
  )
}
Alias
import { P, Span } from 'infra-view'

export const App = () => {
  return (
    <P>
      Same as use <Span>Div</Span> as p.
    </P>
  )
}

Combo

import { Div } from 'infra-view'

export const App = () => {
  return (
    <>
      <Div padding={[1, 2, 3, 4]}></Div>
      <Div
        text={{
          family: 'sans-serif',
          size: 16,
          align: 'left',
          color: 'red',
        }}>
        Text
      </Div>
      <Div
        background={{
          color: 'gray',
          image: 'http://www.demo.com/demo.jpg',
          repeat: 'no-repeat',
          position: 'center',
          size: 'cover',
        }}>
        Background
      </Div>
      <Div
        border={{
          color: 'red',
          width: 1,
          style: 'solid',
        }}>
        Border
      </Div>
    </>
  )
}

Conditional

import { Div } from 'infra-view'

export const App = () => {
  return (
    <>
      {/* same as { isMounted && <Div /> } */}
      <Div isMounted={true}>isMounted</Div>

      {/* same as <div display='none' /> */}
      <Div isHidden={true}>isHidden</Div>
    </>
  )
}

Last child style

import { Div } from 'infra-view'

export const App = () => {
  return (
    <>
      <Div
        border={{
          color: 'red',
          width: 1,
          style: 'solid',
        }}
        lastChildStyle={{
          border: {
            color: 'blue',
            width: 2,
            style: 'dashed',
          },
        }}>
        Last child
      </Div>
    </>
  )
}

Layout

We recommend to use Layout components to create your layout without direct use of Div component.

Flex

import { Flex } from 'infra-view'

export const App = () => {
  return (
    <Flex
      alignItems='center'
      justifyContent='space-between'
      flexDirection='row'
      md={{
        flexDirection: 'column',
      }}>
      <div>1</div>
      <div>2</div>
    </Flex>
  )
}

Grid

Usage
import { Grid } from 'infra-view'

export const App = () => {
  return (
    <Grid
      columns={1}
      gap={20}
      md={{ columns: 2, gap: 30 }}
      lg={{ columns: 3, gap: 40 }}
      xm={{ columns: 4, gap: 50 }}>
      <div>1</div>
      <div>2</div>
      <div>3</div>
      <div>4</div>
    </Grid>
  )
}
Grid template

Center

import { Center } from 'infra-view'

export const App = () => {
  return (
    <Center width={20} height={20}>
      <div>UI</div>
    </Center>
  )
}

Absolute

import { Absolute } from 'infra-view'

export const App = () => {
  return (
    <Absolute top={10} left={10}>
      <div>UI</div>
    </Absolute>
  )
}

Fixed

import { Fixed } from 'infra-view'

export const App = () => {
  return (
    <Fixed top={0} left={0} right={0} height={200}>
      <div>UI</div>
    </Fixed>
  )
}

Container

import { Container, Div } from 'infra-view'

export const App = () => {
  return (
    <Container
      padding={10}
      margin={10}
      md={{
        padding: 20,
        margin: 20,
      }}
      lg={{
        padding: 30,
        margin: 30,
      }}>
      <Div>UI</Div>
    </Container>
  )
}

Theme

Usage

import { Div, useTheme } from 'infra-view'

export const App = () => {
  const { fontSize, lineHeight } = useTheme()

  return (
    <Div
      fontSize={fontSize[0]}
      lineHeight={lineHeight[1]}
      md={{
        fontSize: fontSize[2],
        lineHeight: lineHeight[3],
      }}>
      Theme
    </Div>
  )
}

Create theme

import { createTheme, baseTheme } from 'infra-view'

export const theme = createTheme(baseTheme, {
  margin: [2, 10, 20, 30],
  padding: [10, 20, 30, 40],
  fontSize: [12, 14, 16, 18],
  lineHeight: [1.5, 1.7, 1.9, 2.1],
  breakpoints: [0, 768, 1024, 1440],
})

Update theme

import theme from 'your-theme'

theme.update({
  margin: [1, 2, 3, 4],
})