-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Toolbar: unify Storybook examples under one file, migrate from knobs to controls #47117
Conversation
Size Change: +87 B (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
Flaky tests detected in eee34c2. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3903480893
|
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.
Personally I don't see too much value in most of the stories except Without Group, because all the use cases seem to be covered in the Default story. I'm hoping we can think of a better documentation strategy once we have TS types for the subcomponents!
Looks good to merge once the import path and copypasta is cleaned up 👍
// id is required for server side rendering | ||
// eslint-disable-next-line no-restricted-syntax | ||
<Toolbar> |
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.
Copypasta?
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.
Yup! Not an issue anymore since I deleted all of those extra stories
@@ -30,10 +54,10 @@ function InlineImageIcon() { | |||
); | |||
} | |||
|
|||
/* eslint-disable no-restricted-syntax */ | |||
export const _default = () => { | |||
export const Default = () => { |
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.
This isn't super important because Toolbar
itself doesn't have a lot of props anyway, but I think a general pattern we can use to keep the main component "controls-ready" is to pass in all the content via the children
arg.
const Template = ( props ) => <Toolbar { ...props } />;
export const Foo = Template.bind( {} );
Foo.args = {
label: 'Options',
children: <ToolbarGroup>{/* whatever */}</ToolbarGroup>,
};
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.
Good point, I refactored the stories to use Template.bind()
+ args
syntax as suggested
ToolbarItem, | ||
ToolbarDropdownMenu, | ||
} from '..'; | ||
import { SVG, Path, DropdownMenu } from '../../../build'; |
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.
Wrong import path?
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.
Interesting glitch of my auto-import path plugin. It's fixed now
eee34c2
to
9ab59ee
Compare
Good point, I removed those extra stories. I just added an example of Can you give this PR a final look? 🙏 |
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 just realized the default story is also suffering from the dropdown cutoff problem 😕 I wish there was a better automatic fix but I haven't found one unfortunately. Last time I checked, we'd need to switch to fully custom Docs pages to get the popover portal where we want it.
Otherwise this looks good to go 🚢
What?
Following up the prep work from #46951, this PR tidies up
Toolbar
's Storybook examples into one file, and migrates from knobs to controls (even if no controls are being displayed at this point)Why?
The knobs addon is currently blocking using
npm 8
(see #46443)How?
Testing Instructions
Open Storybook, check that stories behave as expected and are comprehensive.