1.0.6 • Published 5 years ago

every-layout v1.0.6

Weekly downloads
34
License
ISC
Repository
github
Last release
5 years ago

Every Layout

This is a collection of Styled Components for the awesome Every Layout, by Heydon Pickering & Andy Bell

Here's an excerpt from to explain why these components are important:

Relearn CSS layout

If you find yourself wrestling with CSS layout, it’s likely you’re making decisions for browsers they should be making themselves. Through a series of simple, composable layouts, Every Layout will teach you how to better harness the built-in algorithms that power browsers and CSS. Employing algorithmic layout design means doing away with @media breakpoints, “magic numbers”, and other hacks, to create context-independent layout components. Your future design systems will be more consistent, terser in code, and more malleable in the hands of your users and their devices.

Installation

npm i every-layout

Usage

You can destructure the default export for whichever components you'd like. For example:

import { Cover, Stack } from 'every-layout';
// OR
const { Cover, Stack } = require('every-layout');

Component Customization

Every component has some sane defaults, but can be overriden for custom styling. You can also pass any component a style prop to add your own styles.

Stack

A stack of items on top of each other. The Stack component stacks all of it's children with the specified margin between them.

Example:

<Stack space="1.5rem">
  <h2>Header</h2>
  <img src={logo} className="App-logo" />
  <p>Paragraph</p>
</Stack>
PropUsageDefault
spacemargin-top1rem

Sidebar

Any two components that can go next to each other if there is enough space. Otherwise, Sidebar reverts to stacking them on top of each other. The first child is the "sidebar", and the second child is the "content". More than two children will result in undefined behaviour.

Example:

<Sidebar
  space="1rem"
  contentMinWidth="50%"
  sidebarWidth="20rem"
  elastic={false}
>
  <div>Hello</div>
  <div>Hi</div>
</Sidebar>
PropUsageDefault
spacemargin1rem
elasticWhether or not sidebar width is specified, must be used in conjunction with sidebarWidthfalse
sidebarWidthflex-basis20rem
contentMinWidthWidth at which the sidebar breaks to go on top on content, min-width50%

Cover

Cover treats one of it's children as the "principal" component, and will center it vertically within it. Other components will be spread between the top and bottom, pushed to the edge of the container's boundaries.

The principal component must have a principal className.

Example:

<Cover minHeight="100vh" padding="1rem" margin="1rem">
  <Stack className="principal">
    <h1>How To Create A Book Cover</h1>
    <p>With Flexbox & Love</p>
  </Stack>
  <p>By Heydon Pickering and Aaroh Mankad</p>
</Cover>
PropUsageDefault
paddingpadding1rem
marginmargin1rem
minHeightDefault height of the Cover component, min-height100vh
1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago