-
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
Block Editor: Add new TextAlignmentControl
component
#60841
Conversation
Size Change: +361 B (0%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
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. |
Seems valid insofar as it matches existing patterns for block justification controls. On the radar is to use this, or a component like this, to allow a global text justification, including allowing justified text. I wonder if this component should be used for that? If yes, I can update the mockup, but also to be aware then that this control should be able to include the justified text toggle. |
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 putting this initial step together @t-hamano 👍
This is looking pretty good so far. I'd like to wait for a quick sanity check from our design gurus first though to make sure they are happy with the direction.
Update: Should of refreshed before submitting the review, we already have it 🚀
The component tests well for me in Storybook and does appear to mostly follow the existing components for text decoration and transform.
Screen.Recording.2024-04-18.at.4.06.09.PM.mp4
I think we might need to tweak the component name, and some of the wording, of docblock comments etc. "Align" is a verb so doesn't make as much sense in some situations.
This is probably why the AlignmentControl
is named as such. What do you think of renaming this component TextAlignmentControl
?
packages/block-editor/src/components/text-align-control/index.js
Outdated
Show resolved
Hide resolved
Makes sense, updated by 6c69ce8 👍 |
Personally, I find it a bit confusing to indicate text However, since the
|
As an alternative approach, I used |
Thanks for iterating on this @t-hamano, I'll give it another review early next week.
This isn't quite what I meant, or had in mind. It does reduce the CSS for this component but the other two components, text decoration and text transform, have that same CSS as well and the same basic structure. Take this naming with a grain of salt, but what I was proposing was more like:
|
@aaronrobertshaw Thank you for explaining in detail! I added a new
Also, while working, I realized that the style sheet for 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.
Looking good! Thanks for refactoring the existing controls, that's a nice simplification.
I think WritingModeControl
is broken because controls
needs to pass label
instead of name
.
Other than that I've left only minor feedback.
packages/block-editor/src/components/segmented-text-control/index.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/text-alignment-control/README.md
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/text-alignment-control/index.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/text-alignment-control/index.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/writing-mode-control/index.js
Outdated
Show resolved
Hide resolved
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 your patience and continued effort here @t-hamano 🙇
I think this PR is moving in the right direction. There's some minor stuff we can clean up but all in all, it's getting close.
packages/block-editor/src/components/segmented-text-control/index.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/segmented-text-control/index.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/text-alignment-control/README.md
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/text-alignment-control/README.md
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/text-alignment-control/README.md
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/text-alignment-control/stories/index.story.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/text-alignment-control/style.scss
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/text-decoration-control/index.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/text-transform-control/index.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/writing-mode-control/index.js
Outdated
Show resolved
Hide resolved
Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com>
Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com>
Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com>
Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com>
Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com>
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.
Nice work 👍
@aaronrobertshaw @noisysocks Thank you for your review! As a next step, I will work on incorporating this UI into the Global Styles for WP6.6. At that time, I would like to consider whether or not to make this component public. |
TextAlignControl
componentTextAlignmentControl
component
Just before merging, I noticed that this component has a public README, even though it is private 😅 Do you think the README should also be removed? |
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 refinements here @t-hamano 🙇
I think we still need to tidy up some of the wording here with regards to"controls" vs "options". With the latest updates we now are a bit inconsistent in the code.
Sorry to be the one holding up this PR landing 😅
Do you think the README should also be removed?
Yeah, I believe the current process is to avoid documenting experimental or private components. It's a shame we don't have a mechanism to hide docs or make them private too.
packages/block-editor/src/components/segmented-text-control/index.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/segmented-text-control/index.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/segmented-text-control/index.js
Outdated
Show resolved
Hide resolved
@aaronrobertshaw Thank you for the additional review 🙇
|
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 persistence here @t-hamano 👍
Sorry, this PR got a little more complicated than it started out but I think we've arrived at a good place with it.
Each of the controls are working well for me in the editor. There's just one small thing that was missed with the storybook example for the new control. Once that's updated this should be good to merge.
packages/block-editor/src/components/text-alignment-control/stories/index.story.js
Outdated
Show resolved
Hide resolved
Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com>
@aaronrobertshaw Thanks for the review! I fixed the storybook control name. Since I have confirmed that it works correctly on Storybook, I would like to merge it 👍 |
Go for it! Thanks again for the hard work here 👍 |
* Block Editor: Add new `TextAlignControl` component * Rename `TextAlignControl` to `TextAlignmentControl` * Replate `align` with `alignment` * Use components to reduce CSS writing * Refactor using new SegmentedTextControl component * Make a component private * SegmentedTextControl: Update JSDoc parameters * TextAlignmentControl: Update JSDoc parameter * TextAlignmentControl: Cache valid controls filtering * WritingModeControl: fix control property * TextAlignmentControl: Allow `justify` as an allowed value * TextAlignmentControl: Update docs * SegmentedTextControl: Update description Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> * TextAlignmentControl: Update readme Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> * TextAlignmentControl: Fix JSDoc Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> * TextAlignmentControl: Update readme Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> * TextAlignmentControl: Update readme Co-authored-by: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> * SegmentedTextControl: Update JSDoc * TextAlignmentcontrol: remove unecessary `unlock()` * TextAlignmentControl: Remove unnecessary styles * Restor default component classname * Rename `control(s)` to `option(s)` * TextAlignmentControl: Remove README * TextAlignmentControl: Fix control name --------- Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org> Co-authored-by: noisysocks <noisysocks@git.wordpress.org> Co-authored-by: jasmussen <joen@git.wordpress.org>
Part of #60762
What?
This PR adds a new
TextAlignControl
in preparation for adding block-level text alignment UI to the global styles.Why?
Adding UI to the global styles in one PR would involve too many changes, so this PR focuses only on adding new components.
A similar component, the AlignmentControl, already exists, but since this component is intended to be used in a toolbar, I think it is necessary to create a new component specifically for it.
How?
Testing Instructions
npm run storybook:dev
and accesshttp://localhost:50240/?path=/story/blockeditor-textaligncontrol--default
.onChange
action is called correctly when the button is clicked.Screenshots or screencast
82491afcfe10144db4064d1df77ddf1c.mp4