CLI templates: preact => module format

This commit is contained in:
Michael Shilman 2019-07-20 16:46:24 +08:00
parent eb28c95977
commit efda1d5ccc
4 changed files with 36 additions and 28 deletions

View File

@ -1,9 +1,4 @@
import { configure } from '@storybook/preact';
import { load } from '@storybook/preact';
// 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);

View File

@ -0,0 +1,19 @@
/** @jsx h */
import { h } from 'preact';
import { action } from '@storybook/addon-actions';
import Button from './Button';
export default {
title: 'Button',
};
export const text = () => <Button onClick={action('clicked')}>Hello Button</Button>;
export const emoji = () => (
<Button onClick={action('clicked')}>
<span role="img" aria-label="so cool">
😀 😎 👍 💯
</span>
</Button>
);

View File

@ -0,0 +1,15 @@
/** @jsx h */
import { h } from 'preact';
import { linkTo } from '@storybook/addon-links';
import Welcome from './Welcome';
export default {
title: 'Welcome',
};
export const toStorybook = () => <Welcome showApp={linkTo('Button')} />;
toStorybook.story = {
name: 'to Storybook',
};

View File

@ -1,21 +0,0 @@
/** @jsx h */
import { h } from 'preact';
import { storiesOf } from '@storybook/preact';
import { action } from '@storybook/addon-actions';
import { linkTo } from '@storybook/addon-links';
import Welcome from './Welcome';
import Button from './Button';
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')}>
<span role="img" aria-label="so cool">
😀 😎 👍 💯
</span>
</Button>
));