-
-
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
documentation: Clarify description of args - Add example of args controlling more than props #13978
documentation: Clarify description of args - Add example of args controlling more than props #13978
Conversation
Demo use of args outside props
docs/writing-stories/args.md
Outdated
@@ -98,6 +98,20 @@ Args are useful when writing stories for composite components that are assembled | |||
|
|||
<!-- prettier-ignore-end --> | |||
|
|||
## Args can modify any aspect of your components |
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.
Can we make the prose more framework agnostic? This text gets displayed to all frameworks (only the code samples change).
Also, how would this work in React?
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.
I realize that, but I don't know enough about React to know how you'd use args other than as props. And that was the problem that I was trying to address: frameworks that have concepts like slots that don't exist in React (AFAIK).
The original text was very props-centric and lead to my (and others) questions about slots in discord.
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.
Couldn't React be done like this?
const Template = (args, { argTypes }) => (
<page {...args}>
{args.footer}
</page>
);
export const CustomFooter = Template.bind({});
CustomFooter.args = {
footer: <a href="https://storybook.js.org/">Built with Storybook</a>,
};
A little sloppy, but I think that is the equivalent "args as a child" concept. How can we frame those both in this?
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.
If there isn't a snippet for every framework, what do I do? Do I copy the React version to the common
and all the other supported frameworks?
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.
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.
Would this (simpler) example be valid for React? Do the examples have to do exactly the same thing for all frameworks?
const Template = (args, { argTypes }) => (
<page {...args}>
<footer>{args.footer}</footer
</page>
);
export const CustomFooter = Template.bind({});
CustomFooter.args = {
footer: 'Built with Storybook',
};
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.
The examples have to do approximately the same thing.
The code will necessarily be different but the technique should be similar. The code snippet for each framework can be as verbose as we need to accomplish the technique.
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.
@domyen If there isn't a snippet for every framework, what do I do?
- Do I copy the React version to the common?
- Copy React version to all the other supported frameworks?
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.
@saschwarz Add snippets for Vue and React 🙏
All the other frameworks will automatically be shown React until someone contributes the code sample. There's a call to action to do this built into the snippet component already.
@saschwarz i'll take a look a this tomorrow (tuesday) first thing and i'll work with you on how to properly setup the snippets accordingly. Do you mind waiting a little bit? Stay safe |
@jonniebigodes Sorry I didn't see your comment until after I pushed up my changes. The snippet changes appropriately when I change to/from Vue/React/others. Please let me know any other things I need to do. |
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.
@saschwarz thank you very much for the time and effort you put into this. Glad that you managed to solve the way the snippets are shown in the documentation. I left some items that require a bit of attention, more specifically to file naming and this should be good to go. Let me know once you've addressed the comments and we'll get this across
@jonniebigodes Thank you for your patience in reviewing this PR. I merged the latest next, resolved the PR issues, and tested it. It seems OK. 😄 |
@saschwarz on the contrary. I should be the one to thank you for your patience for not addressing the pull request changes when i told you, but i got pulled into other items that required my attention. During the weekend i'm going to take another look and if nothing stands out, we'll be good to go and i'll gladly merge this. Do you mind waiting a little bit while i wrap up what i currently have on my hands? It goes without saying, thank you for the time and effort you put into this and help clarify the documentation. |
Sorry for not addressing this earlier i was caught up on other tasks. Looks good to me. Self merging. Once again thank you for the time and effort you put into this pull request and addressing feedback so promptly. Stay safe |
Issue:
There were a number of questions in the vue discord channel inquiring how to control non-props aspects of components in stories (i.e. slots). I tried to update the args text to be more encompassing and make it clear that all dynamic changes to a template go through the single
args
object.What I did
How to test
No
No
It is one 😄
If your answer is yes to any of these, please make sure to include it in your PR.