diff --git a/lib/cli/generators/WEBPACK_REACT/template/.storybook/config.js b/lib/cli/generators/WEBPACK_REACT/template/.storybook/config.js index 639b168f733..924c2f16cf7 100644 --- a/lib/cli/generators/WEBPACK_REACT/template/.storybook/config.js +++ b/lib/cli/generators/WEBPACK_REACT/template/.storybook/config.js @@ -1,9 +1,4 @@ -import { configure } from '@storybook/react'; +import { load } from '@storybook/react'; // automatically import all files ending in *.stories.js -const req = require.context('../stories', true, /\.stories\.js$/); -function loadStories() { - req.keys().forEach(filename => req(filename)); -} - -configure(loadStories, module); +load(require.context('../stories', true, /\.stories\.js$/), module); diff --git a/lib/cli/generators/WEBPACK_REACT/template/stories/Button.stories.js b/lib/cli/generators/WEBPACK_REACT/template/stories/Button.stories.js new file mode 100644 index 00000000000..ebee8e0c1c9 --- /dev/null +++ b/lib/cli/generators/WEBPACK_REACT/template/stories/Button.stories.js @@ -0,0 +1,22 @@ +import React from 'react'; + +import { action } from '@storybook/addon-actions'; +import { Button } from '@storybook/react/demo'; + +export default { + title: 'Button', +}; + +export const text = () => ; + +export const emoji = () => ( + +); + +emoji.story = { + name: 'with emoji', +}; diff --git a/lib/cli/generators/WEBPACK_REACT/template/stories/Welcome.stories.js b/lib/cli/generators/WEBPACK_REACT/template/stories/Welcome.stories.js new file mode 100644 index 00000000000..fe4de2145a6 --- /dev/null +++ b/lib/cli/generators/WEBPACK_REACT/template/stories/Welcome.stories.js @@ -0,0 +1,13 @@ +import React from 'react'; +import { linkTo } from '@storybook/addon-links'; +import { Welcome } from '@storybook/react/demo'; + +export default { + title: 'Welcome', +}; + +export const toStorybook = () => ; + +toStorybook.story = { + name: 'to Storybook', +}; diff --git a/lib/cli/generators/WEBPACK_REACT/template/stories/index.stories.js b/lib/cli/generators/WEBPACK_REACT/template/stories/index.stories.js deleted file mode 100644 index aa04241802d..00000000000 --- a/lib/cli/generators/WEBPACK_REACT/template/stories/index.stories.js +++ /dev/null @@ -1,19 +0,0 @@ -import React from 'react'; - -import { storiesOf } from '@storybook/react'; -import { action } from '@storybook/addon-actions'; -import { linkTo } from '@storybook/addon-links'; - -import { Button, Welcome } from '@storybook/react/demo'; - -storiesOf('Welcome', module).add('to Storybook', () => ); - -storiesOf('Button', module) - .add('with text', () => ) - .add('with some emoji', () => ( - - ));