1 | # Storybook Addon Notes
|
2 |
|
3 | Storybook Addon Notes allows you to write notes (text or HTML) for your stories in [Storybook](https://storybook.js.org).
|
4 |
|
5 | [Framework Support](https://github.com/storybookjs/storybook/blob/master/ADDONS_SUPPORT.md)
|
6 |
|
7 | 
|
8 |
|
9 | ## Getting Started
|
10 |
|
11 | **NOTE: Documentation on `next` branch is for alpha version, stable release is on [master](https://github.com/storybookjs/storybook/tree/master/addons/)**
|
12 |
|
13 | ```sh
|
14 | yarn add -D @storybook/addon-notes
|
15 | ```
|
16 |
|
17 | within `.storybook/main.js`:
|
18 |
|
19 | ```js
|
20 | module.exports = {
|
21 | addons: ['@storybook/addon-notes/register']
|
22 | }
|
23 | ```
|
24 |
|
25 | Alternatively register the notes addon into a panel. Choose only one, not both.
|
26 |
|
27 | ```js
|
28 | module.exports = {
|
29 | addons: ['@storybook/addon-notes/register-panel']
|
30 | }
|
31 | ```
|
32 |
|
33 | Now, you can use the `notes` parameter to add a note to each story.
|
34 |
|
35 |
|
36 | ```js
|
37 | import Component from './Component';
|
38 |
|
39 | export default {
|
40 | title: 'Component',
|
41 | parameters: {
|
42 | notes: 'some documentation here',
|
43 | },
|
44 | };
|
45 | ```
|
46 |
|
47 | ### Upgrading to CSF Format
|
48 |
|
49 | Add `notes` to the `parameters` object:
|
50 |
|
51 | ```js
|
52 | export default {
|
53 | parameters: {
|
54 | notes: 'My notes',
|
55 | }
|
56 | }
|
57 | ```
|
58 |
|
59 | ## Using Markdown
|
60 |
|
61 | Using Markdown in your notes is supported, Storybook will load Markdown as raw by default.
|
62 |
|
63 | ```js
|
64 | import Component from './Component';
|
65 | import markdown from './someMarkdownText.md';
|
66 |
|
67 | export default {
|
68 | title: 'Component',
|
69 | };
|
70 |
|
71 | export const withMarkdown = () => <Component />;
|
72 | withmarkdown.story = {
|
73 | parameters: {
|
74 | notes: { markdown },
|
75 | }
|
76 | };
|
77 | ```
|
78 |
|
79 | ## Giphy
|
80 |
|
81 | When using Markdown, you can also embed gifs from Giphy into your Markdown. Currently, the value `cheese` of the query prop is used to search and return the first result returned by Giphy.
|
82 |
|
83 | ```md
|
84 | # Title
|
85 |
|
86 | <Giphy query='cheese' />
|
87 | ```
|
88 |
|
89 | ## Multiple Notes Sections
|
90 |
|
91 | If you need to display different notes for different consumers of your storybook (e.g design, developers), you can configure multiple notes pages. The following will render a tab with unique notes for both `Introduction` and `Design`.
|
92 |
|
93 | ```js
|
94 | import { storiesOf } from '@storybook/react';
|
95 | import Component from './Component';
|
96 |
|
97 | import intro from './intro.md';
|
98 | import design from './design.md';
|
99 |
|
100 | export default {
|
101 | title: 'Component',
|
102 | parameters: {
|
103 | notes: { Introduction: intro, 'Design Notes': design },
|
104 | },
|
105 | };
|
106 | ```
|