Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1013 autoload all *.stories.js files in cli templates #2195

Merged
merged 5 commits into from
Oct 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/cli/generators/ANGULAR/template/.storybook/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
46 changes: 46 additions & 0 deletions lib/cli/generators/ANGULAR/template/stories/index.stories.js
Original file line number Diff line number Diff line change
@@ -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'),
},
}));
44 changes: 0 additions & 44 deletions lib/cli/generators/ANGULAR/template/stories/index.ts

This file was deleted.

20 changes: 0 additions & 20 deletions lib/cli/generators/METEOR/template/.stories/index.js

This file was deleted.

4 changes: 3 additions & 1 deletion lib/cli/generators/METEOR/template/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -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);
4 changes: 3 additions & 1 deletion lib/cli/generators/REACT/template/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -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);
4 changes: 3 additions & 1 deletion lib/cli/generators/SFC_VUE/template/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 3 additions & 1 deletion lib/cli/generators/VUE/template/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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);
4 changes: 3 additions & 1 deletion lib/cli/test/snapshots/angular-cli/.storybook/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
46 changes: 46 additions & 0 deletions lib/cli/test/snapshots/angular-cli/stories/index.stories.js
Original file line number Diff line number Diff line change
@@ -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'),
},
}));
44 changes: 0 additions & 44 deletions lib/cli/test/snapshots/angular-cli/stories/index.ts

This file was deleted.

20 changes: 0 additions & 20 deletions lib/cli/test/snapshots/meteor/.stories/index.js

This file was deleted.

4 changes: 3 additions & 1 deletion lib/cli/test/snapshots/meteor/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -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);
4 changes: 3 additions & 1 deletion lib/cli/test/snapshots/react/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -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);
4 changes: 3 additions & 1 deletion lib/cli/test/snapshots/react_project/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -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);
13 changes: 13 additions & 0 deletions lib/cli/test/snapshots/react_project/stories/index.stories.js
Original file line number Diff line number Diff line change
@@ -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', () => <Welcome showApp={linkTo('Button')} />);

storiesOf('Button', module)
.add('with text', () => <Button onClick={action('clicked')}>Hello Button</Button>)
.add('with some emoji', () => <Button onClick={action('clicked')}>😀 😎 👍 💯</Button>);
4 changes: 3 additions & 1 deletion lib/cli/test/snapshots/sfc_vue/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 3 additions & 1 deletion lib/cli/test/snapshots/vue/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 3 additions & 1 deletion lib/cli/test/snapshots/webpack_react/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -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);
13 changes: 13 additions & 0 deletions lib/cli/test/snapshots/webpack_react/stories/index.stories.js
Original file line number Diff line number Diff line change
@@ -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', () => <Welcome showApp={linkTo('Button')} />);

storiesOf('Button', module)
.add('with text', () => <Button onClick={action('clicked')}>Hello Button</Button>)
.add('with some emoji', () => <Button onClick={action('clicked')}>😀 😎 👍 💯</Button>);