CLI templates: Vue SFC => module format

This commit is contained in:
Michael Shilman 2019-07-20 16:55:48 +08:00
parent ac3c128bde
commit 8e7047f1db
4 changed files with 48 additions and 41 deletions

View File

@ -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);

View File

@ -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') },
});

View File

@ -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',
};

View File

@ -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') },
}));