Toolbar: unify Storybook examples under one file, migrate from knobs to controls#47117
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.
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.
Yup! Not an issue anymore since I deleted all of those extra stories
|
|
||
| /* eslint-disable no-restricted-syntax */ | ||
| export const _default = () => { | ||
| export const Default = () => { |
There was a problem hiding this comment.
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.
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.
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? 🙏 |
mirka
left a comment
There was a problem hiding this comment.
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.