diff --git a/lib/block-supports/layout.php b/lib/block-supports/layout.php index 1af4a7f842c4d..c418f04c02116 100644 --- a/lib/block-supports/layout.php +++ b/lib/block-supports/layout.php @@ -39,8 +39,9 @@ function gutenberg_get_layout_style( $selector, $layout, $has_block_gap_support $style = ''; if ( 'default' === $layout_type ) { - $content_size = isset( $layout['contentSize'] ) ? $layout['contentSize'] : null; - $wide_size = isset( $layout['wideSize'] ) ? $layout['wideSize'] : null; + $content_size = isset( $layout['contentSize'] ) ? $layout['contentSize'] : null; + $wide_size = isset( $layout['wideSize'] ) ? $layout['wideSize'] : null; + $outer_padding = isset( $layout['outerPadding'] ) ? $layout['outerPadding'] : array(); $all_max_width_value = $content_size ? $content_size : $wide_size; $wide_max_width_value = $wide_size ? $wide_size : $content_size; @@ -52,14 +53,26 @@ function gutenberg_get_layout_style( $selector, $layout, $has_block_gap_support $style = ''; if ( $content_size || $wide_size ) { - $style = "$selector > * {"; + $style = "$selector {"; + $style .= sprintf( + 'padding: %s %s %s %s', + isset( $outer_padding['top'] ) ? $outer_padding['top'] : 0, + isset( $outer_padding['right'] ) ? $outer_padding['right'] : 0, + isset( $outer_padding['bottom'] ) ? $outer_padding['bottom'] : 0, + isset( $outer_padding['left'] ) ? $outer_padding['left'] : 0 + ); + $style .= '}'; + $style .= "$selector > * {"; $style .= 'max-width: ' . esc_html( $all_max_width_value ) . ';'; $style .= 'margin-left: auto !important;'; $style .= 'margin-right: auto !important;'; $style .= '}'; - $style .= "$selector > .alignwide { max-width: " . esc_html( $wide_max_width_value ) . ';}'; - $style .= "$selector .alignfull { max-width: none; }"; + $style .= "$selector .alignfull {"; + $style .= 'max-width: none;'; + $style .= isset( $outer_padding['left'] ) ? sprintf( 'margin-left: calc( -1 * %s ) !important;', $outer_padding['left'] ) : ''; + $style .= isset( $outer_padding['right'] ) ? sprintf( 'margin-right: calc( -1 * %s ) !important;', $outer_padding['right'] ) : ''; + $style .= '}'; } $style .= "$selector .alignleft { float: left; margin-right: 2em; }"; diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php index f84696e019d23..57650aa06ac99 100644 --- a/lib/class-wp-theme-json-gutenberg.php +++ b/lib/class-wp-theme-json-gutenberg.php @@ -100,8 +100,9 @@ class WP_Theme_JSON_Gutenberg { ), 'custom' => null, 'layout' => array( - 'contentSize' => null, - 'wideSize' => null, + 'contentSize' => null, + 'wideSize' => null, + 'outerPadding' => null, ), 'spacing' => array( 'blockGap' => null, diff --git a/packages/block-editor/src/layouts/flow.js b/packages/block-editor/src/layouts/flow.js index fd83cf822c3e9..9408e73f6fed6 100644 --- a/packages/block-editor/src/layouts/flow.js +++ b/packages/block-editor/src/layouts/flow.js @@ -106,13 +106,19 @@ export default { return null; }, save: function DefaultLayoutStyle( { selector, layout = {} } ) { - const { contentSize, wideSize } = layout; + const { contentSize, wideSize, outerPadding } = layout; const blockGapSupport = useSetting( 'spacing.blockGap' ); const hasBlockGapStylesSupport = blockGapSupport !== null; let style = !! contentSize || !! wideSize ? ` + ${ appendSelectors( selector ) } { + padding: ${ outerPadding?.top || 0 } ${ outerPadding?.right || 0 } ${ + outerPadding?.bottom || 0 + } ${ outerPadding?.left || 0 }; + } + ${ appendSelectors( selector, '> *' ) } { max-width: ${ contentSize ?? wideSize }; margin-left: auto !important; @@ -125,6 +131,8 @@ export default { ${ appendSelectors( selector, '> [data-align="full"]' ) } { max-width: none; + margin-left: calc( -1 * ${ outerPadding.left || 0 } ) !important; + margin-right: calc( -1 * ${ outerPadding.right || 0 } ) !important; } ` : ''; diff --git a/packages/block-library/src/cover/style.scss b/packages/block-library/src/cover/style.scss index 0b29c23c595b7..a13ae67594714 100644 --- a/packages/block-library/src/cover/style.scss +++ b/packages/block-library/src/cover/style.scss @@ -4,7 +4,6 @@ background-size: cover; background-position: center center; min-height: 430px; - width: 100%; display: flex; justify-content: center; align-items: center;