-
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
Buttons block: overhaul alignment/justification controls #23168
Conversation
Size Change: +718 B (0%) Total Size: 1.21 MB
ℹ️ View Unchanged
|
e861e17
to
a1d12c5
Compare
51cec7c
to
e9cdc50
Compare
Remaining things that need to be addressed for this PR to be ready:
|
fffa5f9
to
5749cc1
Compare
5749cc1
to
9637656
Compare
9637656
to
aba0d5a
Compare
0318405
to
63d897a
Compare
c9e899f
to
e17916b
Compare
Thanks for having a look @geriux ! @ZebulanStanphill Do you mind delaying this PR a bit? We need to find some time for someone to help on that task if we want to avoid this (non-fatal) regression on mobile. |
@Tug I'm fine with delaying it. I'd prefer to get it in for WP 5.6, but I understand that it would be best to have someone get a mobile implementation ready first. |
Hey, @ZebulanStanphill 👋 just drafted a PR from your branch adding support for mobile. |
67463b4
to
225ff95
Compare
7b3c4fe
to
9e5a534
Compare
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.
Approving from a web point of view. This is working really nicely in my testing! Thanks for persevering, @ZebulanStanphill, and for the mobile implementation @geriux.
packages/block-library/src/buttons/content-justification-dropdown.js
Outdated
Show resolved
Hide resolved
…tificationDropdown (#26166)
9e5a534
to
4fb29cb
Compare
Rebased after the changes in #26380. Thanks for all your help getting this PR polished and completed, everyone! The end-to-end test failures are unrelated, so I'm going to go ahead and merge now. |
PR WordPress#23168 overhauls alignment controls on the Buttons container and allows for full width. For a Button inside a very large container, in order to be set correctly to 100% it must be able to exceed any configured max-width. This commit does not remove the max-width for any button that does NOT have a custom width percentage selected. This is so that default buttons continue to be sized as they normally would.
* Add sidebar width selector for Button block Initial commit adding a width option for the Button block with options at 25, 50, 75, 100% widths. By default none are applied and the button is sized by its content. * Persist width changes * Apply styling through class name rather than inline * Clean up CSS * Allow toggling a custom width off A width selection can now be toggled off by clicking the already selected option. * Update InspectorControls to use sentence case Co-authored-by: Miguel Fonseca <miguelcsf@gmail.com> * Remove max width from buttons with custom width set PR #23168 overhauls alignment controls on the Buttons container and allows for full width. For a Button inside a very large container, in order to be set correctly to 100% it must be able to exceed any configured max-width. This commit does not remove the max-width for any button that does NOT have a custom width percentage selected. This is so that default buttons continue to be sized as they normally would. * Apply `has-custom-width` class on frontend Fixes a bug where the inner button was not being set correctly to 100% width on the frontend, due to the missing classname.` Co-authored-by: Staci Cooper <staci@Stacis-MacBook-Pro.local> Co-authored-by: Miguel Fonseca <miguelcsf@gmail.com>
Purpose
Replaces #23133.
This PR does two things:
The left and right options (which, as a reminder, are float options) were not really useful at all for the Buttons block, and the center alignment option is something that probably should've been handled by content justification options from the start.
The left/right content justification options actually give the effect that some may have expected the "block alignment" left and right options to do. I suspect that adding the "block alignment" controls to the Buttons block in the first place was a mistake caused by someone thinking that they were content alignment controls, hence the existing
text-align: center
style being applied to Buttons blocks with thealigncenter
class in order to make the center-block-alignment option act like a center-content-alignment option.The Navigation block does have support for the wide and full "block alignment" options, and I think there are actually use-cases for those options, so this PR adds support for those two to the Buttons block. If desired, I could remove those options, and thus remove the
align
attribute from the block entirely.This PR was motivated by this discussion. I initially tried to do all this in multiple PRs, but I realized that doing so would require multiple deprecations if I didn't get certain changes in soon enough. For that reason, I have opted for a single PR to make all the necessary changes at once so that the proper controls are added at the same time that the confusing weird ones are removed.
Deprecation handling
Buttons block with a center-alignment will also be converted to use content alignment, and in this case the end result will look identical.
Existing Buttons blocks with a left/right float alignment will have that float alignment removed and replaced with left or right content justification, since that is what most people thought the options would do anyway. In fact, the editor styles were (confusingly) already applying some content alignment styles, though they weren't noticeable since the
alignxxx
classes were also applying float behavior.The existing front-end styles for block alignment are retained for compatibility with already-published posts that have yet to be reopened in the editor.
How has this been tested?
I tested to make sure existing Buttons blocks using the deprecated align options are converted to the new content justification system as described earlier.
Checklist: