-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {createElement as h} from 'react'; | ||
import {storiesOf} from '@storybook/react'; | ||
const {action} = require('@storybook/addon-actions'); | ||
const {linkTo} = require('@storybook/addon-links'); | ||
const {create} = require('../index'); | ||
const {addon} = require('../addon/spread'); | ||
|
||
const renderer = create(); | ||
addon(renderer); | ||
const {spread} = renderer; | ||
|
||
const rule = spread({ | ||
border: '1px solid red' | ||
}, 'RedBorder'); | ||
|
||
storiesOf('Addons/spread()', module) | ||
.add('As class name', () => | ||
h('div', {className: rule}, 'Hello world') | ||
) | ||
.add('As data attribute', () => | ||
h('div', rule, 'Hello world') | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# `spread()` Addon | ||
|
||
Works the same as [`rule()`](./rule.md) interface, but instead of returning a string of | ||
class names, it returns an object of data attributes that can be "spread". | ||
|
||
```js | ||
const rule = nano.spread({ | ||
color: 'red' | ||
}); | ||
|
||
<div {...rule}>Hello world!</div> | ||
``` | ||
|
||
Or, it can be stringified to get a class name. | ||
|
||
```js | ||
const rule = nano.spread({ | ||
color: 'red' | ||
}); | ||
|
||
<div className={rule}>Hello world!</div> | ||
``` | ||
|
||
|
||
## Installation | ||
|
||
Simply install `spread` addon. | ||
|
||
Read more about the [Addon Installation](./Addons.md#addon-installation). |