Skip to content
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: Add support for Vue 3 #13809

Merged
merged 2 commits into from
Feb 4, 2021

Conversation

phated
Copy link
Contributor

@phated phated commented Feb 4, 2021

Issue: Follow up to #13775

What I did

I added initial support for Vue 3 in @storybook/addon-docs. This was mostly a copy-paste of the vue implementation, but the prepareForInline became very streamlined since Vue 3 allows you to render a vnode directly into the DOM.

Notably missing: The sourceDecorator from Vue 2 won't work because vnodes no longer contain all the information to build up the templates. I explored calling render(vnode, document.createElement('div')) before looking at the props and it helped a bit, but I think the true way to build this would be a custom renderer, similar to how they do SSR and their test utils. However, that is way out of my depth.

I also needed to fix the types in the html framework for some reason.

How to test

I tested this in the vue 3 example storybook and it seems to be working.

If your answer is yes to any of these, please make sure to include it in your PR.

@phated phated requested a review from shilman February 4, 2021 02:33
@phated phated added the run e2e extended test suite Run the e2e extended test suite in CircleCI workflows label Feb 4, 2021
Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

LGTM 🥇

@shilman shilman added this to the 6.2 core milestone Feb 4, 2021
@shilman shilman merged commit 4edd83c into storybookjs:next Feb 4, 2021
@phated phated deleted the phated/vue3-addon-docs branch February 4, 2021 18:57
@Mootook
Copy link

Mootook commented Feb 4, 2021

@phated Perhaps I'm missing something but why is this still concerned with previous vue?

// addons/docs/src/frameworks/vue3/preset.ts
loader: require.resolve('vue-docgen-loader', { paths: [require.resolve('@storybook/vue')] })

since I get Error: Cannot find module '@storybook/vue' when running start-storybook -p 6006 using @storybook/vue3.

@phated
Copy link
Contributor Author

phated commented Feb 4, 2021

@Mootook Just a bug. Good catch. A lot of this work was just copy-pasting the @storybook/vue code and adapting some parts to vue 3 APIs and I missed this reference. I'll submit a patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addon: docs feature request run e2e extended test suite Run the e2e extended test suite in CircleCI workflows vue3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants