0.6.0 • Published 3 years ago

@intactile/react-layout v0.6.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

React Layout

The Every Layout layouts implemented as a set of React components.

Install

$ yarn add @intactile/react-layout

Setup

This set of components is highly opiniated and as advised in “Every Layout” it makes use of a modular scale to set some sensible default. You should define at least 2 custom css properties: --s1 (default spacing value) and --measure (sensible default for the length of a text line). I encourage you to start with the following scale and adapt it to your needs.

:root {
  --ratio: 1.5;
  --s-5: calc(var(--s-4) / var(--ratio));
  --s-4: calc(var(--s-3) / var(--ratio));
  --s-3: calc(var(--s-2) / var(--ratio));
  --s-2: calc(var(--s-1) / var(--ratio));
  --s-1: calc(var(--s0) / var(--ratio));
  --s0: 1rem;
  --s1: calc(var(--s0) * var(--ratio));
  --s2: calc(var(--s1) * var(--ratio));
  --s3: calc(var(--s2) * var(--ratio));
  --s4: calc(var(--s3) * var(--ratio));
  --s5: calc(var(--s4) * var(--ratio));

  --measure: 65ch;
}

Use

import { Box } from '@intactile/react-layout';

function MyComponent() {
  return (
    <Box>content</Box>
  );
}

Layouts

Eleven differents layouts are currently implemented: Box, Center, Cluster, Cover, Frame, Grid, Imposter, Reel, Sidebar, Stack and Switcher.

Box

Props

NameTypeDefaultDescription
paddingstringvar(--s1, 1.5rem)Set the padding around the box, accept any valid css size value
borderWidthnumber1Set the width of the border around the box

Center

Props

NameTypeDefaultDescription
guttersstringnullSet the gutters on each side of the layout, accept any valid css size value
maxstringvar(--measure, 65ch)Set the max width of the layout, accept any valid css size value
andTextboolfalseShould the text inside the layout also be centered or not?
intrinsicboolfalseShould the “nodes” inside the layout also be centered or not?

Cluster

Props

NameTypeDefaultDescription
spacestringvar(--s1, 1.5rem)Set the gutters on each side of the layout, accept any valid css size value
justifystringflex-startUse a valid justify-content css property value
alignstringflex-startUse a valid align-items css property value

Sidebar

Props

NameTypeDefaultDescription
sidestringleftWhich element to treat as the sidebar, accept "left" or "right"
sideWidthstringnullRepresents the width of the sidebar when adjacent. If not set (null) it defaults to the sidebar's content width
contentMinstring50%A CSS percentage value. The minimum width of the content element in the horizontal configuration
spacestringvar(--s1)Set the space between the sidebar and the main content, accept any valid css margin value

Stack

Props

NameTypeDefaultDescription
spacestringvar(--s1)Set the space between each children of the layout, accept any valid css margin value
splitAfternumbernullThe element after which to split the stack with an auto margin

Switcher

Props

NameTypeDefaultDescription
spacestringvar(--s1)Set the space between each children of the layout, accept any valid css margin value
thresholdnumbervar(--measure)Represent the container breakpoint, accept any valid css width value
limitnumber4Represent the maximum number of items allowed for a horizontal layout
0.5.0

3 years ago

0.4.1

3 years ago

0.6.0

3 years ago

0.4.0

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago