Skip to content

Commit

Permalink
Merge pull request #1546 from storybooks/Docs-hierarchy
Browse files Browse the repository at this point in the history
Update 'Substories/Hierarchy' section in docs
  • Loading branch information
shilman committed Jul 30, 2017
2 parents b2ee1c1 + bf52eb1 commit 7ecadce
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions docs/pages/basics/writing-stories/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,34 +105,29 @@ configure(function () {
}, module);
```

## Managing stories
## Nesting stories

Storybook has a very simple API to write stories.
With that, you can’t display nested stories.

But you might ask, how do I manage stories If I have many of them?
We're currently very much interested in changing our api to support this!

Until that's implemented, here's how different developers address this issue, right now:

### Prefix with dots

For example, you can prefix story names with a dot (`.`):
You can organize your stories in a nesting structures using "/" as a separator:

```js
import { storiesOf } from '@storybook/react';

storiesOf('core.Button', module);
```
// file: src/stories/index.js

Then you can filter stories to display only the stories you want to see.
import React from 'react';
import { storiesOf } from '@storybook/react';
import Button from '../components/Button';

### [Chapters](https://github.com/yangshun/react-storybook-addon-chapters)
storiesOf('My App/Buttons/Simple', module)
.add('with text', () => (
<Button onClick={action('clicked')}>Hello Button</Button>
));

With this addon, you can showcase multiple components (or varying component states) within 1 story.
Break your stories down into smaller categories (chapters) and subcategories (sections) for more organizational goodness.
storiesOf('My App/Buttons/Emoji', module)
.add('with some emoji', () => (
<Button onClick={action('clicked')}>😀 😎 👍 💯</Button>
));
```

### Run multiple storybooks
## Run multiple storybooks

You can run multiple storybooks for different kinds of stories (or components). To do that, you can create different NPM scripts to start different stories. See:

Expand Down

0 comments on commit 7ecadce

Please sign in to comment.