mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-02 05:03:44 +08:00
CLI templates: Vue SFC => module format
This commit is contained in:
parent
ac3c128bde
commit
8e7047f1db
@ -1,9 +1,4 @@
|
||||
import { configure } from '@storybook/vue';
|
||||
import { load } from '@storybook/vue';
|
||||
|
||||
// automatically import all files ending in *.stories.js
|
||||
const req = require.context('../src/stories', true, /\.stories\.js$/);
|
||||
function loadStories() {
|
||||
req.keys().forEach(filename => req(filename));
|
||||
}
|
||||
|
||||
configure(loadStories, module);
|
||||
load(require.context('../src/stories', true, /\.stories\.js$/), module);
|
||||
|
@ -0,0 +1,29 @@
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { linkTo } from '@storybook/addon-links';
|
||||
|
||||
import MyButton from './MyButton.vue';
|
||||
|
||||
export default {
|
||||
title: 'Button',
|
||||
};
|
||||
|
||||
export const text = () => ({
|
||||
components: { MyButton },
|
||||
template: '<my-button @click="action">Hello Button</my-button>',
|
||||
methods: { action: action('clicked') },
|
||||
});
|
||||
|
||||
export const jsx = () => ({
|
||||
components: { MyButton },
|
||||
render() {
|
||||
return <my-button onClick={this.action}>With JSX</my-button>;
|
||||
},
|
||||
methods: { action: linkTo('clicked') },
|
||||
});
|
||||
|
||||
export const emoji = () => ({
|
||||
components: { MyButton },
|
||||
template:
|
||||
'<my-button @click="action"><span role="img" aria-label="so cool">😀 😎 👍 💯</span></my-button>',
|
||||
methods: { action: action('clicked') },
|
||||
});
|
@ -0,0 +1,17 @@
|
||||
import { linkTo } from '@storybook/addon-links';
|
||||
|
||||
import Welcome from './Welcome.vue';
|
||||
|
||||
export default {
|
||||
title: 'Welcome',
|
||||
};
|
||||
|
||||
export const toStorybook = () => ({
|
||||
components: { Welcome },
|
||||
template: '<welcome :showApp="action" />',
|
||||
methods: { action: linkTo('Button') },
|
||||
});
|
||||
|
||||
toStorybook.story = {
|
||||
name: 'to Storybook',
|
||||
};
|
@ -1,34 +0,0 @@
|
||||
/* eslint-disable react/react-in-jsx-scope */
|
||||
|
||||
import { storiesOf } from '@storybook/vue';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { linkTo } from '@storybook/addon-links';
|
||||
|
||||
import MyButton from './MyButton.vue';
|
||||
import Welcome from './Welcome.vue';
|
||||
|
||||
storiesOf('Welcome', module).add('to Storybook', () => ({
|
||||
components: { Welcome },
|
||||
template: '<welcome :showApp="action" />',
|
||||
methods: { action: linkTo('Button') },
|
||||
}));
|
||||
|
||||
storiesOf('Button', module)
|
||||
.add('with text', () => ({
|
||||
components: { MyButton },
|
||||
template: '<my-button @click="action">Hello Button</my-button>',
|
||||
methods: { action: action('clicked') },
|
||||
}))
|
||||
.add('with JSX', () => ({
|
||||
components: { MyButton },
|
||||
render() {
|
||||
return <my-button onClick={this.action}>With JSX</my-button>;
|
||||
},
|
||||
methods: { action: linkTo('clicked') },
|
||||
}))
|
||||
.add('with some emoji', () => ({
|
||||
components: { MyButton },
|
||||
template:
|
||||
'<my-button @click="action"><span role="img" aria-label="so cool">😀 😎 👍 💯</span></my-button>',
|
||||
methods: { action: action('clicked') },
|
||||
}));
|
Loading…
x
Reference in New Issue
Block a user