-
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
Heading: Complete TypeScript migration of component #41921
Conversation
Size Change: 0 B Total Size: 1.25 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.
Thanks for the continued efforts typing the components package @walbo 🙇
This is looking pretty good.
While testing the component in the Storybook I noticed that the variant
control is a radio button. This means you can't toggle off the muted
variant once it's clicked. We should probably tweak that while we're here.
Not sure if a check
or select
control might be better options. If using a check
control the example markup may show variant={[]}
when you toggle muted
on then off. We could even switch the control to boolean
and set the variant
prop to muted
based on that being set.
Example diff demonstrating toggle control for variant etc.
diff --git a/packages/components/src/heading/stories/index.tsx b/packages/components/src/heading/stories/index.tsx
index f25b21728e..1cc78538ac 100644
--- a/packages/components/src/heading/stories/index.tsx
+++ b/packages/components/src/heading/stories/index.tsx
@@ -19,7 +19,7 @@ const meta: ComponentMeta< typeof Heading > = {
letterSpacing: { control: { type: 'text' } },
lineHeight: { control: { type: 'text' } },
optimizeReadabilityFor: { control: { type: 'color' } },
- variant: { control: { type: 'radio' }, options: [ 'muted' ] },
+ variant: { control: { type: 'boolean' } },
weight: { control: { type: 'text' } },
},
parameters: {
@@ -30,8 +30,9 @@ const meta: ComponentMeta< typeof Heading > = {
export default meta;
export const Default: ComponentStory< typeof Heading > = ( props ) => (
- <Heading { ...props } />
+ <Heading { ...props } variant={ props.variant ? 'muted' : undefined } />
);
Default.args = {
children: 'Heading',
+ level: '3',
};
Also, it might be beneficial to demonstrate the level
prop's use within the default story.
Other than that, I left a couple of other very minor comments inline as well.
✅ No typing errors
✅ Unit tests pass
✅ Code changes make sense
✅ Has changelog & readme props and types pretty much match
✅ Component functions correctly in both Storybook and editors
✅ Auto-generated docs in Storybook are meaningful
❔ Storybook example has appropriate controls
I don't feel super strongly about it, but for context, here are the pros/cons that were discussed: #38842 (comment) If y'all think it's worth addressing, another way to go might be: variant: {
control: { type: 'radio' },
options: [ 'undefined', 'muted' ],
mapping: { undefined, muted: 'muted' },
}, |
Implemented the |
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.
Thanks for the updates!
LGTM 🚢
✅ No typing errors
✅ Unit tests pass
✅ Code changes make sense
✅ Has changelog & readme props and types match
✅ Component functions correctly in both Storybook and editors
✅ Auto-generated docs in Storybook are meaningful
✅ Storybook example has appropriate controls
What?
Completes the migration of
Heading
component to TypeScript.Why?
Part of the @wordpress/components's TypeScript migration (#35744).
How?
types.js
Testing Instructions
Heading
continues to function as expected