mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-02 05:03:44 +08:00
CLI templates: Angular => module format
This commit is contained in:
parent
f44959a445
commit
f0e3a16778
@ -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);
|
||||
|
@ -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',
|
||||
};
|
@ -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',
|
||||
};
|
@ -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'),
|
||||
},
|
||||
}));
|
Loading…
x
Reference in New Issue
Block a user