Skip to content

Commit

Permalink
Merge pull request #2 from zvictor/patch-1
Browse files Browse the repository at this point in the history
Add instructions for use as extension
  • Loading branch information
Muhammed Thanish authored Mar 22, 2017
2 parents fb1cae0 + dfa3af2 commit c9fae57
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ React Storybook decorator to center components.
npm i @kadira/react-storybook-decorator-centered
```

Then add the decorator like this:
#### As a decorator
You can set the decorator locally:

```js
import React from 'react';
Expand All @@ -22,7 +23,7 @@ storiesOf('MyComponent', module)
.add('with some props', () => (<MyComponent text="The Comp"/>));
```

You can also add this decorator globally like this:
Or you can also add this decorator globally:

```js
import { configure, addDecorator } from '@kadira/storybook';
Expand All @@ -34,3 +35,35 @@ configure(function () {
...
}, module);
```

#### As an extension
1 - Configure the extension

```js
import React from 'react';
import { configure, setAddon } from '@kadira/storybook';
import centered from '@kadira/react-storybook-decorator-centered';

setAddon({
addCentered(storyName, storyFn) {
this.add(storyName, (context) => (
centered.call(context, storyFn)
));
}
});

configure(function () {
...
}, module);
```

2 - Use it in your story

```js
import React from 'react';
import { storiesOf } from '@kadira/storybook';
import MyComponent from '../my_component';

storiesOf('MyComponent', module)
.addCentered('without props', () => (<MyComponent />))
```

0 comments on commit c9fae57

Please sign in to comment.