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

@aaronuu/react-layout

v0.2.1

Published

Layout components for react

Downloads

42

Readme

react-layout

CSS grid and flexbox helper components for react. Uses emotion for css injection.

Features

  • Declarative layout - having layout properties on the component makes page layout easier to reason about while not sacrificing performance by inlining all styles
    • Class construction is memoized based on props
  • Aliased css properties - less typing required
    • All properties (except position which is shortened to pos) are shortened to the first letter of each word of the property
    • Some of the more common properties also have easier to remember aliases (e.g. rows for gridTemplateRows)
    • You can either use the full prop name or any of it's aliases.
  • Flexible breakpoints
    • Given an integer as the key (or a string that can be parsed to an integer) the breakpoint will default as @media (max-width: <key>px)
    • Anything else will simply use the key as the media query
  • Inspired by react-native styling, flex-direction defaults to column

Getting Started

Installing

Install using yarn

yarn add @aaronuu/react-layout emotion

Install using npm

npm i @aaronuu/react-layout emotion

Usage

import { Box, Grid, GridItem } from '@aaronuu/react-layout';

const BREAKPOINT_MOBILE = '768';
const BREAKPOINT_TABLET = '@media(min-width: 768px and max-width: 1024px)';

class YourComponent extends Component {
  render() {
    return (
      <Grid
        rowGap="20px"
        columnGap="10px"
        rows="auto 1fr auto"
        columns="repeat(10, 100px)"
        breakpoints={{
          [BREAKPOINT_TABLET]: {
            rows: 'auto minmax(150px, 500px) auto'
          },
          [BREAKPOINT_MOBILE]: {
            rows: '1fr'
          }
        }}
      >
        <GridItem
          subgrid
          rows="100px 100px 100px"
          columns="auto"
          tag="span"
          area="1 / 1 / 4 / 3"
          breakpoints={{
            [BREAKPOINT_MOBILE]: {
              area: '1 / 1 / 2 / 3'
            }
          }}
        >
          <Box padding="10px">
            <h1>Heading</h1>
          </Box>
        </GridItem>
        <GridItem
          flex
          flexDirection="row"
          area="1 / 3 / 4 / 11"
          breakpoints={{
            [BREAKPOINT_MOBILE]: {
              area: '1 / 3 / 2 / 11'
            }
          }}
        >
          <Box ai="center" jc="center">
            <p>Content</p>
          </Box>
        </GridItem>
      </Grid>
    );
  }
}

Props

Shared

| Prop | Alias | | ------------- | ----- | | tag | - | | position | pos | | top | t | | right | r | | bottom | b | | left | l | | height | h | | width | w | | maxHeight | maxh | | maxWidth | maxw | | minHeight | minh | | minWidth | minw | | padding | p | | paddingTop | pt | | paddingRight | pr | | paddingBottom | pb | | paddingLeft | pl | | margin | m | | marginTop | mt | | marginRight | mr | | marginBottom | mb | | marginLeft | ml | | overflow | o |

Box

| Prop | Alias | | -------------- | ------------- | | flexDirection | fd, direction | | flexWrap | fw, wrap | | alignItems | ai | | alignContent | ac | | justifyContent | jc | | flexGrow | fg | | flexShrink | fs | | flex | f | | flexAuto | fa | | flexNone | fn |

Grid

| Prop | Alias | | ------------------- | -------------- | | gridGap | gg, gap | | gridRowGap | grg, rowGap | | gridColumnGap | gcg, columnGap | | gridTemplateRows | gtr, rows | | gridTemplateColumns | gtc, columns | | justifyItems | ji | | alignItems | ai | | placeItems | pc | | justifyContent | jc | | alignContent | ac | | placeContent | pc | | gridAutoColumns | gac | | gridAutoRows | gar | | gridAutoFlow | gaf |

GridItem

| Prop | Alias | | --------------- | ---------------- | | subgrid | | | flex | | | gridRowStart | grs, rowStart | | gridRowEnd | gre, rowEnd | | gridColumnStart | gcs, columnStart | | gridColumnEnd | gce, columnEnd | | gridRow | gr, row | | gridColumn | gc, column | | gridArea | ga, area | | justifySelf | js | | alignSelf | as | | placeSelf | ps |

The subgrid prop will make the GridItem also a Grid and the flex prop will make it also a Box

Caveats

React 16 only for now.

Only flexbox container properties have been exposed, all flexbox child properties will still have to be added to the child elements directly.

Due to how CSS Grid works all children of the Grid component are technically 'grid items' so you aren't limited to using the GridItem component to style Grid children.

Refs will be forwarded to the inner element using the forwardRef API so the ref will return a reference to the underlying DOM node rather than the instance of the component.

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details