Skip to content

Commit 047b2f4

Browse files
committed
Add storybook integration to demo components
1 parent 3a59ec4 commit 047b2f4

File tree

13 files changed

+1594
-2
lines changed

13 files changed

+1594
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@ testResults/junit.xml
3636
package-lock.json
3737

3838
*-css.ts
39+
40+
# storybook
41+
storybook-static/

.storybook/main.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
presets: ['@storybook/addon-docs/preset'],
3+
stories: ['../stories/**/*.stories.(js|mdx)'],
4+
addons: [
5+
'@storybook/addon-a11y/register',
6+
'@storybook/addon-actions/register',
7+
'@storybook/addon-knobs/register',
8+
'@storybook/addon-links/register',
9+
'@storybook/addon-storysource/register'
10+
]
11+
};

.storybook/manager.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import addonAPI from '@storybook/addons';
2+
import { STORIES_CONFIGURED, STORY_MISSING } from '@storybook/core-events';
3+
4+
addonAPI.register('microsoft/graph-toolkit', storybookAPI => {
5+
storybookAPI.on(STORIES_CONFIGURED, (kind, story) => {
6+
if (storybookAPI.getUrlState().path === '/story/*') {
7+
storybookAPI.selectStory('mgt-login', 'login');
8+
}
9+
});
10+
storybookAPI.on(STORY_MISSING, (kind, story) => {
11+
storybookAPI.selectStory('mgt-login', 'login');
12+
});
13+
});

.storybook/preview.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* global window */
2+
3+
import { configure, addParameters, setCustomElements } from '@storybook/web-components';
4+
import customElements from '../custom-elements.json';
5+
6+
setCustomElements(customElements);
7+
8+
addParameters({
9+
docs: {
10+
iframeHeight: '200px'
11+
}
12+
});
13+
14+
// force full reload to not reregister web components
15+
const req = require.context('../stories', true, /\.stories\.(js|mdx)$/);
16+
configure(req, module);
17+
if (module.hot) {
18+
module.hot.accept(req.id, () => {
19+
const currentLocationHref = window.location.href;
20+
window.history.pushState(null, null, currentLocationHref);
21+
window.location.reload();
22+
});
23+
}

0 commit comments

Comments
 (0)