Block Spacing UI: Respect axial support when a single value is defined#65306
Closed
t-hamano wants to merge 1 commit into
Closed
Block Spacing UI: Respect axial support when a single value is defined#65306t-hamano wants to merge 1 commit into
t-hamano wants to merge 1 commit into
Conversation
|
Size Change: +9 B (0%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
39c3169 to
ad3348f
Compare
This was referenced Sep 17, 2024
Contributor
Author
|
Closing this PR to move forward with #66783. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
This PR fixes the issues discovered in this comment:
Why?
Whether the UI, i.e. the
SpacingSizesControl, supports the axial gap is evaluated using both thesidesprop and thevaluesprop:gutenberg/packages/block-editor/src/components/spacing-sizes-control/index.js
Line 48 in 1664022
If a theme defines a single string as a block gap, the
splitGapValue()function converts it to an object with only atopproperty:gutenberg/packages/block-editor/src/components/global-styles/dimensions-panel.js
Lines 150 to 157 in 1664022
As a result, a SpacingSizeControl component that receives these props will assume that the axial gap is not supported, even if the block itself supports it.
How?
splitGapValue()function so that if the argument is a string, it converts it to an object with explicittop,right,bottom, andleftproperties.topproperty from this object and pass it as thevaluesprop.Testing Instructions
Define a theme.json for each scenario and check out the block spacing UI in the global styles. This PR fixes the second and fourth scenarios.
Has Spacing Size Presets
1. The theme does not have block gap styles defined
{ "version": 3, "settings": { "appearanceTools": true, "layout": { "contentSize": "840px" } } }As before, whether a block supports the axial gap is respected.
Columns:
Group:
2. The theme defines the block gap for blocks
{ "version": 3, "settings": { "appearanceTools": true, "layout": { "contentSize": "840px" } }, "styles": { "blocks": { "core/columns": { "spacing": { "blockGap": "2em" } }, "core/group": { "spacing": { "blockGap": "2em" } } } } }This is the scenario that this PR solves. Blocks that support the axial gap (such as the Columns block) will show axial controls instead of a single control if the string is defined in theme.json.
No Spacing Size Presets
3. The theme does not have block gap styles defined
{ "version": 3, "settings": { "appearanceTools": true, "layout": { "contentSize": "840px" }, "spacing": { "defaultSpacingSizes": false, "spacingSizes": [] } } }As before, whether a block supports the axial gap is respected.
Columns:
Group:
4. The theme defines the block gap for blocks
{ "version": 3, "settings": { "appearanceTools": true, "layout": { "contentSize": "840px" }, "spacing": { "defaultSpacingSizes": false, "spacingSizes": [] } }, "styles": { "blocks": { "core/columns": { "spacing": { "blockGap": "2em" } }, "core/group": { "spacing": { "blockGap": "2em" } } } } }Note
Note that this is true for the trunk branch as well, but this PR doesn't yet support axis-defined strings (e.g.
"blockGap": "1em 2em"). This may be addressed in a follow-up.