Skip to content

Commit 9a564a1

Browse files
committed
Added storybook
1 parent 4ba93cb commit 9a564a1

File tree

5 files changed

+2830
-68
lines changed

5 files changed

+2830
-68
lines changed

.storybook/config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { configure } from '@storybook/react';
2+
3+
// automatically import all files ending in *.stories.js
4+
const req = require.context('../stories', true, /.stories.js$/);
5+
function loadStories() {
6+
req.keys().forEach((filename) => req(filename));
7+
}
8+
9+
configure(loadStories, module);

.storybook/webpack.config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// you can use this file to add your custom webpack plugins, loaders and anything you like.
2+
// This is just the basic way to add additional webpack configurations.
3+
// For more information refer the docs: https://storybook.js.org/configurations/custom-webpack-config
4+
5+
// IMPORTANT
6+
// When you add this file, we won't add the default configurations which is similar
7+
// to "React Create App". This only has babel loader to load JavaScript.
8+
9+
module.exports = {
10+
plugins: [
11+
// your custom plugins
12+
],
13+
module: {
14+
rules: [
15+
// add your custom rules.
16+
],
17+
},
18+
};

package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
"babel-preset-react": "^6.24.1",
1818
"webpack": "^4.5.0",
1919
"webpack-dev-server": "^3.1.3",
20-
"why-did-you-update": "^0.1.1"
20+
"why-did-you-update": "^0.1.1",
21+
"@storybook/react": "^3.4.1",
22+
"@storybook/addon-actions": "^3.4.1",
23+
"@storybook/addon-links": "^3.4.1",
24+
"@storybook/addons": "^3.4.1"
25+
},
26+
"scripts": {
27+
"storybook": "start-storybook -p 6006",
28+
"build-storybook": "build-storybook"
2129
}
2230
}

stories/index.stories.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react';
2+
3+
import { storiesOf } from '@storybook/react';
4+
import { action } from '@storybook/addon-actions';
5+
import { linkTo } from '@storybook/addon-links';
6+
7+
import { Button, Welcome } from '@storybook/react/demo';
8+
9+
storiesOf('Welcome', module).add('to Storybook', () => <Welcome showApp={linkTo('Button')} />);
10+
11+
storiesOf('Button', module)
12+
.add('with text', () => <Button onClick={action('clicked')}>Hello Button</Button>)
13+
.add('with some emoji', () => <Button onClick={action('clicked')}>😀 😎 👍 💯</Button>);

0 commit comments

Comments
 (0)