Skip to content

Commit 904f642

Browse files
author
Jessica Peng
authoredMar 19, 2020
Merge pull request #7 from MyEtherWallet/feature/storybook-vuetify
Yes got storybook to work with vuetify
2 parents 4ab9d4e + eb3942a commit 904f642

File tree

7 files changed

+516
-4
lines changed

7 files changed

+516
-4
lines changed
 

‎.storybook/addons.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import '@storybook/addon-a11y/register';
2+
import '@storybook/addon-knobs/register';
3+
import '@storybook/addon-links/register';
4+
import '@storybook/addon-notes/register';
5+
import '@storybook/addon-storysource/register';
6+
import '@storybook/addon-viewport/register';

‎.storybook/config.js

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { configure, addDecorator } from '@storybook/vue';
2+
import Vue from 'vue';
3+
import vuetifyConfig from "../src/plugins/vuetify";
4+
import "vuetify/src/styles/main.sass";
5+
import { configureViewport, INITIAL_VIEWPORTS } from '@storybook/addon-viewport'
6+
7+
// From https://github.com/nidkil/vuetify-with-storybook
8+
const vuetifyViewports = {
9+
VuetifyLg: {
10+
name: 'Vuetify LG',
11+
styles: {
12+
width: '1904px'
13+
},
14+
type: 'desktop'
15+
},
16+
VuetifyXs: {
17+
name: 'Vuetify XS',
18+
styles: {
19+
width: '600px'
20+
},
21+
type: 'mobile'
22+
},
23+
VuetifySm: {
24+
name: 'Vuetify SM',
25+
styles: {
26+
width: '960px'
27+
},
28+
type: 'mobile'
29+
},
30+
VuetifyMd: {
31+
name: 'Vuetify MD',
32+
styles: {
33+
width: '1264px'
34+
},
35+
type: 'tablet'
36+
},
37+
VuetifyXl: {
38+
name: 'Vuetify XL',
39+
styles: {
40+
width: '4096px'
41+
},
42+
type: 'desktop'
43+
}
44+
}
45+
configureViewport({
46+
defaultViewport: 'VuetifyMd',
47+
viewports: {
48+
...vuetifyViewports,
49+
...INITIAL_VIEWPORTS
50+
}
51+
});
52+
addDecorator(() => ({
53+
vuetify: vuetifyConfig,
54+
template: '<v-app><v-content><v-container><v-layout column><story/></v-layout></v-container></v-content></v-app>',
55+
}));
56+
57+
// automatically import all files ending in *.stories.js
58+
const req = require.context('../stories', true, /.stories.js$/);
59+
function loadStories() {
60+
req.keys().forEach(filename => req(filename));
61+
}
62+
63+
configure(loadStories, module);

‎.storybook/webpack.config.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const path = require('path');
2+
3+
// Export a function. Accept the base config as the only param.
4+
module.exports = async ({ config, mode }) => {
5+
// `mode` has a value of 'DEVELOPMENT' or 'PRODUCTION'
6+
// You can change the configuration based on that.
7+
// 'PRODUCTION' is used when building the static version of storybook.
8+
9+
config.module.rules.push({
10+
test: /\.stories\.js?$/,
11+
loaders: [require.resolve('@storybook/source-loader')],
12+
enforce: 'pre',
13+
});
14+
15+
// Make whatever fine-grained changes you need
16+
config.module.rules.push({
17+
test: /\.s(c|a)ss$/,
18+
use: [
19+
'vue-style-loader',
20+
'css-loader',
21+
{
22+
loader: 'sass-loader',
23+
// Requires sass-loader@^8.0.0
24+
options: {
25+
implementation: require('sass'),
26+
sassOptions: {
27+
fiber: require('fibers'),
28+
indentedSyntax: true // optional
29+
},
30+
},
31+
},
32+
]
33+
});
34+
// Return the altered config
35+
return config;
36+
};

‎package-lock.json

+347
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+8
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,16 @@
2727
},
2828
"devDependencies": {
2929
"@babel/core": "^7.8.7",
30+
"@storybook/addon-a11y": "^5.2.1",
3031
"@storybook/addon-actions": "^5.3.17",
32+
"@storybook/addon-knobs": "^5.3.17",
3133
"@storybook/addon-links": "^5.3.17",
34+
"@storybook/addon-notes": "^5.3.17",
35+
"@storybook/addon-storysource": "^5.3.17",
36+
"@storybook/addon-viewport": "^5.3.17",
3237
"@storybook/addons": "^5.3.17",
3338
"@storybook/vue": "^5.3.17",
39+
"fibers": "^4.0.1",
3440
"@vue/cli-plugin-babel": "^3.11.0",
3541
"@vue/cli-plugin-eslint": "^3.11.0",
3642
"@vue/cli-service": "^3.11.0",
@@ -46,8 +52,10 @@
4652
"rollup-plugin-buble": "^0.19.8",
4753
"rollup-plugin-commonjs": "^10.0.1",
4854
"rollup-plugin-vue": "^5.0.1",
55+
"material-design-icons-iconfont": "^5.0.1",
4956
"sass": "^1.18.0",
5057
"sass-loader": "^7.1.0",
58+
"storybook-vue-router": "^1.0.7",
5159
"vue-cli-plugin-vuetify": "^0.6.3",
5260
"vue-template-compiler": "^2.6.10",
5361
"vuetify-loader": "^1.2.2"

‎src/plugins/vuetify.js

+54-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,59 @@
11
import Vue from "vue";
2-
import Vuetify from "vuetify/lib";
2+
import Vuetify, {
3+
VApp,
4+
VBtn,
5+
VCard,
6+
VCardText,
7+
VCol,
8+
VContainer,
9+
VContent,
10+
VDialog,
11+
VDivider,
12+
VIcon,
13+
VImg,
14+
VList,
15+
VListItem,
16+
VListItemAvatar,
17+
VListItemContent,
18+
VListItemIcon,
19+
VListItemTitle,
20+
VNavigationDrawer,
21+
VRow,
22+
VSheet,
23+
VSnackbar,
24+
VSparkline,
25+
VToolbar,
26+
VLayout
27+
} from "vuetify/lib";
328

4-
Vue.use(Vuetify);
29+
Vue.use(Vuetify, {
30+
components: {
31+
VApp,
32+
VBtn,
33+
VCard,
34+
VCardText,
35+
VCol,
36+
VContainer,
37+
VContent,
38+
VDialog,
39+
VDivider,
40+
VIcon,
41+
VImg,
42+
VList,
43+
VListItem,
44+
VListItemAvatar,
45+
VListItemContent,
46+
VListItemIcon,
47+
VListItemTitle,
48+
VNavigationDrawer,
49+
VRow,
50+
VSheet,
51+
VSnackbar,
52+
VSparkline,
53+
VToolbar,
54+
VLayout
55+
}
56+
});
557

658
export default new Vuetify({
759
theme: {

‎stories/MyButton.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ export default {
1616
},
1717

1818
template: `
19-
<button :style="buttonStyles" @click="onClick">
19+
<v-btn depressed :style="buttonStyles" @click="onClick">
2020
<slot></slot>
21-
</button>
21+
</v-btn>
2222
`,
2323

2424
methods: {

0 commit comments

Comments
 (0)
Please sign in to comment.