Skip to content

Commit 5c966ed

Browse files
committed
build(storybook): set up docs addon
It generates a nice "Docs" tab with a list of all the element's attributes & properties, as well as code usage examples.
1 parent d010926 commit 5c966ed

16 files changed

+3672
-281
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ dist
55
build
66
*.log
77
storybook-static
8+
custom-elements.json

.storybook/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
addons: ['@storybook/addon-docs'],
3+
};

.storybook/config.js renamed to .storybook/preview.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { configure } from '@storybook/web-components';
2+
import { setCustomElements } from '@storybook/web-components';
3+
import customElements from '../custom-elements.json';
24

35
// automatically import all files ending in *.stories.ts
46
const req = require.context('../src', true, /\.stories\.ts$/);
@@ -10,3 +12,6 @@ if (module.hot) {
1012
window.location.reload();
1113
});
1214
}
15+
16+
// Configure Storybook Docs Addon for Web Components
17+
setCustomElements(customElements);

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ can interact with the elements and see your changes live, similar to
3030
The easiest way to create a new element is to run the generator:
3131

3232
```
33-
npm run new-element --name my-element
33+
npm run new-element --name demo
3434
```
3535

36-
This will generate a new element called `my-element`. It will also
36+
This will generate a new element called `demo`. It will also
3737
create a storybook file, so you will be able to see the new element
3838
in storybook (see the "Local development" section above).
3939

_templates/element/new/element.stories.ts.t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { html } from 'lit-html';
77
import './<%= name %>-element';
88

99
storiesOf('<%= h.changeCase.title(h.className(name)) %>', module)
10+
.addParameters({ component: 'wokwi-<%= name %>' })
1011
.addDecorator(withKnobs)
1112
.add(
1213
'Default',

0 commit comments

Comments
 (0)