Skip to content

Commit 96bd052

Browse files
committed
update docs
1 parent c3b75c5 commit 96bd052

File tree

1 file changed

+38
-14
lines changed

1 file changed

+38
-14
lines changed

api.md

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,19 @@ var myStyle = stylesheet.get('myStyleClass').attr({color: 'white'}).css();
115115
// will be {color: 'white', backgroundColor: 'black'}
116116
```
117117

118-
119118
#### vars(variables)
120119
* ***variables***: Object specifying additional variables to be made accessable to the styleset function or referenced mixin functions as ```this.get("varName")```
121120

122121
See [variables usage](#project/jhudson8/react-css-builder/section/Usage/Variables) for more details.
123122

124123

124+
#### css()
125+
Return the style attributes object created using the StylesetBuilder.
126+
127+
See [variables usage](#project/jhudson8/react-css-builder/section/Usage/Variables) or [mixins usage](#project/jhudson8/react-css-builder/section/Usage/Mixins) for more details.
128+
129+
130+
125131
### StyleContext
126132
This is the object provided as the single styleset if the styleset value is a function rather than a simple object specifying the style attributes.
127133

@@ -245,15 +251,29 @@ See [Mixins API](#project/jhudson8/react-css-builder/method/react-css-builder/mi
245251

246252
Mixins can return any number of attributes that should be applied to a styleset.
247253

254+
Mixins can be registered [globally](#project/jhudson8/react-css-builder/method/react-css-builder/mixin) or scoped to a [single stylesheet](#project/jhudson8/react-css-builder/method/Stylesheet/mixin?focus=outline)
255+
```
256+
// the mixin can have any number of arguments provided when the mixin is referenced
257+
258+
css.mixin('vendor-prefix', function(name, value) {
259+
260+
// for example only, a smarter impl would eval the user agent to include the appropriate prefix
261+
var rtn = {};
262+
// if you have underscore
263+
_.each(['O', 'Webkit', 'ms', 'Moz'], function(prefix) {
264+
rtn[prefix + name] = value;
265+
});
266+
rtn[name] = value;
267+
return rtn;
268+
});
269+
```
270+
248271
```
249272
var stylesheet = require('react-css-builder').register({
250273
251274
myClassUsingMixins: function(css) {
252275
return css
253-
.mixin('the-mixin-name', param1, param2, ...)
254-
.attr({
255-
// include any additional attributes
256-
})
276+
.mixin('vendor-prefix', 'borderRadius', '3px')
257277
.val();
258278
}
259279
});
@@ -263,6 +283,19 @@ Mixins can return any number of attributes that should be applied to a styleset.
263283
#### Variables
264284
See [Variables API](#project/jhudson8/react-css-builder/method/react-css-builder/vars) to understand how to register variables
265285

286+
Variables can be set [globally](#project/jhudson8/react-css-builder/method/react-css-builder/vars) or scoped to a [single stylesheet](#project/jhudson8/react-css-builder/method/Stylesheet/vars) or set when [getting individual styles attributes](#project/jhudson8/react-css-builder/method/StylesetBuilder/vars?focus=outline).
287+
288+
```
289+
// variables can be set globally
290+
require('react-css-builder').vars({ myGlobalVar: 'foo'});
291+
292+
// variables can be set on a specific stylesheet
293+
stylesheet.vars({ myStylesheetVar: 'bar'});
294+
295+
// variables can be set when referencing the styleset directly
296+
var myStyle = stylesheet.get('myClassUsingMixins').vars({ verySpecificVar: 'baz'}).css();
297+
```
298+
266299
Variables can be referenced in a styleset definition using ```this.get("varName")```
267300
```
268301
var stylesheet = require('react-css-builder').register({
@@ -273,15 +306,6 @@ Variables can be referenced in a styleset definition using ```this.get("varName"
273306
}
274307
}
275308
});
276-
277-
// variables can be set globally
278-
require('react-css-builder').vars({ border: 'solid 2px #000'});
279-
280-
// variables can be set on a specific stylesheet
281-
stylesheet.vars({ border: 'solid 2px #000'});
282-
283-
// variables can be set when referencing the styleset directly
284-
var myStyle = stylesheet.get('myClassUsingMixins').vars({ border: 'solid 2px #000'}).css();
285309
```
286310

287311

0 commit comments

Comments
 (0)