New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vuetify 2.0.2 not supported #7593
Comments
I had the same issue. All you have to do is add // add vuetify
import vuetifyConfig from '../src/plugins/vuetify'
addDecorator(() => ({
vuetify: vuetifyConfig,
template: '<v-app><v-content><story/></v-content></v-app>',
})) |
legend, thanks jack :) |
Decorators are the correct approach. |
or if you don't want to import the plugin....
|
@jacklp - how did you add the VuetifyLoaderPlugin? via Webpack or vue.config.js? |
@morficus I was encountering the same issue as you. I solved it by creating a separate vuetify config file just for Storybook and using the full installation method for Vuetify inside of Storybook, so it doesn't rely on VuetifyLoaderPlugin. This way I could get Vuetify working in Storybook while still using VuetifyLoaderPlugin in my main application. Hope that helps. |
@kyleoliveiro @atgjack <v-app>
<v-card height="400" width="256" class="mx-auto"></v-card>
</v-app>
I configured Vuetify using Webpack install instructions and followed your advice configuring storybook with it's own plugin config. My const path = require('path');
module.exports = async ({ config, mode }) => {
config.module.rules = [
...config.module.rules,
{
test: /\.s(c|a)ss$/,
use: [
'vue-style-loader',
'css-loader',
{
loader: 'sass-loader',
options: {
implementation: require('sass'),
sassOptions: {
fiber: require('fibers'),
indentedSyntax: true
}
}
}
]
}
];
config.resolve.alias = {
...config.resolve.alias,
'@': path.resolve(__dirname, '../src')
}
return config;
};
import Vue from 'vue'
import Vuetify from 'vuetify/lib'
import { configure, addDecorator } from '@storybook/vue'
Vue.use(Vuetify)
addDecorator(() => ({
vuetify: new Vuetify(),
template: '<v-app><story/></v-app>'
}))
configure(require.context('../stories', true, /\.stories\.js$/), module); I don't know why v-components wont register globally but I got it to work by following A-la-carte setup to register them explicitly. import Vue from 'vue'
import * as _Vuetify from 'vuetify/lib'
import { configure, addDecorator } from '@storybook/vue'
const Vuetify = _Vuetify.default
const isVueComponent = obj => obj.name === 'VueComponent'
const VComponents = Object.keys(_Vuetify).reduce((acc, key) => {
if (isVueComponent(_Vuetify[key])) {
acc[key] = _Vuetify[key]
}
return acc
}, {})
Vue.use(Vuetify, {
components: {
...VComponents
}
})
addDecorator(() => ({
vuetify: new Vuetify(),
template: '<v-app><story/></v-app>'
}))
configure(require.context('../stories', true, /\.stories\.js$/), module); |
I had the same problem and @adambuczek approach reflects mine. I do have an issue however in trying to override scss variable for Vuetify 2.
The above is incorrect, I was just redeclaring already declared sass variables. I now understand that i need VuetifyLoaderPlugin and the a-la-carte approach so that vuetifyloader can override the sass variables needed for customization. When i do try the vuetifyloader approach, the it's my custom components that complain about not having a render function. |
This approach no longer works for Vuetify 2 since there is no more "Full installation method". I'm having the same issue as @antoniancu; Unable to customize the Vuetify theme for Storybook. The approach suggested by @atgjack does not work, as Storybook complains that the Vuetify components are not registered. Please re-open this issue @backbone87 |
Having the same issue - can't customize anything Vuetify related. Here's my config: import Vue from 'vue'
import * as _Vuetify from 'vuetify/lib'
import { configure, addDecorator } from '@storybook/vue'
import { keyBy } from 'lodash';
import Icons from '@/components/icons/index';
const Vuetify = _Vuetify.default
const isVueComponent = obj => obj.name === 'VueComponent'
const VComponents = Object.keys(_Vuetify).reduce((acc, key) => {
if (isVueComponent(_Vuetify[key])) {
acc[key] = _Vuetify[key]
}
return acc
}, {})
Vue.use(Vuetify, {
options: {
customProperties: true,
},
icons: {
iconfont: 'md',
values: {
...keyBy(Icons, 'name'),
},
},
components: {
...VComponents
}
})
addDecorator(() => ({
vuetify: new Vuetify({
options: {
customProperties: true,
},
icons: {
iconfont: 'md',
values: {
...keyBy(Icons, 'name'),
},
},
}),
template: '<v-app><story/></v-app>'
}))
// automatically import all files ending in *.stories.js
configure(require.context('../src', true, /\.stories\.js$/), module); |
ok I got this working with the following config. Hoping this helps someone in the future. The difference between the Frankly getting Storybook working with Vuetify is entirely too much trouble const path = require('path');
module.exports = async ({ config }) => {
function resolve(dir) {
return path.join(__dirname, '..', dir);
}
/** removes existing scss rule */
config.module.rules = config.module.rules.filter(rule =>
!rule.test.test('.scss')
)
config.module.rules.push({
test: /\.sass$/,
use: [
'vue-style-loader',
'css-loader', {
loader: 'sass-loader',
options: {
implementation: require('sass'),
data: `
@import '@/styles/styles.scss'
`,
}
},
],
}, {
test: /\.scss$/,
use: [
'vue-style-loader',
'css-loader', {
loader: 'sass-loader',
options: {
implementation: require('sass'),
data: `
@import '@/styles/styles.scss';
`,
}
},
],
})
config.resolve = {
extensions: ['.js', '.vue', '.json'],
alias: {
vue$: 'vue/dist/vue.esm.js',
'@': resolve('src'),
},
};
return config;
}; |
cc @pocka @Aaron-Pool anything we learn from this and improve in the docs or out-of-box config? |
Here is how I got
Now if I use However, if I use any vuetify component within a story definition itself, I get warnings about components that haven't registered. So if you are to use specific vuetify components within the story file, you have to manually register them:
Maybe someone understands why this behaviour and how to make it easier? |
Yes, it is how storybook requires stories and how it interacts with Vue |
can this be explained further? is there a documentation for me to read to understand this more? |
Hi @mediafreakch, could you explain what does the parameter I'm abit confused here as I'm not very familiar with storybook mechanics |
Thanks for that mate! So I could globally load all vuetify components with:
And in case someone is interested the whole configuration:
btw. version:
|
Are you guys able to read scoped styles that touches vuetify components?
|
This solution worked for me.
Thanks a lot @DomDomHaas ! |
Thank you @DomDomHaas, your set up also worked for me. Specifically this is what I saw in the Chrome browser console:
From process of elimination, I narrowed it down to something to do with Storybook's Docs add-on that comes from including
|
I tried to dig further into this with no success. When the docs addon is enabled, this.$vuetify just seems to be a circular reference to |
Imho this issue should be reopened. I`ve got the same problem as @thomasvogelaar and @stingpan. Only after disabling the docs everything works as expected. Any ideas anyone? |
Automention: Hey @Aaron-Pool @elevatebart @pocka, you've been tagged! Can you give a hand here? |
There’s indeed an issue with this, when you provide I was able to work around the issue by providing the vuetify.js import Vue from 'vue';
import Vuetify from 'vuetify/lib';
Vue.use(Vuetify);
const vuetify = new Vuetify({
// ...
});
export default vuetify; .storybook/preview.js import vuetify from './path/to/vuetify.js';
addDecorator(() => ({
vuetify,
components: {
VApp,
},
render() {
return (
<VApp>
<story />
</VApp>
);
},
})); whatever.stories.mdx export const Template = (args, { argTypes }) => ({
vuetify, // <- Provide vuetify again locally
props: Object.keys(argTypes),
components: { VSelect },
template: `<VSelect :label="label" v-model="value" :items="items" />`,
}); |
IMO this issue should focus on the original topic (we can't access Vue root instance, the workaround is to add a decorator) and we better create another issue with more specific contexts. It seems recent comments are Docs Addon specific (especially Dynamic Source Rendering is suspicious regarding dates...). It's so hard to work on a bug report in the issue for a different bug, not only insufficient information (issue template is important!) but also the difficulty of knowing what "this issue" or "this bug" indicates. |
@pocka Isn’t the decorator needed in any case? The components must be wrapped within a |
Ah, my bad. We can't eliminate the need for the decorator anyway. Also, the correct problem is "we can't access Vue root instance" not "we can't
Do you mean this? It seems it's working without it according to comments... I thought the new Vue({
vuetify,
}).$mount('#app') I (and some contributors) acknowledge the root instance problem but there seems no actions taken yet. Relavant one: #13862 What I said is the "vuetify does not work when Docs Addon enabled". This is clearly Docs Addon, especially its rendering/source generation mechanisms' problem, since the same user code working on Canvas (normal preview). Docs Addon too have the root instance problem but we shouldn't mix these so to make these easier to work on. |
Hi just wanna say that I'm experiencing the same problem mentioned in some comments here regards importing the global variables.scss file. Has anyone found a solution or a workaround for this ? 🙏 I've tried with both importing This is my .storybook/preview.js file:
|
Is this issue still relevant today in 7.0 beta? |
I am closing this since we haven't had any reaction for a year. Please let us know if the issue persists in the latest version of Storybook. |
Description:
https://stackoverflow.com/a/56367842
The new style of latest version of vuetify 2.0.2 requires that vuetify be passed into new Vue()
My .storybook/config.js file:
My /plugins/vuetify.ts file:
Cannot read property 'dark' of undefined
TypeError: Cannot read property 'dark' of undefined
at VueComponent.isDark (http://localhost:9001/vendors~main.2f0c8252b2ad5480ce8f.bundle.js:73337:34)
at Watcher.get (http://localhost:9001/vendors~main.2f0c8252b2ad5480ce8f.bundle.js:65400:25)
at Watcher.evaluate (http://localhost:9001/vendors~main.2f0c8252b2ad5480ce8f.bundle.js:65505:21)
at VueComponent.computedGetter [as isDark] (http://localhost:9001/vendors~main.2f0c8252b2ad5480ce8f.bundle.js:65755:17)
at VueComponent.themeClasses (http://localhost:9001/vendors~main.2f0c8252b2ad5480ce8f.bundle.js:105182:29)
at Watcher.get (http://localhost:9001/vendors~main.2f0c8252b2ad5480ce8f.bundle.js:65400:25)
at Watcher.evaluate (http://localhost:9001/vendors~main.2f0c8252b2ad5480ce8f.bundle.js:65505:21)
at Proxy.computedGetter (http://localhost:9001/vendors~main.2f0c8252b2ad5480ce8f.bundle.js:65755:17)
at Proxy.render (http://localhost:9001/vendors~main.2f0c8252b2ad5480ce8f.bundle.js:73354:15)
at VueComponent.Vue._render (http://localhost:9001/vendors~main.2f0c8252b2ad5480ce8f.bundle.js:64491:22)```
The text was updated successfully, but these errors were encountered: