-
-
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
Vue: Add CSF3 default render function #17279
Conversation
☁️ Nx Cloud ReportCI ran the following commands for commit f7df112. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @yannbf ! I'm not a Vue expert but I don't think the default render function is correct. If you go to the new story in vue-kitchen-sink
, it does not update when you update the controls.
This works, but the source snippet shows component
instead of my-button
, so I don't think it's a good solution. I don't know enough Vue to know the right answer here:
return {
props: Object.keys(argTypes),
components: { Component },
template: '<component v-bind="$props" />',
};
Alright I reworked the render function resulting in the following snippets: 1 - component with correct name property// Button.vue
export default {
name: 'my-button' // correct, should be used as is
} 2 - component with invalid name// Button.vue
export default {
name: 'button' // clashes with HTML reserved tag, should be prepended with sb
} 3 - component with name in PascalCase// Button.vue
export default {
name: 'MyComponentName' // JSX name, should be used as is
} 4 - component with no name property// Button.vue
export default {
// with no name property, name should be extracted from file name
} What I'm unsure is about scenarios 3 and 4. Should the JSX name be used? Should we always kebab-case them? @pocka @prashantpalikhe would love to hear your perspective! |
a6bffe8
to
f2b6346
Compare
I feel both results are quite intuitive. For scenario 3, we can't guess the user's preference because PascalCase name can be used for both kebab-case and PascalCase usage. Since the official style guide recommends using PascalCase instead of kebab-case, we should keep the PascalCase name, IMO. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yannbf Looking great, but Storyshots is failing in CI. Looks like that global registration was there to illustrate a particular use case:
Storyshots › Custom/Method for rendering Vue › pre-registered component
error: [Vue warn]: Unknown custom element: <my-button> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
Oops. Fixed! |
Hi @yannbf I think when providing these defaults, the best is to mimic the behavior of Vue dev tools. Vue dev tools seem to only display component names in PascalCase, even when the name is provided in kebab-case in the component definition. E.g. The provided If no name is provided, the chosen display name is the name of the import. E.g. In the Storybook case, users would probably do So to answer your questions: Q3: Since Vue dev tools always prefer PascalCase, I'd go the same way. Also, my suggestion is to play more with all your use cases and see how Vue dev tools handle things. And stick to that behavior. |
fb2930d
to
c63faf3
Compare
Issue: #15498
What I did
Added Vue default render function
How to test
1 - Run storybook in vue-kitchen-sink
2 - See Button/WithDefaultRender
If your answer is yes to any of these, please make sure to include it in your PR.