-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Addon-docs: Support Vue JSX in MDX stories #7729
Comments
Hi @Aaron-Pool the contents of Here's a valid example: <Story name="square" height="60px">
{{
template: '<my-button :rounded="false">A Button with square edges</my-button>',
}}
</Story> This should exactly parallel the return value from a regular Storybook for Vue story. https://storybook.js.org/docs/guides/guide-vue/ |
Oh? Sorry, this example in in the technical preview threw me off import { action } from '@storybook/addon-actions';
import { Button } from '@storybook/react/demo';
import { Story, Meta } from '@storybook/addon-docs/blocks';
<Meta title='MDX|Button' component={Button} />
# Hello Docs
Welcome to the future of Storybook!
<Story name="hello">
<Button onClick={action('clicked')}>Hello button!</Button>
</Story>
<Story name="with emoji">
<Button onClick={action('clicked')}>🤘🚀💯</Button>
</Story> I assumed that that would work for any JSX supporting view layer, since (to my knowledge) the above has no parallel to the current usage of the way stories are written, even in the react view layer? |
Unfortunately we're not there yet. We support JSX directly in React, but it's going to take a little work to get that level of ergonomics for the other view layers. There are two reasons:
Now that I write this I realize that we could probably make our own compiler smarter about this and eliminate the need for both of those things. I'm not sure what's the best solution yet, but would be up for figuring that out together after 5.2 ships. I'm converting this bug report into a feature request. :) |
@shilman yeah, I actually spent about an hour digging through your mdx compiler plug-in, it seems like it should be possible to check the view layer and parse the contents of the tag with a different set of Babel plugins, depending on the view layer that is active. But I tried to do a quick hack of the storybook compiler dist code and I was still running into some parsing errors. Whenever I get a chance to get back to it, I'll try to add a more detailed write up to this thread. |
Oh, and also, I don't entirely know what you specifically mean when you say "AFAIK, @storybook/vue does not support JSX directly yet". Because you can definitely use JSX with the Vue |
Yeah that's what I meant. I think the non-react view layers support stores that return objects and strings. Whereas |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
Hi, Using versions 5.2.1 of @storybook/vue and @storybook/addon-docs I've been following drastically the installation guide for addon-docs, replacing the preset with Here is my Button.stories.mdx file
Then I run storybook and when I go the docs tab on the Button story, I get this error :
Do you guys have a link towards a working example of storybooks addon-docs with Vue ? Thanks! Edit : I also tried this implementation
With no success. It does not outputs any error, but I still dont get my custom Button classes and all when I inspect the result. Quick FYI : it still works like this in .stories.js files :
|
@mathieuartu Vue JSX does not currently work on As for your edit, have you registered import { Button } from './Button';
<Story name="positive">
{{
components: { Button},
template: '<Button>A Button with square edges</Button>'
}}
</Story> |
@Aaron-Pool Thank you so much for your answer! I understand and I'll keep waiting for the day Vue JSX works in mdx files :) |
Any updates on this? |
Not saying that this should be a solution... but here's a code snippet of getting JSX to work with vue for anyone who is dying to use JSX for vue
An example of using this looks like this
|
How do you set args in your component ? |
@sdailly I followed the example in
|
I considering update my storybook form 5.3.x to 6.0.x, is vue mdx supported or not at 6.0.x. or 6.1.x ? I can not find any solution so far |
☝️ Also curious. Pretty sure this was announced as a feature for 6.x. Can't find where I read it, however, so maybe I dreamt it. |
@Hishengs not in 6.0 and 6.1 is just starting now |
@shilman I saw you removed this from 6.2 docs milestone. Any news or movement on this? |
waiting on mdx 2.0 |
https://www.npmjs.com/package/storybook-addon-vue-mdx should address this ticket. It's now possible, with caveats as the addon is very experimental, to load Vue components in MDX docs pages. |
Is this even still relevant with inline stories in mdx files being deprecated? |
@bodograumann indeed, I'd say that this is no longer relevant. And I believe that @Sidnioulz addon addresses a related but different problem. So I'm closing this for now. Thanks! |
You're right, I got confused by the all-too-familiar error message and missed that the execution contexts are different! |
Describe the bug
A clean install of vue and addon-docs preset doesn't work.
To Reproduce
Steps to reproduce the behavior:
yarn storybook
Expected behavior
It displays the docs for
Test.stories.mdx
correctly.Screenshots
System:
Additional context
Before I even got to this state, the storybook build wouldn't even run until I manually added
yarn add -D @babel/plugin-transform-react-jsx
The text was updated successfully, but these errors were encountered: