File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change 4
4
var reactCSSBuilder = require ( 'react-css-builder' ) ;
5
5
var stylesheet = module . exports = reactCSSBuilder . create ( {
6
6
7
+ // the simplest style class definition
7
8
myClass : {
8
- border : 'solid 1px #000'
9
+ border : 'solid 1px #000' ,
10
+ margin : '6px'
9
11
} ,
10
12
13
+ // class hierarchies can be as many levels deep as you with. each parent object
14
+ // must have an "attributes" property which references the style returned
15
+ // for the parent if requested
11
16
myClassGroup : {
12
- // any class group must have an "attributes" property
13
- // it's what is returned with // retrieved using stylesheet.css('myClassGroup')
14
17
attributes : { } ,
15
18
16
19
// retrieved using stylesheet.css('myClassGroup.groupChild1')
@@ -22,6 +25,20 @@ var stylesheet = module.exports = reactCSSBuilder.create({
22
25
groupChild2 : {
23
26
margin : "2px"
24
27
} ,
28
+
29
+ moreNesting : {
30
+ attributes : {
31
+ color : '#fff'
32
+ } ,
33
+
34
+ grandChild1 : {
35
+ padding : '3px'
36
+ } ,
37
+
38
+ grandChild2 : {
39
+ padding : '4px'
40
+ }
41
+ }
25
42
} ,
26
43
27
44
// include the styles from "myClassGroup" and "myClassGroup.groupChild1"
@@ -77,5 +94,5 @@ var styleAttributes = stylesheet.css('myClassWithEverything');
77
94
// now override the border variable (used by the myClassWithEverything) styleset definition
78
95
var styleAttributes = stylesheet . get ( 'myClassWithEverything' ) . vars ( { primaryBorder : 'solid 1px #000' } ) . css ( ) ;
79
96
80
-
97
+ // this is how you apply the styles to a React component
81
98
< MyReactComponent style = { styleAttributes } />
You can’t perform that action at this time.
0 commit comments