Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 33 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Read our blog post [here](http://www.actioniq.co/blog/reactjs-cramping-my-style/

## Example

```
```js
const StyleBuilder = require("style-builder");

const _styles = StyleBuilder.build({
Expand All @@ -23,45 +23,57 @@ console.log(_styles);
marginLeft: "10px"
}
```

## Options

Style builder can also take options when building styles. Currently only one option is available.

`cache` (default: `true`): If true, style builder will store a cache of the results from style functions, key'd off the arguments. This is very useful in React if you use the pure render mixin. Each time you pass a computed style to a child component, it will receive the exact (===) same style object.

For example:
```
const _styles = StyleBuilder.build({
awesomeStyle: (iLikeGreen) => ({
background: iLikeGreen ? "green" : "blue",
}),
}, {
cache: true,
});

```js
const _styles = StyleBuilder.build(
{
awesomeStyle: iLikeGreen => ({
background: iLikeGreen ? "green" : "blue"
})
},
{
cache: true
}
);
console.log(_styles.awesomeStyle(true) === _styles.awesomeStyle(true)); // true

const _styles = StyleBuilder.build({
awesomeStyle: (iLikeGreen) => ({
background: iLikeGreen ? "green" : "blue",
}),
}, {
cache: false,
});
const _styles = StyleBuilder.build(
{
awesomeStyle: iLikeGreen => ({
background: iLikeGreen ? "green" : "blue"
})
},
{
cache: false
}
);
console.log(_styles.awesomeStyle(true) === _styles.awesomeStyle(true)); // false
```

## Build

```
npm run-script build
```

## Test

```
npm test
```

## TODO
* background
* font
* transition
* transform
* list-style

- background
- font
- transition
- transform
- list-style