nuxt / icon

The <Icon> component, supporting Iconify, Emojis and custom components.
https://stackblitz.com/edit/nuxt-icon-playground?file=app.vue
MIT License
874 stars 38 forks source link

How do we make nuxt-icon work in Storybook? #77

Open nasianss opened 1 year ago

nasianss commented 1 year ago

Is it possible to make work in Storybook? Thank you

ricovandevin commented 1 year ago

I'm interested in this too. A fair amount of Googling and trying some potential solutions did not give me a way to accomplish this.

Atinux commented 1 year ago

Would be nice to have a repository / reproduction to help

miclgael commented 1 year ago

Is the issue that it causes an error / warning?

If its anything like my experience getting nuxt-link to work, you may need to make a mock component.

https://github.com/miclgael/chia/blob/main/.storybook/mock-components/NuxtLink.js

Atinux commented 1 year ago

Could you take a look at https://github.com/hirotaka/storybook-addon-nuxt and tell me if this works?

miclgael commented 1 year ago

For me, storybook-addon-nuxt will throw an error when trying to use icon.

Interested to hear from you on this @nasianss πŸ™

I will try to make a reproduction as well.

miclgael commented 1 year ago

@Atinux My reproduction with storybook-addon-nuxt yields [Vue warn]: Failed to resolve component: icon If this is a native custom element, make sure to exclude it from component

https://stackblitz.com/edit/nuxt-starter-nivfnx?file=stories%2FIconTester.vue,stories%2FIconTester.stories.js

npm run storybook

I think this is a common issue - where every module in the nuxt ecosystem requires some sort of patch or workaround to work in Storybook.

e.g. https://github.com/hirotaka/storybook-addon-nuxt/issues/5

DenFin commented 11 months ago

@miclgael I'm getting the exact same error. Did you find a way to get this to work?

miclgael commented 11 months ago

@miclgael I'm getting the exact same error. Did you find a way to get this to work?

@DenFin It’s not ideal, but I think you would have to mock it for now. :(

DenFin commented 11 months ago

@miclgael Thanks for your reply.

I solved it by adding the Material Symbols icon font directly in my project and use it in a stylesheet

TiBianMod commented 7 months ago

@Atinux here you have a reproduction repo for testing

use main branche first to see that Storybook & Nuxt with Local components and Nuxt components is working !!! and then switch to nuxt-icon branch and enjoy πŸ˜„

from the moment you add nuxt-icon on modules, the issues starts, you don't even need to used on any story !!!

export default defineNuxtConfig({
    modules: ["@nuxtjs/storybook", "nuxt-icon"],
});
zola33dsf commented 5 months ago

Any updates please ?

memtech3 commented 4 months ago

I'm also experiencing this issue. I've glanced at IconCss.vue and nothing looks blaringly wrong there. Could this be a problem with all of the module. files? They seem* to be written sort of differently than nuxtUI writes theirs.

memtech3 commented 4 months ago

When I comment out the parts of module.mjs that import IconCSS.vue, (lines 91-95 in the npm package) storybook complains about template/script tags in Icon.vue. When I remove Icon.vue from module.mjs storybook stops complaining. Hopefully this is helpful diagnostic info

duplicate of #128