Skip to content

Commit 561c745

Browse files
committed
update example
1 parent a00621a commit 561c745

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

examples/example.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
var reactCSSBuilder = require('react-css-builder');
55
var stylesheet = module.exports = reactCSSBuilder.create({
66

7+
// the simplest style class definition
78
myClass: {
8-
border: 'solid 1px #000'
9+
border: 'solid 1px #000',
10+
margin: '6px'
911
},
1012

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
1116
myClassGroup: {
12-
// any class group must have an "attributes" property
13-
// it's what is returned with // retrieved using stylesheet.css('myClassGroup')
1417
attributes: {},
1518

1619
// retrieved using stylesheet.css('myClassGroup.groupChild1')
@@ -22,6 +25,20 @@ var stylesheet = module.exports = reactCSSBuilder.create({
2225
groupChild2: {
2326
margin: "2px"
2427
},
28+
29+
moreNesting: {
30+
attributes: {
31+
color: '#fff'
32+
},
33+
34+
grandChild1: {
35+
padding: '3px'
36+
},
37+
38+
grandChild2: {
39+
padding: '4px'
40+
}
41+
}
2542
},
2643

2744
// include the styles from "myClassGroup" and "myClassGroup.groupChild1"
@@ -77,5 +94,5 @@ var styleAttributes = stylesheet.css('myClassWithEverything');
7794
// now override the border variable (used by the myClassWithEverything) styleset definition
7895
var styleAttributes = stylesheet.get('myClassWithEverything').vars({ primaryBorder: 'solid 1px #000' }).css();
7996

80-
97+
// this is how you apply the styles to a React component
8198
<MyReactComponent style={styleAttributes}/>

0 commit comments

Comments
 (0)