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 WritingModeControl story #67343

Merged

Conversation

Sukhendu2002
Copy link
Contributor

@Sukhendu2002 Sukhendu2002 commented Nov 27, 2024

Part of #67165

What?

This PR will add stories for WritingModeControl component in the Storybook.

Testing Instructions

  1. Run npm run storybook:dev
  2. Open the storybook on http://localhost:50240/
  3. Check the WritingModeControl stories.

Screenshots or screencast

Screen.Recording.2024-11-27.at.4.10.10.PM.mov

@Sukhendu2002 Sukhendu2002 marked this pull request as ready for review November 27, 2024 11: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: Sukhendu2002 <[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
@miminari miminari requested review from carolinan and t-hamano and removed request for ellatrix November 29, 2024 00:18
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!

In order to move this PR forward, I would like to suggest two points that I think are particularly important.

1 - Only one story is needed: I think the only difference between the Default and Vertical stories is the default value. In this case, I think an additional story (Vertical) is unnecessary.

2 - Don't make the value prop controllable: In the current implementation, nothing happens when you press the component's button after changing the value prop.

b67d787f2e6b0d17f55218fbc36fe20e.mp4

How about implementing it in control mode as follows?

export const Default = {
	render: function Template( { onChange, ...args } ) {
		const [ value, setValue ] = useState();
		return (
			<WritingModeControl
				{ ...args }
				onChange={ ( ...changeArgs ) => {
					onChange( ...changeArgs );
					setValue( ...changeArgs );
				} }
				value={ value }
			/>
		);
	},
};

@Sukhendu2002
Copy link
Contributor Author

Hi @t-hamano, Thanks for the detailed feedback!

I’ve updated the story:

  • The Default and Vertical stories have been combined into a single story, as the difference was only the default value.
  • The component now manages the value internally using useState.

Please let me know if there’s anything else that needs adjustment!

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 update! Overall it looks good, but I'd like to suggest two additional illustrations at the end.

@Sukhendu2002
Copy link
Contributor Author

Hi @t-hamano, Thanks for the feedback! I’ve addressed both points.

@Sukhendu2002 Sukhendu2002 requested a review from t-hamano December 9, 2024 07:00
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.

LGTM! Works as expected 👍

8a3b9f256639d65386dad23e24632256.mp4

@t-hamano t-hamano merged commit 53ed803 into WordPress:trunk Dec 10, 2024
61 of 63 checks passed
@github-actions github-actions bot added this to the Gutenberg 19.9 milestone Dec 10, 2024
yogeshbhutkar pushed a commit to yogeshbhutkar/gutenberg that referenced this pull request Dec 18, 2024
* Storybook: Add WritingModeControl story

* Enhance WritingModeControl usability and simplify structure

* Simplify WritingModeControl story implementation

Co-authored-by: Sukhendu2002 <[email protected]>
Co-authored-by: t-hamano <[email protected]>
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