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: Add first-class args support #11115

Merged
merged 5 commits into from
Jun 11, 2020
Merged

Vue: Add first-class args support #11115

merged 5 commits into from
Jun 11, 2020

Conversation

shilman
Copy link
Member

@shilman shilman commented Jun 10, 2020

Issue: #11051

What I did

Worked with @backbone87 and @tmeasday to automatically inject args into the prop values, so you can do this:

export const Rounded = (args) => ({
  props: Object.keys(args),
  components: { MyButton },
  template: '<my-button :color="color" :rounded="rounded">A Button with rounded edges</my-button>',
});
Rounded.argTypes = {
  rounded: { defaultValue: true },
  color: { control: { type: 'color' }, defaultValue: '#f00' },
};

This needs documentation but I'm not sure where is the best place for it currently.

How to test

See vue-kitchen-sink

Feedback wanted, h/t @ndelangen for the idea of baking it into @storybook/vue

@shilman
Copy link
Member Author

shilman commented Jun 10, 2020

@@ -44,8 +44,10 @@ export default function render({

showMain();

// always refresh the component
root[COMPONENT] = element;
// at component creation || refresh by HMR // always refresh the component
Copy link
Member

Choose a reason for hiding this comment

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

Refresh by HMR OR changing story to be clear.

@graup
Copy link
Contributor

graup commented Jun 11, 2020

If the story returns args, @storybook/vue will unpack the args into props with default values.

To me, that doesn't sound very intuitive. If we introduce "magic", it should be properly named, something like { defaultProps: args }. But is it really necessary? It would be better if we can let the user define data/props normally and just work with that.

@shilman
Copy link
Member Author

shilman commented Jun 11, 2020

@graup thanks for the feedback and point taken. check out the new version, updated in the description. much better i think!

@shilman
Copy link
Member Author

shilman commented Jun 11, 2020

Self-merging @backbone87 @tmeasday

@shilman shilman merged commit 21f8d0e into next Jun 11, 2020
@graup
Copy link
Contributor

graup commented Jun 11, 2020

@shilman yeah this is better! 👍

@Martskin
Copy link

Martskin commented Jun 11, 2020

The controls are working on the Canvas tab great now but don't seem to be having any effect in the Docs addon tab.

https://next--storybookjs.netlify.app/vue-kitchen-sink/?path=/story/button--rounded

storybook-doc-controls

@shilman
Copy link
Member Author

shilman commented Jun 11, 2020

@Martskin thanks for letting me know. Will look into it tomorrow!

@Martskin
Copy link

Martskin commented Jun 11, 2020

@Martskin thanks for letting me know. Will look into it tomorrow!

Glad to help! Thanks for the response.

@Martskin
Copy link

The controls are working on the Canvas tab great now but don't seem to be having any effect in the Docs addon tab.

Release https://github.com/storybookjs/storybook/releases/tag/v6.0.0-beta.26 fixed it for me! Thanks.

@stof stof deleted the 11051-vue-args-support branch May 25, 2022 09:26
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.

4 participants