CLI templates: Angular => module format

This commit is contained in:
Michael Shilman 2019-07-20 16:59:03 +08:00
parent f44959a445
commit f0e3a16778
4 changed files with 67 additions and 54 deletions

View File

@ -1,9 +1,4 @@
import { configure } from '@storybook/angular';
import { load } from '@storybook/angular';
// automatically import all files ending in *.stories.ts
const req = require.context('../src/stories', true, /\.stories\.ts$/);
function loadStories() {
req.keys().forEach(filename => req(filename));
}
configure(loadStories, module);
load(require.context('../src/stories', true, /\.stories\.ts$/), module);

View File

@ -0,0 +1,51 @@
import { action } from '@storybook/addon-actions';
import { linkTo } from '@storybook/addon-links';
import { Button } from '@storybook/angular/demo';
export default {
title: 'Button',
};
export const text = () => ({
component: Button,
props: {
text: 'Hello Button',
},
});
export const emoji = () => ({
component: Button,
props: {
text: '😀 😎 👍 💯',
},
});
emoji.story = {
parameters: { notes: 'My notes on a button with emojis' },
};
export const withSomeEmojiAndAction = () => ({
component: Button,
props: {
text: '😀 😎 👍 💯',
onClick: action('This was clicked OMG'),
},
});
withSomeEmojiAndAction.story = {
name: 'with some emoji and action',
parameters: { notes: 'My notes on a button with emojis' },
};
export const buttonWithLinkToAnotherStory = () => ({
component: Button,
props: {
text: 'Go to Welcome Story',
onClick: linkTo('Welcome'),
},
});
buttonWithLinkToAnotherStory.story = {
name: 'button with link to another story',
};

View File

@ -0,0 +1,14 @@
import { Welcome } from '@storybook/angular/demo';
export default {
title: 'Welcome',
};
export const toStorybook = () => ({
component: Welcome,
props: {},
});
toStorybook.story = {
name: 'to Storybook',
};

View File

@ -1,47 +0,0 @@
import { storiesOf } from '@storybook/angular';
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',
() => ({
component: Button,
props: {
text: '😀 😎 👍 💯',
},
}),
{ notes: 'My notes on a button with emojis' }
)
.add(
'with some emoji and action',
() => ({
component: Button,
props: {
text: '😀 😎 👍 💯',
onClick: action('This was clicked OMG'),
},
}),
{ notes: 'My notes on a button with emojis' }
);
storiesOf('Another Button', module).add('button with link to another story', () => ({
component: Button,
props: {
text: 'Go to Welcome Story',
onClick: linkTo('Welcome'),
},
}));