Skip to content
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

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from

Conversation

himanshupathak95
Copy link
Contributor

@himanshupathak95 himanshupathak95 commented Nov 27, 2024

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

  • Start Storybook by running npm run storybook:dev
  • Open Storybook at http://localhost:50240/
  • Navigate to "BlockEditor/TextDecorationControl" in the Storybook sidebar
  • Test the following stories:
    • Default (no decoration)
    • WithUnderline (underline decoration)
    • WithStrikethrough (strikethrough decoration)
    • WithCustomClass (custom class name)

Screencast

text-decoration-control-story.mov

@himanshupathak95 himanshupathak95 marked this pull request as ready for review November 27, 2024 08:33
Copy link

github-actions bot commented Nov 27, 2024

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: himanshupathak95 <[email protected]>
Co-authored-by: t-hamano <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@akasunil akasunil added [Type] Developer Documentation Documentation for developers Storybook Storybook and its stories for components labels Nov 28, 2024
@himanshupathak95 himanshupathak95 changed the title Storybook: Add stories for the text-decoration-control component Storybook: Add stories for the TextDecorationControl component Nov 28, 2024
@miminari miminari requested review from mirka and t-hamano and removed request for ellatrix November 29, 2024 00:13
Copy link
Contributor

@t-hamano t-hamano left a 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) to argTypes
  • Convert to CSF3 format (See this comment)

@himanshupathak95
Copy link
Contributor Author

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

Copy link
Contributor

@t-hamano t-hamano left a 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 🙏

Comment on lines +29 to +30
},
defaultValue: { summary: 'none' },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
},
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?

https://github.com/WordPress/gutenberg/blame/widgets/fix/inserter-open/packages/block-editor/src/components/text-decoration-control/README.md#L31

Comment on lines +55 to +58
/**
* Default story showing TextDecorationControl
*/
export const Default = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* 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' );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const [ value, setValue ] = useState( 'none' );
const [ value, setValue ] = useState();

Comment on lines +64 to +67
onChange={ ( newValue ) => {
onChange( newValue );
setValue( newValue );
} }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Storybook Storybook and its stories for components [Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants