-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Button: refactor Storybook to controls and align docs #44105
Conversation
Size Change: 0 B Total Size: 1.28 MB ℹ️ View Unchanged
|
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.
Changes look good!
A couple of considerations:
- would it make sense to add the
isBusy
knobs also in otherButton
stories? - since knobs are deprecated, would it make sense to convert these stories to use controls instead?
Thanks for the review, @ciampo. I will push the updates tomorrow.
I need to check if the state is correctly applied for all variations. But happy to add controls where it makes sense. |
fce9c59
to
2cb890c
Compare
@ciampo, I converted knobs to controls, which made adding the Notes
P.S. Working with controls is way more fun 😄 |
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.
Thank you! The new stories are testing well !
Working with controls is way more fun 😄
I know, right?! Much easier, more fun and definitely more informative too
I combined most of the stories into two stories - "Default" and "Icon." I think this makes more sense than having multiple stories per variation.
Sounds good to me
I left "Buttons" and "Grouped Icon" stories untouched, as they are just a showcase.
While "Grouped Icon" in a way represents an example of usage of Button
, I'm not sure that the "Buttons" story should stick around — it only shows a subset of all the possible combinations that the Button
component can have, and all of its examples can be completely replicated via the "default" story. I would argue that it can be deleted.
I was thinking the same but wasn't 100% sure. I'm going to remove that story. |
525715a
to
dca0075
Compare
@ciampo, let me know if this is good to merge. |
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.
While giving this PR a final look, I noticed some discrepancies between the docs and the code regarding most default values of Button
's props. Looking at the code, almost every prop doesn't have a default value (i.e. its values is undefined
when the prop is not passed to Button
) apart from iconPosition
, which has a default value of left
. But the README lists default values for almost every prop.
Since we shouldn't have this discrepancy, we have two choices:
- Update the code to mirror what the docs say
- Update the docs to be in line with the code
In order to keep the scope of this PR small and focused on docs, I suggest that we update both the README and the Storybook stories to remove all default values (apart from iconPosition
).
In the README, when there's an implicit default value assigned by other components, we may want to mention it explicitly - e.g.:
diff --git a/packages/components/src/button/README.md b/packages/components/src/button/README.md
index 3bf23aed95..a3f2106221 100644
--- a/packages/components/src/button/README.md
+++ b/packages/components/src/button/README.md
@@ -209,11 +209,10 @@ If provided, renders an [Icon](/packages/components/src/icon/README.md) componen
#### iconSize
-If provided with `icon`, sets the icon size.
+If provided with `icon`, sets the icon size. Please refer to the [Icon](/packages/components/src/icon/README.md) component for more details regarding the default value of its `size` prop.
- Type: `Number`
- Required: No
-- Default: `20 when a Dashicon is rendered, 24 for all other icons.`
#### iconPosition
The same approach could be used for the tooltipPosition
prop.
We can always come back to Button
and add default values (both in code and in the docs) in a separate follow-up PR.
Sorry for the delay on this one. I've removed defaults from README/story. Also documented |
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.
Changes are looking good!
Apart from removing __experimentalIsFocusable
's default value, the last thing is to add a CHANGELOG entry. After that, we're ready to merge!
Regarding the follow-ups mentioned around the different inline styles, I think that a good summary would be:
- Refactor the component to TypeScript, and updating the README to include all props (e.g
describedBy
) - Potentially look into adding default values for those props, as it was documented in the README until this PR (and update types/readme accordingly)
Sorry for the delay on this one.
Not an issue at all! I actually really appreciate your help here :)
Co-authored-by: Marco Ciampini <[email protected]>
Co-authored-by: Marco Ciampini <[email protected]>
8c9aa93
to
e84813a
Compare
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.
Thank you!
What?
PR adds
isBusy
state knobs to Button component stories.Testing Instructions
npm run storybook:dev
primary
,secondary
orisDestructive
.Screenshots or screencast