Skip to content

Commit c581f70

Browse files
committed
update docs
1 parent 6da74c1 commit c581f70

File tree

1 file changed

+28
-115
lines changed

1 file changed

+28
-115
lines changed

api.md

Lines changed: 28 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -41,84 +41,35 @@ Register a set of styles which are associated with an alias which can be referen
4141

4242
Return the [Stylesheet](#project/jhudson8/react-css-builder/package/Stylesheet) object
4343

44-
```
45-
module.exports = require('react-css-builder').register('some-namespace', {
46-
// the stylesets can be much more advanced, this is an example most similar to CSS
47-
myClass: {
48-
color: 'white'
49-
},
50-
anotherClass: {
51-
color: 'black'
52-
}
53-
});
54-
```
55-
see [Examples](#project/jhudson8/react-css-builder/section/Examples) to see all available options including, importing external stylesets, using mixins, variable references and nested styles.
44+
See [Creating a stylesheet](#project/jhudson8/react-css-builder/section/Usage/Creating%20a%20stylesheet) for more details.
45+
5646

5747
#### vars(varsObject)
5848
* ***varsObject***: a hash of variables to register which will be available to styleset rules (using this.get("varName")).
5949

60-
```
61-
var css = require('react-css-builder');
62-
css.vars({
63-
primaryColor: 'white'
64-
});
50+
See [variables usage](#project/jhudson8/react-css-builder/section/Usage/Variables) for more details.
51+
6552

66-
// variables available using this.get within a stylesheet rule function
67-
css.register('my-styleset-namespace', {
68-
myClass: function() {
69-
return color: this.get('primaryColor')
70-
}
71-
});
72-
```
7353
#### mixin(mixinName, mixinFunction)
7454
* ***mixinName***: the name of the mixin
7555
* ***mixinFunction***: the mixin function which can take any number of arguments
7656

7757
The mixin can be included in a styleset function. It should return an object represent all style attributes which should be included.
7858

79-
```
80-
var css = require('react-css-builder');
81-
css.mixin('background-image', function(imagePath) {
82-
// silly little example
83-
return {
84-
backgroundImage: 'url(\"' + imagePath + '\")'
85-
};
86-
});
87-
88-
// mixins can be referenced using ```css.mixin``` within a stylesheet rule function (```css``` is the styleset rule function argument)
89-
css.register('my-styleset', {
90-
myClass: function(css) {
91-
return css
92-
.mixin('background-image', 'foo.gif')
93-
.val();
94-
}
95-
});
96-
```
59+
See [mixin usage](#project/jhudson8/react-css-builder/section/Usage/Mixins) for details.
9760

9861

9962
### Stylesheet
100-
This is the object returned when calling ```require('react-css-builder').register(...)
63+
This is the object returned when calling ```require('react-css-builder').register(...)```
64+
10165

10266
#### css(className)
10367
* ***className***: return the styleset object matching the className key which can be used for associated with a React component ```style``` property.
10468

10569
If the ```className``` value has ```.``` values in it, styleset rules will be referenced as nested objects.
10670

107-
```
108-
var stylesheet = require('react-css-builder').register({
109-
panel: {
110-
// attributes is a special key used when nesting if the current level should have style attributes
111-
attributes: {
112-
color: 'white'
113-
},
114-
header: {
115-
color: 'black'
116-
}
117-
}
118-
});
119-
stylesheet.css('panel'); // = {color: 'white'}
120-
stylesheet.css('panel.header'); // = {color: 'black'}
121-
```
71+
See [Creating a stylesheet](#project/jhudson8/react-css-builder/section/Usage/Creating%20a%20stylesheet) for more details
72+
12273

12374
#### get(className)
12475
* ***className***: return the styleset object matching the className key which can be used for associated with a React component ```style``` property.
@@ -127,34 +78,30 @@ Very much like the previously described ```css``` method but allows for addition
12778

12879
Returns a [StylesetBuilder](#project/jhudson8/react-css-builder/package/StylesetBuilder)
12980

130-
```
131-
var stylesheet = require('...').register(...)
132-
stylesheet.get('myStyle')
133-
.vars({
134-
foo: 'this var will be available in the styleset function / mixin function as this.get("foo")'
135-
})
136-
.attr({
137-
content: 'this will be an additional attribute included in the returned styleset'
138-
})
139-
// this returns the styleset value
140-
.css();
141-
```
81+
See [styleset definitions](#project/jhudson8/react-css-builder/section/Usage/Styleset%20Definitions) for more details.
82+
14283

14384
#### mixin(mixinName, mixinFunction)
14485
* ***mixinName***: the name of the mixin
14586
* ***mixinFunction***: the mixin function which can take any number of arguments
14687

14788
Exactly the same as [react-css-builder mixin](#project/jhudson8/react-css-builder/method/react-css-builder/mixin) except that the mixin registered will *only* be accessable to this particular stylesheet.
14889

90+
See [mixin usage](#project/jhudson8/react-css-builder/section/Usage/Mixins) for details.
91+
92+
14993
#### vars(varsObject)
15094
* ***varsObject***: a hash of variables to register which will be available to styleset rules (using this.get("varName")).
15195

15296
Exactly the same as [react-css-builder vars](l#project/jhudson8/react-css-builder/method/react-css-builder/vars) except that the provided variables will *only* be accessable to this particular stylesheet.
15397

98+
See [variables usage](#project/jhudson8/react-css-builder/section/Usage/Variables) for more details.
99+
154100

155101
### StylesetBuilder
156102
This is the object returned when calling ```get``` from a [StylesetBuilder](#project/jhudson8/react-css-builder/package/StylesetBuilder). It is used to apply variables and attributes to a styleset request.
157103

104+
158105
#### attr(styleAttributes)
159106
* ***styleAttributes***: Additional attributes that should be included with the attributes defined with the styleset defined by the class name.
160107

@@ -168,70 +115,35 @@ var myStyle = stylesheet.get('myStyleClass').attr({color: 'white'}).css();
168115
// will be {color: 'white', backgroundColor: 'black'}
169116
```
170117

118+
171119
#### vars(variables)
172120
* ***variables***: Object specifying additional variables to be made accessable to the styleset function or referenced mixin functions as ```this.get("varName")```
173121

174-
```
175-
var stylesheet = require('...').register({
176-
myStyleClass: function() {
177-
var radius = this.get('radius');
178-
return {
179-
borderRadius: radius,
180-
WebkitBorderRadius: radius
181-
}
182-
}
183-
});
184-
var myStyle = stylesheet.get('myStyleClass').var({radius: 3}).css();
185-
// will be {borderRadius: 3, WebkitBorderRadius: 3}
186-
```
122+
See [variables usage](#project/jhudson8/react-css-builder/section/Usage/Variables) for more details.
123+
187124

188125
### StyleContext
189-
This is the object provided as the single argument a styleset if the styleset value is a function rather than a simple object specifying the style attributes.
126+
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.
127+
128+
See [styleset definitions](#project/jhudson8/react-css-builder/section/Usage/Styleset%20Definitions) for more details.
129+
190130

191131
#### include(stylesetName)
192132
* ***stylesetName***: the name of a styleset in the current stylesheet or, if prefixed with the namespace separated by a ```.```, the name of a styleset in another stylesheet.
193133

194134
Include all of the attributes defined by another styleset.
195135

196-
```
197-
var stylesheet = require('...').register({
198-
anotherStyleClass: {
199-
color: 'white'
200-
},
201-
myStyleClass: function(css) {
202-
return css
203-
.include('anotherStyleClass')
204-
.val();
205-
}
206-
});
207-
var myStyle = stylesheet.css('myStyleClass');
208-
// will be {color: 'white'}
209-
```
136+
See [include usage](#project/jhudson8/react-css-builder/section/Usage/Includes) for more details.
137+
210138

211139
#### mixin(mixinName[, mixinParameters])
212140
* ***mixinName***: the name of a registered mixin to include
213141
* ***mixinParameters***: any number of parameters that the mixin is expecting
214142

215143
Include all of the attributes returned by a registered by a mixin
216144

217-
```
218-
// very silly example just to demonstrate a mixin
219-
var stylesheet = require('...').register({
220-
myStyleClass: function(css) {
221-
return css
222-
.mixin('color', 'white')
223-
.val();
224-
}
225-
});
226-
stylesheet.register('myMixin', function(name, value) {
227-
var rtn = {};
228-
rtn[name] = value;
229-
return rtn;
230-
});
145+
See [mixin usage](#project/jhudson8/react-css-builder/section/Usage/Mixins) for details.
231146

232-
var myStyle = stylesheet.css('myStyleClass');
233-
// will be {color: 'white'}
234-
```
235147

236148
#### val()
237149
Called when all attribute inclusions are complete to return the styleset attributes.
@@ -245,6 +157,7 @@ var stylesheet = require('...').register({
245157
});
246158
```
247159

160+
248161
Sections
249162
----------
250163
### Usage

0 commit comments

Comments
 (0)