diff --git a/lib/cli/generators/ANGULAR/template/.storybook/config.js b/lib/cli/generators/ANGULAR/template/.storybook/config.js index 3ec2718b7843..7df645552aa3 100644 --- a/lib/cli/generators/ANGULAR/template/.storybook/config.js +++ b/lib/cli/generators/ANGULAR/template/.storybook/config.js @@ -2,8 +2,10 @@ import { configure } from '@storybook/angular'; +// automatically import all files ending in *.stories.js +const req = require.context('../stories', true, /.stories.js$/); function loadStories() { - require('../stories'); + req.keys().forEach((filename) => req(filename)); } configure(loadStories, module); diff --git a/lib/cli/generators/ANGULAR/template/stories/index.stories.js b/lib/cli/generators/ANGULAR/template/stories/index.stories.js new file mode 100644 index 000000000000..e61f2d785e51 --- /dev/null +++ b/lib/cli/generators/ANGULAR/template/stories/index.stories.js @@ -0,0 +1,46 @@ +import { storiesOf } from '@storybook/angular'; +import { withNotes } from '@storybook/addon-notes'; +import { action } from '@storybook/addon-actions'; +import { linkTo } from '@storybook/addon-links'; + +import { Welcome, Button } from '@storybook/angular/demo'; + +storiesOf('Welcome', module).add('to Storybook', () => ({ + component: Welcome, + props: {}, +})); + +storiesOf('Button', module) + .add('with text', () => ({ + component: Button, + props: { + text: 'Hello Button', + }, + })) + .add( + 'with some emoji', + withNotes({ notes: 'My notes on a button with emojis' })(() => ({ + component: Button, + props: { + text: '😀 😎 👍 💯', + }, + })) + ) + .add( + 'with some emoji and action', + withNotes({ notes: 'My notes on a button with emojis' })(() => ({ + component: Button, + props: { + text: '😀 😎 👍 💯', + onClick: action('This was clicked OMG'), + }, + })) + ); + +storiesOf('Another Button', module).add('button with link to another story', () => ({ + component: Button, + props: { + text: 'Go to Welcome Story', + onClick: linkTo('Welcome'), + }, +})); diff --git a/lib/cli/generators/ANGULAR/template/stories/index.ts b/lib/cli/generators/ANGULAR/template/stories/index.ts deleted file mode 100644 index def9b9acb7a8..000000000000 --- a/lib/cli/generators/ANGULAR/template/stories/index.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { storiesOf } from '@storybook/angular'; -import { withNotes } from '@storybook/addon-notes'; -import { action } from '@storybook/addon-actions' -import { linkTo } from '@storybook/addon-links' - -import { Welcome, Button } from '@storybook/angular/demo'; - -declare let module; - -storiesOf('Welcome', module) - .add('to Storybook', () => ({ - component: Welcome, - props: {} - })) - -storiesOf('Button', module) - .add('with text', () => ({ - component: Button, - props: { - text: 'Hello Button' - } - })) - .add('with some emoji', withNotes({ notes: 'My notes on a button with emojis' })(() => ({ - component: Button, - props: { - text: '😀 😎 👍 💯' - } - }))) - .add('with some emoji and action', withNotes({ notes: 'My notes on a button with emojis' })(() => ({ - component: Button, - props: { - text: '😀 😎 👍 💯', - onClick: action('This was clicked OMG') - } - }))) - -storiesOf('Another Button', module) - .add('button with link to another story', () => ({ - component: Button, - props: { - text: 'Go to Welcome Story', - onClick: linkTo('Welcome') - } - })) diff --git a/lib/cli/generators/METEOR/template/.stories/index.js b/lib/cli/generators/METEOR/template/.stories/index.js deleted file mode 100644 index 4afc99366db0..000000000000 --- a/lib/cli/generators/METEOR/template/.stories/index.js +++ /dev/null @@ -1,20 +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', () => ( - - )); diff --git a/lib/cli/generators/METEOR/template/.storybook/config.js b/lib/cli/generators/METEOR/template/.storybook/config.js index 140143dad399..694160f50fe1 100644 --- a/lib/cli/generators/METEOR/template/.storybook/config.js +++ b/lib/cli/generators/METEOR/template/.storybook/config.js @@ -1,7 +1,9 @@ import { configure } from '@storybook/react'; +// automatically import all files ending in *.stories.js +const req = require.context('../stories', true, /.stories.js$/); function loadStories() { - require('../.stories'); + req.keys().forEach((filename) => req(filename)); } configure(loadStories, module); diff --git a/lib/cli/generators/REACT/template/stories/index.js b/lib/cli/generators/METEOR/template/stories/index.stories.js similarity index 100% rename from lib/cli/generators/REACT/template/stories/index.js rename to lib/cli/generators/METEOR/template/stories/index.stories.js diff --git a/lib/cli/generators/REACT/template/.storybook/config.js b/lib/cli/generators/REACT/template/.storybook/config.js index 9154670ab327..694160f50fe1 100644 --- a/lib/cli/generators/REACT/template/.storybook/config.js +++ b/lib/cli/generators/REACT/template/.storybook/config.js @@ -1,7 +1,9 @@ import { configure } from '@storybook/react'; +// automatically import all files ending in *.stories.js +const req = require.context('../stories', true, /.stories.js$/); function loadStories() { - require('../stories'); + req.keys().forEach((filename) => req(filename)); } configure(loadStories, module); diff --git a/lib/cli/generators/WEBPACK_REACT/template/stories/index.js b/lib/cli/generators/REACT/template/stories/index.stories.js similarity index 100% rename from lib/cli/generators/WEBPACK_REACT/template/stories/index.js rename to lib/cli/generators/REACT/template/stories/index.stories.js diff --git a/lib/cli/generators/SFC_VUE/template/.storybook/config.js b/lib/cli/generators/SFC_VUE/template/.storybook/config.js index aabcced40e3f..d5aba0f1fa3b 100644 --- a/lib/cli/generators/SFC_VUE/template/.storybook/config.js +++ b/lib/cli/generators/SFC_VUE/template/.storybook/config.js @@ -1,7 +1,9 @@ import { configure } from '@storybook/vue' +// automatically import all files ending in *.stories.js +const req = require.context('../stories', true, /.stories.js$/); function loadStories() { - require('../src/stories') + req.keys().forEach((filename) => req(filename)); } configure(loadStories, module) diff --git a/lib/cli/generators/SFC_VUE/template/src/stories/index.js b/lib/cli/generators/SFC_VUE/template/src/stories/index.stories.js similarity index 100% rename from lib/cli/generators/SFC_VUE/template/src/stories/index.js rename to lib/cli/generators/SFC_VUE/template/src/stories/index.stories.js diff --git a/lib/cli/generators/VUE/template/.storybook/config.js b/lib/cli/generators/VUE/template/.storybook/config.js index a26a91bc2afb..d5aba0f1fa3b 100644 --- a/lib/cli/generators/VUE/template/.storybook/config.js +++ b/lib/cli/generators/VUE/template/.storybook/config.js @@ -1,7 +1,9 @@ import { configure } from '@storybook/vue' +// automatically import all files ending in *.stories.js +const req = require.context('../stories', true, /.stories.js$/); function loadStories() { - require('../stories') + req.keys().forEach((filename) => req(filename)); } configure(loadStories, module) diff --git a/lib/cli/generators/VUE/template/stories/index.js b/lib/cli/generators/VUE/template/stories/index.stories.js similarity index 100% rename from lib/cli/generators/VUE/template/stories/index.js rename to lib/cli/generators/VUE/template/stories/index.stories.js diff --git a/lib/cli/generators/WEBPACK_REACT/template/.storybook/config.js b/lib/cli/generators/WEBPACK_REACT/template/.storybook/config.js index 9154670ab327..694160f50fe1 100644 --- a/lib/cli/generators/WEBPACK_REACT/template/.storybook/config.js +++ b/lib/cli/generators/WEBPACK_REACT/template/.storybook/config.js @@ -1,7 +1,9 @@ import { configure } from '@storybook/react'; +// automatically import all files ending in *.stories.js +const req = require.context('../stories', true, /.stories.js$/); function loadStories() { - require('../stories'); + req.keys().forEach((filename) => req(filename)); } configure(loadStories, module); diff --git a/lib/cli/test/snapshots/react/stories/index.js b/lib/cli/generators/WEBPACK_REACT/template/stories/index.stories.js similarity index 100% rename from lib/cli/test/snapshots/react/stories/index.js rename to lib/cli/generators/WEBPACK_REACT/template/stories/index.stories.js diff --git a/lib/cli/test/snapshots/angular-cli/.storybook/config.js b/lib/cli/test/snapshots/angular-cli/.storybook/config.js index 3ec2718b7843..7df645552aa3 100644 --- a/lib/cli/test/snapshots/angular-cli/.storybook/config.js +++ b/lib/cli/test/snapshots/angular-cli/.storybook/config.js @@ -2,8 +2,10 @@ import { configure } from '@storybook/angular'; +// automatically import all files ending in *.stories.js +const req = require.context('../stories', true, /.stories.js$/); function loadStories() { - require('../stories'); + req.keys().forEach((filename) => req(filename)); } configure(loadStories, module); diff --git a/lib/cli/test/snapshots/angular-cli/stories/index.stories.js b/lib/cli/test/snapshots/angular-cli/stories/index.stories.js new file mode 100644 index 000000000000..e61f2d785e51 --- /dev/null +++ b/lib/cli/test/snapshots/angular-cli/stories/index.stories.js @@ -0,0 +1,46 @@ +import { storiesOf } from '@storybook/angular'; +import { withNotes } from '@storybook/addon-notes'; +import { action } from '@storybook/addon-actions'; +import { linkTo } from '@storybook/addon-links'; + +import { Welcome, Button } from '@storybook/angular/demo'; + +storiesOf('Welcome', module).add('to Storybook', () => ({ + component: Welcome, + props: {}, +})); + +storiesOf('Button', module) + .add('with text', () => ({ + component: Button, + props: { + text: 'Hello Button', + }, + })) + .add( + 'with some emoji', + withNotes({ notes: 'My notes on a button with emojis' })(() => ({ + component: Button, + props: { + text: '😀 😎 👍 💯', + }, + })) + ) + .add( + 'with some emoji and action', + withNotes({ notes: 'My notes on a button with emojis' })(() => ({ + component: Button, + props: { + text: '😀 😎 👍 💯', + onClick: action('This was clicked OMG'), + }, + })) + ); + +storiesOf('Another Button', module).add('button with link to another story', () => ({ + component: Button, + props: { + text: 'Go to Welcome Story', + onClick: linkTo('Welcome'), + }, +})); diff --git a/lib/cli/test/snapshots/angular-cli/stories/index.ts b/lib/cli/test/snapshots/angular-cli/stories/index.ts deleted file mode 100644 index def9b9acb7a8..000000000000 --- a/lib/cli/test/snapshots/angular-cli/stories/index.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { storiesOf } from '@storybook/angular'; -import { withNotes } from '@storybook/addon-notes'; -import { action } from '@storybook/addon-actions' -import { linkTo } from '@storybook/addon-links' - -import { Welcome, Button } from '@storybook/angular/demo'; - -declare let module; - -storiesOf('Welcome', module) - .add('to Storybook', () => ({ - component: Welcome, - props: {} - })) - -storiesOf('Button', module) - .add('with text', () => ({ - component: Button, - props: { - text: 'Hello Button' - } - })) - .add('with some emoji', withNotes({ notes: 'My notes on a button with emojis' })(() => ({ - component: Button, - props: { - text: '😀 😎 👍 💯' - } - }))) - .add('with some emoji and action', withNotes({ notes: 'My notes on a button with emojis' })(() => ({ - component: Button, - props: { - text: '😀 😎 👍 💯', - onClick: action('This was clicked OMG') - } - }))) - -storiesOf('Another Button', module) - .add('button with link to another story', () => ({ - component: Button, - props: { - text: 'Go to Welcome Story', - onClick: linkTo('Welcome') - } - })) diff --git a/lib/cli/test/snapshots/meteor/.stories/index.js b/lib/cli/test/snapshots/meteor/.stories/index.js deleted file mode 100644 index 4afc99366db0..000000000000 --- a/lib/cli/test/snapshots/meteor/.stories/index.js +++ /dev/null @@ -1,20 +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', () => ( - - )); diff --git a/lib/cli/test/snapshots/meteor/.storybook/config.js b/lib/cli/test/snapshots/meteor/.storybook/config.js index 140143dad399..694160f50fe1 100644 --- a/lib/cli/test/snapshots/meteor/.storybook/config.js +++ b/lib/cli/test/snapshots/meteor/.storybook/config.js @@ -1,7 +1,9 @@ import { configure } from '@storybook/react'; +// automatically import all files ending in *.stories.js +const req = require.context('../stories', true, /.stories.js$/); function loadStories() { - require('../.stories'); + req.keys().forEach((filename) => req(filename)); } configure(loadStories, module); diff --git a/lib/cli/test/snapshots/react_project/stories/index.js b/lib/cli/test/snapshots/meteor/stories/index.stories.js similarity index 100% rename from lib/cli/test/snapshots/react_project/stories/index.js rename to lib/cli/test/snapshots/meteor/stories/index.stories.js diff --git a/lib/cli/test/snapshots/react/.storybook/config.js b/lib/cli/test/snapshots/react/.storybook/config.js index 9154670ab327..694160f50fe1 100644 --- a/lib/cli/test/snapshots/react/.storybook/config.js +++ b/lib/cli/test/snapshots/react/.storybook/config.js @@ -1,7 +1,9 @@ import { configure } from '@storybook/react'; +// automatically import all files ending in *.stories.js +const req = require.context('../stories', true, /.stories.js$/); function loadStories() { - require('../stories'); + req.keys().forEach((filename) => req(filename)); } configure(loadStories, module); diff --git a/lib/cli/test/snapshots/webpack_react/stories/index.js b/lib/cli/test/snapshots/react/stories/index.stories.js similarity index 100% rename from lib/cli/test/snapshots/webpack_react/stories/index.js rename to lib/cli/test/snapshots/react/stories/index.stories.js diff --git a/lib/cli/test/snapshots/react_project/.storybook/config.js b/lib/cli/test/snapshots/react_project/.storybook/config.js index 9154670ab327..694160f50fe1 100644 --- a/lib/cli/test/snapshots/react_project/.storybook/config.js +++ b/lib/cli/test/snapshots/react_project/.storybook/config.js @@ -1,7 +1,9 @@ import { configure } from '@storybook/react'; +// automatically import all files ending in *.stories.js +const req = require.context('../stories', true, /.stories.js$/); function loadStories() { - require('../stories'); + req.keys().forEach((filename) => req(filename)); } configure(loadStories, module); diff --git a/lib/cli/test/snapshots/react_project/stories/index.stories.js b/lib/cli/test/snapshots/react_project/stories/index.stories.js new file mode 100644 index 000000000000..9214f65c7bb5 --- /dev/null +++ b/lib/cli/test/snapshots/react_project/stories/index.stories.js @@ -0,0 +1,13 @@ +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', () => ); diff --git a/lib/cli/test/snapshots/sfc_vue/.storybook/config.js b/lib/cli/test/snapshots/sfc_vue/.storybook/config.js index aabcced40e3f..d5aba0f1fa3b 100644 --- a/lib/cli/test/snapshots/sfc_vue/.storybook/config.js +++ b/lib/cli/test/snapshots/sfc_vue/.storybook/config.js @@ -1,7 +1,9 @@ import { configure } from '@storybook/vue' +// automatically import all files ending in *.stories.js +const req = require.context('../stories', true, /.stories.js$/); function loadStories() { - require('../src/stories') + req.keys().forEach((filename) => req(filename)); } configure(loadStories, module) diff --git a/lib/cli/test/snapshots/sfc_vue/src/stories/index.js b/lib/cli/test/snapshots/sfc_vue/src/stories/index.stories.js similarity index 100% rename from lib/cli/test/snapshots/sfc_vue/src/stories/index.js rename to lib/cli/test/snapshots/sfc_vue/src/stories/index.stories.js diff --git a/lib/cli/test/snapshots/vue/.storybook/config.js b/lib/cli/test/snapshots/vue/.storybook/config.js index a26a91bc2afb..d5aba0f1fa3b 100644 --- a/lib/cli/test/snapshots/vue/.storybook/config.js +++ b/lib/cli/test/snapshots/vue/.storybook/config.js @@ -1,7 +1,9 @@ import { configure } from '@storybook/vue' +// automatically import all files ending in *.stories.js +const req = require.context('../stories', true, /.stories.js$/); function loadStories() { - require('../stories') + req.keys().forEach((filename) => req(filename)); } configure(loadStories, module) diff --git a/lib/cli/test/snapshots/vue/stories/index.js b/lib/cli/test/snapshots/vue/stories/index.stories.js similarity index 100% rename from lib/cli/test/snapshots/vue/stories/index.js rename to lib/cli/test/snapshots/vue/stories/index.stories.js diff --git a/lib/cli/test/snapshots/webpack_react/.storybook/config.js b/lib/cli/test/snapshots/webpack_react/.storybook/config.js index 9154670ab327..694160f50fe1 100644 --- a/lib/cli/test/snapshots/webpack_react/.storybook/config.js +++ b/lib/cli/test/snapshots/webpack_react/.storybook/config.js @@ -1,7 +1,9 @@ import { configure } from '@storybook/react'; +// automatically import all files ending in *.stories.js +const req = require.context('../stories', true, /.stories.js$/); function loadStories() { - require('../stories'); + req.keys().forEach((filename) => req(filename)); } configure(loadStories, module); diff --git a/lib/cli/test/snapshots/webpack_react/stories/index.stories.js b/lib/cli/test/snapshots/webpack_react/stories/index.stories.js new file mode 100644 index 000000000000..9214f65c7bb5 --- /dev/null +++ b/lib/cli/test/snapshots/webpack_react/stories/index.stories.js @@ -0,0 +1,13 @@ +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', () => );