-
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
ItemGroup: migrate Storybook to controls, refactor to TypeScript #46945
Conversation
ItemGroup
: migrate Storybook to controls, refactor to TypeScript<ItemGroup { ...props } /> | ||
); | ||
|
||
export const Default: ComponentStory< typeof ItemGroup > = Template.bind( {} ); |
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.
Previously, ItemGroup
's stories were much more complex, and involved many other components in an effort to showcase how the component could be used:
- in combination with
Dropdown
- for more "complex" layouts (i.e. the ones used in Global Styles sidebar)
For now, I've decided not to convert those examples to TypeScript/controls because I feel like we've been recently trying to keep Storybook examples closer to the component they represent.
What do folks think?
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.
Yes, I agree the previous stories were a bit much.
Though, I wasn't familiar with this component and my first impression when seeing the new default story was that I couldn't understand what the component was supposed to be used for. Would it be more straightforward if we just had a group of three clickable Item
s? I'm assuming that is the main use case because I had a hard time finding an example in the Gutenberg app where there were unclickable items.
And if we want to highlight other usages like unclickable items, different padding sizes, borders, etc. we could do that in separate stories (doesn't have to be in this PR).
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.
Pushed some changes in 6623d9b — let me know if they look good to you (if they're not, I can open a follow-up)
<ItemGroup { ...props } /> | ||
); | ||
|
||
export const Default: ComponentStory< typeof ItemGroup > = Template.bind( {} ); |
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.
Also, note that I removed the hardcoded max-width
from the component, since we can now leverage some custom Storybook tools to change the container's width
@@ -33,6 +33,7 @@ export const itemWrapper = css` | |||
`; | |||
|
|||
export const item = css` | |||
box-sizing: border-box; |
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.
Linking to #42415 for posterity.
Size Change: +5 B (0%) Total Size: 1.32 MB
ℹ️ View Unchanged
|
Flaky tests detected in a947ad9. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3876020347
|
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 had a little suggestion for the default story, but otherwise I think we're good to merge once the snapshots are updated 🚢
@@ -33,6 +33,7 @@ export const itemWrapper = css` | |||
`; | |||
|
|||
export const item = css` | |||
box-sizing: border-box; |
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.
Linking to #42415 for posterity.
<ItemGroup { ...props } /> | ||
); | ||
|
||
export const Default: ComponentStory< typeof ItemGroup > = Template.bind( {} ); |
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.
Yes, I agree the previous stories were a bit much.
Though, I wasn't familiar with this component and my first impression when seeing the new default story was that I couldn't understand what the component was supposed to be used for. Would it be more straightforward if we just had a group of three clickable Item
s? I'm assuming that is the main use case because I had a hard time finding an example in the Gutenberg app where there were unclickable items.
And if we want to highlight other usages like unclickable items, different padding sizes, borders, etc. we could do that in separate stories (doesn't have to be in this PR).
5896305
to
6623d9b
Compare
What?
Related to #46443
Part of #35744
Migrate
ItemGroup
's Storybook examples to controls instead of knobs, and rewrite in TypeScriptWhy?
Knobs are deprecated
How?
Leveraging TypeScript to generate docs and controls, so that knobs are not necessary
Testing Instructions
Open Storybook, make sure that the
ItemGroup
example works and feels good