@@ -14,12 +14,50 @@ Demo: https://trendmicro-frontend.github.io/react-grid-system
14
14
npm install --save react @trendmicro/react-grid-system
15
15
```
16
16
17
- 2 . Install [ react-grid-system ] ( https://github.com/ trendmicro-frontend /react-grid-system) with < b > @ trendmicro </ b > scope :
17
+ 2 . At this point you can import ` @ trendmicro/react-grid-system` and its styles in your application as follows :
18
18
19
19
``` js
20
- import { Provider , Container , Row , Col } from ' @trendmicro/react-grid-system' ;
20
+ import {
21
+ Provider as GridSystemProvider ,
22
+ Container ,
23
+ Row ,
24
+ Col
25
+ } from ' @trendmicro/react-grid-system' ;
26
+
27
+ // Be sure to include styles at some point, probably during your bootstraping
28
+ import ' @trendmicro/react-grid-system/dist/react-grid-system.css' ;
21
29
```
22
30
31
+ ## Recommended Setup
32
+
33
+ Create a common components directory including the GridSystem component, as shown below:
34
+ ```
35
+ components/
36
+ GridSystem/
37
+ index.js
38
+ ```
39
+
40
+ ** components/GridSystem/index.js**
41
+ ``` jsx
42
+ import ' @trendmicro/react-grid-system/dist/react-grid-system.css' ;
43
+ export {
44
+ Provider ,
45
+ Container ,
46
+ Row ,
47
+ Col
48
+ } from ' @trendmicro/react-grid-system' ;
49
+ ```
50
+
51
+ Then, import components like below:
52
+ ``` jsx
53
+ import {
54
+ Provider as GridSystemProvider ,
55
+ Container ,
56
+ Row ,
57
+ Col
58
+ } from ' ./components/GridSystem' ;
59
+ ```
60
+
23
61
## Usage
24
62
25
63
``` jsx
@@ -40,6 +78,34 @@ Demo: https://trendmicro-frontend.github.io/react-grid-system
40
78
< / Container>
41
79
```
42
80
81
+ ### Provider
82
+
83
+ You can wrap ` <Container /> ` , ` <Row /> ` , and ` <Col /> ` in ` <Provider /> ` to pass grid system config through context.
84
+
85
+ ``` jsx
86
+ < Provider
87
+ breakpoints= {[576 , 768 , 992 , 1200 ]}
88
+ containerWidths= {[540 , 720 , 960 , 1140 ]}
89
+ columns= {12 }
90
+ gutterWidth= {20 }
91
+ layout= " flexbox"
92
+ >
93
+ < Container>
94
+ < Row>
95
+ < Col> col< / Col>
96
+ < Col> col< / Col>
97
+ < Col> col< / Col>
98
+ < / Row>
99
+ < / Container>
100
+ < Container>
101
+ < Row>
102
+ < Col> col< / Col>
103
+ < Col> col< / Col>
104
+ < / Row>
105
+ < / Container>
106
+ < / Provider>
107
+ ```
108
+
43
109
## API
44
110
45
111
### Properties
@@ -48,11 +114,11 @@ Demo: https://trendmicro-frontend.github.io/react-grid-system
48
114
49
115
Name | Type | Default | Description
50
116
:--- | :--- | :------ | :----------
51
- breakpoints | Number[ ] | [ 576, 768, 992, 1200, 1600 ] | The breakpoints (minimum width) of devices in screen class sm, md, lg, xl, and xxl.
117
+ breakpoints | Number[ ] | [ 576, 768, 992, 1200, 0 ] | The breakpoints (minimum width) of devices in screen class sm, md, lg, xl, and xxl.
52
118
containerWidths | Number[ ] | [ 540, 720, 960, 1140, 0] | The container widths in pixels of devices in screen class sm, md, lg, xl, and xxl.
53
- columns | Number | 12 | The number of columns. Defaults to 12.
119
+ columns | Number | 12 | The number of columns.
54
120
gutterWidth | Number | 30 | The horizontal padding (called gutter) between two columns. A gutter width of 30 means 15px on each side of a column.
55
- layout | One of:<br >'float '<br >'flex ' | 'float ' | The grid system layout.
121
+ layout | One of:<br >'floats '<br >'flexbox ' | 'floats ' | The grid system layout.
56
122
57
123
#### Container
58
124
@@ -65,29 +131,30 @@ md | Boolean | false | True makes container fluid only in md, not present means
65
131
lg | Boolean | false | True makes container fluid only in lg, not present means fluid everywhere.
66
132
xl | Boolean | false | True makes container fluid only in xl, not present means fluid everywhere.
67
133
xxl | Boolean | false | True makes container fluid only in xxl, not present means fluid everywhere.
134
+ columns | Number | 12 | The number of columns.
68
135
gutterWidth | Number | 30 | The horizontal padding (called gutter) between two columns. A gutter width of 30 means 15px on each side of a column.
69
- layout | One of:<br >'float '<br >'flex ' | 'float ' | The grid system layout.
136
+ layout | One of:<br >'floats '<br >'flexbox ' | 'floats ' | The grid system layout.
70
137
onResize | Function({ screenClass }) | | A callback fired when the resize event occurs.
71
138
72
139
#### Row
73
140
74
141
Name | Type | Default | Description
75
142
:--- | :--- | :------ | :----------
143
+ columns | Number | 12 | The number of columns.
76
144
gutterWidth | Number | 30 | The horizontal padding (called gutter) between two columns. A gutter width of 30 means 15px on each side of a column.
77
- layout | One of:<br >'float'<br >'flex' | 'float' | The grid system layout.
78
-
145
+ layout | One of:<br >'floats'<br >'flexbox' | 'floats' | The grid system layout.
79
146
80
147
#### Col
81
148
82
149
Name | Type | Default | Description
83
150
:--- | :--- | :------ | :----------
84
- width | Number | | The width of the column for all screen classes.
85
- xs | Boolean or Number | | The width of the column for screen class ` xs ` .
86
- sm | Boolean or Number | | The width of the column for screen class ` sm ` .
87
- md | Boolean or Number | | The width of the column for screen class ` md ` .
88
- lg | Boolean or Number | | The width of the column for screen class ` lg ` .
89
- xl | Boolean or Number | | The width of the column for screen class ` xl ` .
90
- xxl | Boolean or Number | | The width of the column for screen class ` xxl ` .
151
+ width | Number or 'auto' | | The width of the column for all screen classes.
152
+ xs | Boolean, Number or 'auto' | | The width of the column for screen class ` xs ` .
153
+ sm | Boolean, Number or 'auto' | | The width of the column for screen class ` sm ` .
154
+ md | Boolean, Number or 'auto' | | The width of the column for screen class ` md ` .
155
+ lg | Boolean, Number or 'auto' | | The width of the column for screen class ` lg ` .
156
+ xl | Boolean, Number or 'auto' | | The width of the column for screen class ` xl ` .
157
+ xxl | Boolean, Number or 'auto' | | The width of the column for screen class ` xxl ` .
91
158
offset | { xs, sm, md, lg, xl, xxl } | | The offset of this column for all screen classes.
92
159
pull | { xs, sm, md, lg, xl, xxl } | | The amount this column is pulled to the left for all screen classes.
93
160
push | { xs, sm, md, lg, xl, xxl } | | The amount this column is pushed to the right for all screen classes.
0 commit comments