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

Vue: support @values in args table #16019

Conversation

adrianpdm
Copy link
Contributor

@adrianpdm adrianpdm commented Sep 12, 2021

Issue: #13764 Addon-docs/Vue: Support @values in ArgsTable

What I did

Framework
Vue

Changes

  • addon/docs
    • Change how ArgTypes is returned from the extractArgTypes: ArgTypesExtractor
      • Mutate propDef, ensuring its type is converted to enum if @values tag is defined
      • Sync sbType with mutated propDef.type
      • Append corresponding enumerated values into the propDef.type.summary
  • examples/vue-cli
    • Add example in Button.vue
    • Remove argTypes.size from Button's story, ensuring its size options are inferred from the generated docs, rather than being manually defined.

How to test

cd examples/vue-cli
yarn storybook

Enums defined using @values tag will be shown under Description and available as either radio or select control in the ArgsTable.

image

@nx-cloud
Copy link

nx-cloud bot commented Sep 12, 2021

Nx Cloud Report

CI ran the following commands for commit ae970f4. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch

Status Command
#000000 nx run-many --target=prepare --all --parallel --max-parallel=15

Sent with 💌 from NxCloud.

@adrianpdm
Copy link
Contributor Author

Hi, it seems that there is a conflict. Should i rebase my branch?.

@yannbf
Copy link
Member

yannbf commented Sep 14, 2021

Hi, it seems that there is a conflict. Should i rebase my branch?.

Yes! Or merge the latest next into it, whatever feels more comfortable to you. Let me know if you'd like any assistance :)

@adrianpdm adrianpdm force-pushed the 13764/addons-docs-vue-support-values-in-args-table branch from 2037f25 to ae970f4 Compare September 14, 2021 15:53
@adrianpdm
Copy link
Contributor Author

Hi, it seems that there is a conflict. Should i rebase my branch?.

Yes! Or merge the latest next into it, whatever feels more comfortable to you. Let me know if you'd like any assistance :)

Hi, thank you for reaching out 🙏. As for the conflicts, I chose to rebase my branch onto next.

@yannbf
Copy link
Member

yannbf commented Sep 16, 2021

Thanks a lot for your contribution @adrianpdm!

While I was testing this, I found a few things worth mentioning:
1 - You should probably check for empty values. If you set @values first, second, and leave a dangling comma, controls will show an empty value as possible option:
image
2 - When changing the @values annotation while Storybook is running, HMR works and things are rebuilt, however there are no changes in the controls panel. Even when switching stories they don't change, so you need to reload the entire page for the change to have effect.

Regarding point 2, @shilman I believe this might be a bug in controls and not something related to this change. WDYT?

@adrianpdm
Copy link
Contributor Author

Thank you for testing this out @yannbf 😃

I surely can filter out the empty values that is caused by the dangling commas. Although, to me it is to be expected since that just how vue-docgen behaves. WDYT?.

As for the HMR issue, i do experience the same behavior in my company's Storybook (v6.2.9), which doesn't trigger rebuilt when making some docgen-related changes.

@yannbf yannbf changed the title Support @values in args table Vue: support @values in args table Oct 4, 2021
Copy link
Member

@yannbf yannbf left a comment

Choose a reason for hiding this comment

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

Hey @adrianpdm sorry for the long time (I was on vacation) to reply!
I believe we should just keep things as is. The HMR is something not related to this PR anyway, and we should look further into it.

Thanks a lot for your contribution! This one is good to go!

@shilman shilman merged commit cf23a44 into storybookjs:next Oct 5, 2021
@shilman shilman added this to the 6.4 PRs milestone Oct 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants