-
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 stories for the TextDecorationControl component #67337
base: trunk
Are you sure you want to change the base?
Storybook: Add stories for the TextDecorationControl component #67337
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. |
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 PR!
I would like to make two suggestions.
- It looks like you are adding as many variations as possible as individual stories, but this seems redundant. All these props can be changed from the Controls panel. Also, if we go ahead with this approach, we will probably add similar variations to all other block editor components 😅
- It is certainly easier to understand with demo text, but Storybook is for testing and developing a single component itself. How this component interacts with the outside world is the responsibility of the developer who uses this component, and I think it is better not to include it in the story.
With that in mind, I think it would be best to focus on just the following two improvements for this PR. What do you think?
- Add the missing propsI (
value
,className
) toargTypes
- Convert to CSF3 format (See this comment)
Thanks, @t-hamano for the suggestions. I have addressed all the comments. Please let me if we can improve further. Screen.Recording.2024-12-11.at.16.17.33.mov |
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 PR! It looks almost good, but I'd like to give you some additional feedback 🙏
}, | ||
defaultValue: { summary: 'none' }, |
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.
}, | |
defaultValue: { summary: 'none' }, | |
}, |
I think this is a mistake in the README. The default value is undefined, not the string "none"
.
Besides this part, could you also remove this line below?
/** | ||
* Default story showing TextDecorationControl | ||
*/ | ||
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.
/** | |
* Default story showing TextDecorationControl | |
*/ | |
export const Default = { | |
export const Default = { |
There is only one story, so this comment is no longer necessary.
*/ | ||
export const Default = { | ||
render: function Template( { onChange, ...args } ) { | ||
const [ value, setValue ] = useState( 'none' ); |
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.
const [ value, setValue ] = useState( 'none' ); | |
const [ value, setValue ] = useState(); |
onChange={ ( newValue ) => { | ||
onChange( newValue ); | ||
setValue( newValue ); | ||
} } |
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.
onChange={ ( newValue ) => { | |
onChange( newValue ); | |
setValue( newValue ); | |
} } | |
onChange={ ( ...changeArgs ) => { | |
onChange( ...changeArgs ); | |
setValue( ...changeArgs ); | |
} } |
This change isn't required, but let's make it consistent with the other stories.
Part of #67165
What?
This PR improves the Storybook stories for the TextDecorationControl component in the block editor. It includes stories demonstrating different text-decoration states.
Why?
As part of the ongoing effort to improve component documentation and testing (tracked in #22891), we need comprehensive stories for all Block Editor components.
Testing Instructions
npm run storybook:dev
Screencast
text-decoration-control-story.mov