-
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
Storybook: Add badges based on tags
#61111
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: 0 B Total Size: 1.75 MB ℹ️ View Unchanged
|
@@ -33,8 +33,8 @@ const meta: Meta< typeof UseCompositeStorePlaceholder > = { | |||
// @ts-expect-error - See https://github.com/storybookjs/storybook/issues/23170 | |||
CompositeItem, | |||
}, | |||
tags: [ 'status-private' ], |
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.
We already had a slip-up here, where the tags
weren't present in the metadata so the icon wasn't being displayed in the sidebar.
The automation in this PR will prevent omissions like this.
@@ -34,7 +34,8 @@ export default { | |||
controls: { expanded: true }, | |||
docs: { canvas: { sourceState: 'shown' } }, | |||
}, | |||
} as Meta< typeof DimensionControl >; |
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.
Converting this back to our standard format, because the type casting overly complicates the AST parsing we'd have to do. Not worth it right now.
@@ -21,8 +21,8 @@ const meta: Meta< typeof CustomSelectControl > = { | |||
onChange: { control: { type: null } }, | |||
value: { control: { type: null } }, | |||
}, | |||
tags: [ 'status-wip' ], |
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.
Another slip-up here.
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 tests well and the code looks good 👍
I also verified all WIP / private stories look alright and they display the badges both in the sidebar and the top bar.
* Consolidate tags in stories * DimensionControl: Standardize story meta format for easier parsing * Storybook: Add badges based on `tags` Co-authored-by: mirka <[email protected]> Co-authored-by: tyxla <[email protected]>
What?
Automatically add a status tag (
Private
,WIP
, etc) to the story, based on thetags
property of the story metadata.Why?
This builds upon #58123 where we added component status badges, and #58518 where the status icon was inserted into the Storybook sidebar as well. The badge identifiers needed to be set in
meta.parameters.badges
(key for a third-party badge plugin), whereas the sidebar injection required identifiers to be present inmeta.tags
(an official Storybook key).Since this duplication of metadata is error-prone, and we'll probably be relying on the
meta.tags
for more applications in the future (e.g. categorizing, filtering), we decided we should maketags
the single source of truth.How?
Add a simple Babel plugin to copy relevant tags into the
meta.parameters.badges
field.Testing instructions
For tagged components like ProgressBar, the Storybook should show a badge icon in the sidebar in addition to the badge in the toolbar.