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

layabout

v0.9.0

Published

Simple layout components for React

Downloads

18

Readme

Layabout

Build Status

Low config layout components for React.

View the storybook demo at https://yearofthedan.github.io/layabout/


Issues and contributions are welcome. Specifics on how and the guiding philosophy are under CONTRIBUTING.md.

This is very much in alpha, so expect the api to shift a lot.


Components

Grid

Lays out children according to a defined grid structure

|Prop | Description | Options |Default | |-------|-------------|---------|---------| |container|Element to hold container styles and render children into. | Any string representing a HTML DOM element (eg. div) or a React component. For React components the style prop must be received by the container and passed to an underlying DOM element to render it (eg. a HTML DOM element). |generates a div| |widths|An array of column widths|String values will be mapped directly to css so feel free to use things like minmax(). If an integer is given it will be mapped as an fr unit.|['auto'] |heights|An array of row heights|String values will be mapped directly to css so feel free to use things like minmax(). If an integer is given it will be mapped as an fr unit.|['auto'] |columnGap|The gap or gutter between each column|A string property to be mapped directly as css (eg.4px)|none |rowGap|The gap or gutter between each row|A string property to be mapped directly as css (eg.4px)|none |style|Style properties to be applied to the container. This particularly supports use cases where you're combining layout components.|A style object|none |layout|A template expressing the entries in the grid. See below for some advice on use|A multiline string where each line represents one row in the grid and each line contains the list of elements at each column position. Use the child component name, or a . to denote an empty cell. If a component is named multiple times it means that the component takes up multiple cells. |Empty layout, meaning the children will flow into the provided column and row structure defined by the widths and heights props

Any other props are passed through to the container.

Hey! Some things to think about with the layout prop The magic of Grid is in the binding between the template as described in the layout prop and the children.

1. everything needs to have a unique name

If you have multiple same named elements - lets us div as an example - as children there's no way to define different div sections in the template since you should just write 'div'. To avoid this you should wrap them in a uniquely named component (nb. this is more semantic anyway). Alternatively, you can just not use the template prop, in which case the elements will just flow across the rows and columns.

2. use fromComponents for safety

The renderer will try to connect the display name of the element to the token in the layout string. A few things can interfere here, particularly minimisation steps in your build which may mean that the child elements display name is no longer the same as what you wrote in the template. To get around this you can import and use fromComponents and refer to the components in the template directly. This will map any provided components to their actual display name at run time.

Usage

import {fromComponents} from 'layabout';
<Grid  
  widths={[1, 4, 1]}  
  heights={['100px', 'minmax(100px, 200px)', '100px', 'auto', '50px']}  
  layout={fromComponents`  
   ${MenuHeader} ${MenuHeader}   ${MenuHeader}
   .             ${LogoSection}  .
   .             ${Search}       .
   .             .               .
   ${Footer}     ${Footer}       ${Footer}  
 `}  
  container={Page}  
>  
 <MenuHeader />
 <LogoSection />
 <Search />
 <Footer />
</Grid>

FlexRow / FlexColumn

Lays out its children one by one according to a set of relative sizes. Overflow continues onto the new row/column, following the same template.

|Prop | Description | Options |Default | |-------|-------------|---------|---------| |sizes|Set of relative weights for the amount of space available to children on a row| An array of numbers for the row|Children will share available space equally | |container|Element to hold container styles and render children into. | Any string representing a HTML DOM element (eg. div) or a React component. For React components the style prop must be received by the container and passed to an underlying DOM element to render it (eg. a HTML DOM element). |generates a div| |alignCrossAxis|How to align content on the cross axis|start,middle, end | middle |style|Style properties to be applied to the container. This particularly supports use cases where you're combining layout components.|A style object|none

Usage

<FlexRow  
 sizes={[2, 4, 4]} container={Article}>  
 <section />
 <section />
 <section />
</FlexRow>  

In the example above the sections would have spacing of 2/10ths, 4/10ths, and 4/10ths of the total available width.

SpacedColumn / SpacedRow

Lays out children within the space available. Any remaining spacing is allocated according to the spacing prop.

|Prop | Description | Options |Default | |-------|-------------|---------|---------| |spacing|How to allocate remaining space| between, around, start, middle, end |between| |container|Element to hold container styles and render children into. | Any string representing a HTML DOM element (eg. div) or a React component. For React components the style prop must be received by the container and passed to an underlying DOM element to render it (eg. a HTML DOM element). |generates a div| |alignCrossAxis|How to align content on the cross axis|start, middle, end | middle |style|Style properties to be applied to the container. This particularly supports use cases where you're combining layout components.|A style object|none

Usage

<SpacedRow spacing="between" container={MyCustomContainer}>  
 <section />
 <section />
 <section />
</SpacedRow>