Skip to content

Commit

Permalink
Try implementing partially in editor
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewserong committed May 9, 2022
1 parent e2d969d commit 69893f5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/block-supports/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function gutenberg_get_layout_style( $selector, $layout, $has_block_gap_support
$gap_column = isset( $gap_value['left'] ) ? $gap_value['left'] : '0.5em';
$gap_value = $gap_row === $gap_column ? $gap_row : $gap_row . ' ' . $gap_column;
}
$gap_style = $gap_value && ! $should_skip_gap_serialization ? $gap_value : 'var( --wp--style--block-gap, 0.5em )';
$gap_style = $gap_value && ! $should_skip_gap_serialization ? $gap_value : 'var( --wp--style--block-gap, 0.5em )'; // TODO: If there's a value set at the block level in theme.json, how do we ensure this value doesn't override that?
$style .= "gap: $gap_style;";
} else {
$style .= 'gap: 0.5em;';
Expand Down
6 changes: 5 additions & 1 deletion packages/block-editor/src/hooks/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,10 @@ export const withLayoutStyles = createHigherOrderComponent(
const usedLayout = layout?.inherit
? defaultThemeLayout
: layout || defaultBlockLayout || {};
const layoutType = usedLayout?.type || 'flow';
const className = classnames( props?.className, {
[ `wp-container-${ id }` ]: shouldRenderLayoutStyles,
[ `is-layout-${ layoutType }` ]: true,
} );

return (
Expand All @@ -223,7 +225,9 @@ export const withLayoutStyles = createHigherOrderComponent(
createPortal(
<LayoutStyle
blockName={ name }
selector={ `.wp-container-${ id }` }
selector={ `${
props?.className || '' // TODO: It seems the block className isn't really available here.
}.wp-container-${ id }` }
layout={ usedLayout }
style={ attributes?.style }
/>,
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/layouts/flex.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default {
style?.spacing?.blockGap &&
! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )
? getGapCSSValue( style?.spacing?.blockGap, '0.5em' )
: 'var( --wp--style--block-gap, 0.5em )';
: 'var( --wp--style--block-gap, 0.5em )'; // TODO: If there's a value set at the block level in theme.json, how do we ensure this value doesn't override that?
const justifyContent =
justifyContentMap[ layout.justifyContent ] ||
justifyContentMap.left;
Expand Down

0 comments on commit 69893f5

Please sign in to comment.