-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Layout: Add default fallback gap value in block.json, and set to 2em for Columns blocks #41098
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
Changes from all commits
56152c6
a9dd741
a2cc158
426f67a
e779a9f
7774b7c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -11,6 +11,7 @@ import { | |||
| arrowDown, | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about flow.js? no fallback support there?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed that too when I went to work on this feature — the Flow layout currently doesn't use any fallback value at all, so I didn't inject one where there isn't one already (both in
It was the Flex layout that currently has a But, please do let me know if I missed something here! 🙂 |
||||
| } from '@wordpress/icons'; | ||||
| import { Button, ToggleControl, Flex, FlexItem } from '@wordpress/components'; | ||||
| import { getBlockSupport } from '@wordpress/blocks'; | ||||
|
|
||||
| /** | ||||
| * Internal dependencies | ||||
|
|
@@ -109,14 +110,21 @@ export default { | |||
| save: function FlexLayoutStyle( { selector, layout, style, blockName } ) { | ||||
| const { orientation = 'horizontal' } = layout; | ||||
| const blockGapSupport = useSetting( 'spacing.blockGap' ); | ||||
| const fallbackValue = | ||||
| getBlockSupport( blockName, [ | ||||
| 'spacing', | ||||
| 'blockGap', | ||||
| '__experimentalDefault', | ||||
| ] ) || '0.5em'; | ||||
|
|
||||
| const hasBlockGapStylesSupport = blockGapSupport !== null; | ||||
| // If a block's block.json skips serialization for spacing or spacing.blockGap, | ||||
| // don't apply the user-defined value to the styles. | ||||
| const blockGapValue = | ||||
| style?.spacing?.blockGap && | ||||
| ! shouldSkipSerialization( blockName, 'spacing', 'blockGap' ) | ||||
| ? getGapCSSValue( style?.spacing?.blockGap, '0.5em' ) | ||||
| : 'var( --wp--style--block-gap, 0.5em )'; | ||||
| ? getGapCSSValue( style?.spacing?.blockGap, fallbackValue ) | ||||
| : `var( --wp--style--block-gap, ${ fallbackValue } )`; | ||||
| const justifyContent = | ||||
| justifyContentMap[ layout.justifyContent ] || | ||||
| justifyContentMap.left; | ||||
|
|
@@ -143,7 +151,7 @@ export default { | |||
| ${ appendSelectors( selector ) } { | ||||
| display: flex; | ||||
| flex-wrap: ${ flexWrap }; | ||||
| gap: ${ hasBlockGapStylesSupport ? blockGapValue : '0.5em' }; | ||||
| gap: ${ hasBlockGapStylesSupport ? blockGapValue : fallbackValue }; | ||||
| ${ orientation === 'horizontal' ? rowOrientation : columnOrientation } | ||||
| } | ||||
|
|
||||
|
|
||||
Uh oh!
There was an error while loading. Please reload this page.