|
3 | 3 |
|
4 | 4 | # React CSS Grid
|
5 | 5 |
|
6 |
| -## Abstract |
| 6 | +A pleasingly simple-to-use horizontal grid system for React based on [CSS Grid Layout](https://www.w3.org/TR/css-grid-1/), complete with breakpoints and nested-grid support. |
7 | 7 |
|
8 |
| -This project leverages React's Context API with the CSS Grid Layout specification in a way that allows for a pleasingly simple-to-use horizontal grid system, complete with breakpoints and nested-grid support. |
| 8 | +## Quick Start |
9 | 9 |
|
10 |
| -## Component Composition |
| 10 | +### Installation |
11 | 11 |
|
12 |
| -```jsx |
13 |
| - <GridProvider |
14 |
| - hGap="columnWidth" |
15 |
| - vGap="10px" |
16 |
| - breakpoints={{ |
17 |
| - xs: 350, |
18 |
| - s: 576, |
19 |
| - m: 768, |
20 |
| - l: 992, |
21 |
| - xl: 1200, |
22 |
| - }} |
23 |
| - classPrefix="demo" |
24 |
| - scopeCSSTo="#grid-demo" |
25 |
| - > |
26 |
| - <div id="grid-demo"> |
27 |
| - <Grid> |
28 |
| - <Cell |
29 |
| - hStart={2} |
30 |
| - hSpan={4} |
31 |
| - hStartL={1} |
32 |
| - hSpanS={6} |
33 |
| - > |
34 |
| - <Grid> |
35 |
| - <Cell |
36 |
| - hSpan={2} |
37 |
| - hSpanS={3} |
38 |
| - > |
39 |
| - ... |
40 |
| - </Cell> |
41 |
| - <Cell |
42 |
| - hSpan={2} |
43 |
| - hSpanS={3} |
44 |
| - > |
45 |
| - ... |
46 |
| - </Cell> |
47 |
| - </Grid> |
48 |
| - </Cell> |
49 |
| - <Cell |
50 |
| - hSpan={8} |
51 |
| - hSpanL={9} |
52 |
| - hSpanS={8} |
53 |
| - > |
54 |
| - ... |
55 |
| - </Cell> |
56 |
| - </Grid> |
57 |
| - </div> |
58 |
| - </GridProvider> |
| 12 | +```bash |
| 13 | +$ yarn add @trbl/react-css-grid |
59 | 14 | ```
|
60 | 15 |
|
61 |
| -## Component Documentation |
62 |
| - |
63 |
| -The source components in their raw form are found in the `src` directory. These are all batch exported from the top-level `index.js` so that they can be easily accessed via import. |
64 |
| - |
65 |
| - - [Grid ](/src/Grid/README.md) |
66 |
| - - [Cell](/src/Cell/README.md) |
67 |
| - - [Grid Provider](/src/GridProvider/README.md) |
| 16 | +### Compositon |
68 | 17 |
|
69 |
| -## Environment |
| 18 | +```jsx |
| 19 | + import React from 'react'; |
| 20 | + import { GridProvider, Grid, Cell } from '@trbl/react-css-grid'; |
| 21 | + |
| 22 | + const App = () => { |
| 23 | + return ( |
| 24 | + <GridProvider |
| 25 | + hCount={12} |
| 26 | + hGap="columnWidth" |
| 27 | + vGap="10px" |
| 28 | + breakpoints={{ |
| 29 | + xs: 350, |
| 30 | + s: 576, |
| 31 | + m: 768, |
| 32 | + l: 992, |
| 33 | + xl: 1200, |
| 34 | + }} |
| 35 | + > |
| 36 | + <Grid> |
| 37 | + <Cell hSpan={6}> |
| 38 | + ... |
| 39 | + </Cell> |
| 40 | + <Cell |
| 41 | + hSpan={10} |
| 42 | + hStart={2} |
| 43 | + hSpanL={12} |
| 44 | + hStartL={1} |
| 45 | + hSpanS={6} |
| 46 | + > |
| 47 | + <Grid> |
| 48 | + <Cell |
| 49 | + hSpan={5} |
| 50 | + hSpanL={6} |
| 51 | + > |
| 52 | + ... |
| 53 | + </Cell> |
| 54 | + <Cell |
| 55 | + hSpan={5} |
| 56 | + hSpanL={6} |
| 57 | + > |
| 58 | + ... |
| 59 | + </Cell> |
| 60 | + </Grid> |
| 61 | + </Cell> |
| 62 | + </Grid> |
| 63 | + </GridProvider> |
| 64 | + ) |
| 65 | + } |
| 66 | +``` |
70 | 67 |
|
71 |
| -### Distribution |
| 68 | +## Demo |
72 | 69 |
|
73 |
| -The entrypoint for the production bundle is `/dist/build.bundle.js`, as defined in `package.json`. Importing this project will return that bundle. |
| 70 | +To demo locally, clone the repo and |
74 | 71 |
|
75 |
| -### Compilation and Transpilation |
| 72 | +```bash |
| 73 | +$ yarn install |
| 74 | +$ npm run dev |
| 75 | +$ open http://localhost:3000 |
| 76 | +``` |
76 | 77 |
|
77 |
| -Generating this production bundle is defined in `webpack.production.config.js`, one of two custom webpack configurations defined at the top of this repo. It simply processes all of the `.js` files within the `src` directory through the `babel-loader` transpiler and into the `dist` directory. |
| 78 | +## Documentation |
78 | 79 |
|
79 |
| - - tldr: `npm run build` |
| 80 | +All available props can be found via the references below: |
80 | 81 |
|
81 |
| -### Development |
| 82 | + - [Grid](/src/Grid/README.md) |
| 83 | + - [Cell](/src/Cell/README.md) |
| 84 | + - [Grid Provider](/src/GridProvider/README.md) |
82 | 85 |
|
83 |
| -The other webpack configuration is `webpack.development.config.js` which does a few things differently -- compilation happens from the `demo` directory as opposed to the `src` directory directly. It then will spin up `webpack-dev-server`, which serves a compiled and transpiled build _in memory_, with hot-reloading enabled. |
| 86 | +## License |
84 | 87 |
|
85 |
| - - tldr: `npm run dev` |
| 88 | +[MIT](https://github.com/trbldesign/react-css-grid/blob/master/LICENSE) Copyright (c) TRBL, LLC |
0 commit comments