mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-02 05:03:44 +08:00
CLI templates: preact => module format
This commit is contained in:
parent
eb28c95977
commit
efda1d5ccc
@ -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);
|
||||
|
19
lib/cli/generators/PREACT/template/stories/Button.stories.js
Normal file
19
lib/cli/generators/PREACT/template/stories/Button.stories.js
Normal 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>
|
||||
);
|
@ -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',
|
||||
};
|
@ -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>
|
||||
));
|
Loading…
x
Reference in New Issue
Block a user