|
| 1 | +--- |
| 2 | +name: Grid |
| 3 | +route: /grid |
| 4 | +order: -5 |
| 5 | +--- |
| 6 | + |
| 7 | +import { Playground } from 'docz' |
| 8 | +import { ThemeProvider } from 'emotion-theming' |
| 9 | +import { PropsTable } from '../props-table' |
| 10 | +import { Box } from '../box' |
| 11 | +import { Grid } from './index' |
| 12 | + |
| 13 | + |
| 14 | +# Grid |
| 15 | + |
| 16 | +## Description |
| 17 | + |
| 18 | +[Grid Layout](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout) |
| 19 | + |
| 20 | +- Item conrolled with `col`, `row` prop in `Grid.Item` component |
| 21 | +- [Space](https://github.com/exah/pss/blob/master/docs/api.md#space) between items conrolled with `gap`, `gapx` and `gapy` props |
| 22 | +- [Box alignment](https://rachelandrew.co.uk/css/cheatsheets/box-alignment) styles |
| 23 | + |
| 24 | + |
| 25 | +### Components: |
| 26 | + |
| 27 | +#### `Grid` — Grid layout container |
| 28 | + |
| 29 | +- `gap` — `grid-gap` |
| 30 | +- `gapx` — `grid-column-gap` |
| 31 | +- `gapy` — `grid-row-gap` |
| 32 | +- `autoFlow` — `grid-auto-flow` |
| 33 | +- `autoCols` — `grid-auto-columns` |
| 34 | +- `autoRows` — `grid-auto-rows` |
| 35 | +- `templateCols` — `grid-template-columns` |
| 36 | +- `templateRows` — `grid-template-rows` |
| 37 | +- `templateAreas` — `grid-template-areas` |
| 38 | +- `alignItems` — `align-items` |
| 39 | +- `justifyItems` — `justify-items` |
| 40 | +- `alignContent` — `align-content` |
| 41 | +- `justifyContent` — `justify-content` |
| 42 | + |
| 43 | + |
| 44 | +#### `Grid.Item` |
| 45 | + |
| 46 | +- `col` — `grid-column` |
| 47 | +- `row` — `grid-row` |
| 48 | +- `area` — `grod-area` |
| 49 | +- `justifySelf` — `justify-self` |
| 50 | +- `alignSelf` — `align-self` |
| 51 | +- `order` — `order` |
| 52 | + |
| 53 | + |
| 54 | +## Usage |
| 55 | + |
| 56 | +```js |
| 57 | +import { Grid } from 'pss-components' |
| 58 | +``` |
| 59 | + |
| 60 | +```js |
| 61 | +<Grid gap={2}> |
| 62 | + <Grid.Item col='span 6'> |
| 63 | + Content |
| 64 | + </Grid.Item> |
| 65 | + <Grid.Item col='span 4'> |
| 66 | + Content |
| 67 | + </Grid.Item> |
| 68 | + <Grid.Item col='span 2'> |
| 69 | + Content |
| 70 | + </Grid.Item> |
| 71 | +</Grid> |
| 72 | +``` |
| 73 | + |
| 74 | + |
| 75 | +## Examples |
| 76 | + |
| 77 | +### Basic |
| 78 | + |
| 79 | +<Playground> |
| 80 | + <Grid templateCols='repeat(12, 1fr)' gapx={1}> |
| 81 | + <Grid.Item col='span 2' outline='1px solid' pd={1}> |
| 82 | + 2 |
| 83 | + </Grid.Item> |
| 84 | + <Grid.Item col='span 2' outline='1px solid' pd={1}> |
| 85 | + 2 |
| 86 | + </Grid.Item> |
| 87 | + <Grid.Item col='span 2' outline='1px solid' pd={1}> |
| 88 | + 2 |
| 89 | + </Grid.Item> |
| 90 | + <Grid.Item col='span 2' outline='1px solid' pd={1}> |
| 91 | + 2 |
| 92 | + </Grid.Item> |
| 93 | + <Grid.Item col='span 2' outline='1px solid' pd={1}> |
| 94 | + 2 |
| 95 | + </Grid.Item> |
| 96 | + <Grid.Item col='span 2' outline='1px solid' pd={1}> |
| 97 | + 2 |
| 98 | + </Grid.Item> |
| 99 | + </Grid> |
| 100 | +</Playground> |
| 101 | + |
| 102 | +### Vertical and horizontal space between items |
| 103 | + |
| 104 | +<Playground> |
| 105 | + <Grid templateCols='repeat(12, 1fr)' gap={1}> |
| 106 | + <Grid.Item col='span 1' outline='1px solid' pd={1}> |
| 107 | + 1 |
| 108 | + </Grid.Item> |
| 109 | + <Grid.Item col='span 2' outline='1px solid' pd={1}> |
| 110 | + 2 |
| 111 | + </Grid.Item> |
| 112 | + <Grid.Item col='span 3' outline='1px solid' pd={1}> |
| 113 | + 3 |
| 114 | + </Grid.Item> |
| 115 | + <Grid.Item col='span 6' outline='1px solid' pd={1}> |
| 116 | + 6 |
| 117 | + </Grid.Item> |
| 118 | + <Grid.Item col='span 12' outline='1px solid' pd={1}> |
| 119 | + 12 |
| 120 | + </Grid.Item> |
| 121 | + <Grid.Item col='span 4' outline='1px solid' pd={1}> |
| 122 | + 4 |
| 123 | + </Grid.Item> |
| 124 | + <Grid.Item col='span 4' outline='1px solid' pd={1}> |
| 125 | + 4 |
| 126 | + </Grid.Item> |
| 127 | + <Grid.Item col='span 4' outline='1px solid' pd={1}> |
| 128 | + 4 |
| 129 | + </Grid.Item> |
| 130 | + </Grid> |
| 131 | +</Playground> |
| 132 | + |
| 133 | +### Control each item `col` and `row` props |
| 134 | + |
| 135 | +<Playground> |
| 136 | + <Grid templateCols='repeat(12, 1fr)' gap={1}> |
| 137 | + <Grid.Item row='1' col='1 / span 3' outline='1px solid' pd={1}> |
| 138 | + 1 |
| 139 | + </Grid.Item> |
| 140 | + <Grid.Item row='2' col='4 / span 3' outline='1px solid' pd={1}> |
| 141 | + 2 |
| 142 | + </Grid.Item> |
| 143 | + <Grid.Item row='3' col='7 / span 3' outline='1px solid' pd={1}> |
| 144 | + 3 |
| 145 | + </Grid.Item> |
| 146 | + <Grid.Item row='4' col='10 / span 3' outline='1px solid' pd={1}> |
| 147 | + 4 |
| 148 | + </Grid.Item> |
| 149 | + </Grid> |
| 150 | +</Playground> |
| 151 | + |
| 152 | + |
| 153 | +## Props |
| 154 | + |
| 155 | +### Grid |
| 156 | + |
| 157 | +<PropsTable of={Grid} /> |
| 158 | + |
| 159 | +### Grid.Item |
| 160 | + |
| 161 | +<PropsTable of={Grid.Item} /> |
0 commit comments