Skip to content

Commit

Permalink
Merge pull request #7501 from storybookjs/7499-module-format-vue
Browse files Browse the repository at this point in the history
CLI: update `sb init` to module format for Vue
  • Loading branch information
shilman authored Jul 21, 2019
2 parents 8a21f97 + dd756d9 commit f712df8
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 83 deletions.
1 change: 1 addition & 0 deletions lib/cli/generators/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
'import/no-unresolved': ignore,
'import/no-extraneous-dependencies': ignore,
'global-require': ignore,
'react/react-in-jsx-scope': ignore,
},
},
};
2 changes: 1 addition & 1 deletion lib/cli/generators/RAX/template/stories/Welcome.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable react/react-in-jsx-scope, react/prop-types, jsx-a11y/anchor-is-valid */
/* eslint-disable react/prop-types, jsx-a11y/anchor-is-valid */
import { createElement } from 'rax';
import View from 'rax-view';
import Text from 'rax-text';
Expand Down
1 change: 0 additions & 1 deletion lib/cli/generators/RAX/template/stories/index.stories.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/react-in-jsx-scope */
import { createElement } from 'rax';
import { storiesOf } from '@storybook/rax';
import { action } from '@storybook/addon-actions';
Expand Down
9 changes: 2 additions & 7 deletions lib/cli/generators/SFC_VUE/template/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -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);
29 changes: 29 additions & 0 deletions lib/cli/generators/SFC_VUE/template/src/stories/Button.stories.js
Original file line number Diff line number Diff line change
@@ -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') },
});
17 changes: 17 additions & 0 deletions lib/cli/generators/SFC_VUE/template/src/stories/Welcome.stories.js
Original file line number Diff line number Diff line change
@@ -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',
};
34 changes: 0 additions & 34 deletions lib/cli/generators/SFC_VUE/template/src/stories/index.stories.js

This file was deleted.

9 changes: 2 additions & 7 deletions lib/cli/generators/VUE/template/.storybook/config.js
Original file line number Diff line number Diff line change
@@ -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('../stories', true, /\.stories\.js$/);
function loadStories() {
req.keys().forEach(filename => req(filename));
}

configure(loadStories, module);
load(require.context('../stories', true, /\.stories\.js$/), module);
28 changes: 28 additions & 0 deletions lib/cli/generators/VUE/template/stories/Button.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { action } from '@storybook/addon-actions';
import { linkTo } from '@storybook/addon-links';

import MyButton from './MyButton';

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(h) {
return <my-button onClick={this.action}>With JSX</my-button>;
},
methods: { action: linkTo('clicked') },
});

export const emoji = () => ({
components: { MyButton },
template: '<my-button @click="action">😀 😎 👍 💯</my-button>',
methods: { action: action('clicked') },
});
17 changes: 17 additions & 0 deletions lib/cli/generators/VUE/template/stories/Welcome.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { linkTo } from '@storybook/addon-links';

import Welcome from './Welcome';

export default {
title: 'Welcome',
};

export const toStorybook = () => ({
components: { Welcome },
template: '<welcome :showApp="action" />',
methods: { action: linkTo('Button') },
});

toStorybook.story = {
name: 'to Storybook',
};
33 changes: 0 additions & 33 deletions lib/cli/generators/VUE/template/stories/index.stories.js

This file was deleted.

1 comment on commit f712df8

@vercel
Copy link

@vercel vercel bot commented on f712df8 Jul 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.