Make WordPress Core


Ignore:
Timestamp:
05/29/2024 05:14:00 AM (22 months ago)
Author:
isabel_brison
Message:

Editor: improve consistency of root padding.

Improve the behaviour of global padding when useRootPaddingAwareAlignments is enabled in theme.json to be more consistent across blocks, templates and patterns.

Props richtabor, isabel_brison, andrewserong.
Fixes #61304.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-theme-json.php

    r58222 r58226  
    26892689     *
    26902690     * @since 6.1.0
    2691      * @since 6.6.0 Use `ROOT_CSS_PROPERTIES_SELECTOR` for CSS custom properties.
     2691     * @since 6.6.0 Use `ROOT_CSS_PROPERTIES_SELECTOR` for CSS custom properties and improved consistency of root padding rules.
    26922692     *
    26932693     * @param string $selector The root node selector.
     
    27092709            $wide_size    = isset( $settings['layout']['wideSize'] ) ? $settings['layout']['wideSize'] : $settings['layout']['contentSize'];
    27102710            $wide_size    = static::is_safe_css_declaration( 'max-width', $wide_size ) ? $wide_size : 'initial';
    2711             $css .= static::ROOT_CSS_PROPERTIES_SELECTOR . ' { --wp--style--global--content-size: ' . $content_size . ';';
    2712             $css .= '--wp--style--global--wide-size: ' . $wide_size . '; }';
     2711            $css         .= static::ROOT_CSS_PROPERTIES_SELECTOR . ' { --wp--style--global--content-size: ' . $content_size . ';';
     2712            $css         .= '--wp--style--global--wide-size: ' . $wide_size . '; }';
    27132713        }
    27142714
     
    27282728            // Right and left padding are applied to the first container with `.has-global-padding` class.
    27292729            $css .= '.has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }';
    2730             // Nested containers with `.has-global-padding` class do not get padding.
    2731             $css .= '.has-global-padding :where(.has-global-padding:not(.wp-block-block)) { padding-right: 0; padding-left: 0; }';
    27322730            // Alignfull children of the container with left and right padding have negative margins so they can still be full width.
    27332731            $css .= '.has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }';
    2734             // The above rule is negated for alignfull children of nested containers.
    2735             $css .= '.has-global-padding :where(.has-global-padding:not(.wp-block-block)) > .alignfull { margin-right: 0; margin-left: 0; }';
    2736             // Some of the children of alignfull blocks without content width should also get padding: text blocks and non-alignfull container blocks.
    2737             $css .= '.has-global-padding > .alignfull:where(:not(.has-global-padding):not(.is-layout-flex):not(.is-layout-grid)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }';
    2738             // The above rule also has to be negated for blocks inside nested `.has-global-padding` blocks.
    2739             $css .= '.has-global-padding :where(.has-global-padding) > .alignfull:where(:not(.has-global-padding)) > :where([class*="wp-block-"]:not(.alignfull):not([class*="__"]),p,h1,h2,h3,h4,h5,h6,ul,ol) { padding-right: 0; padding-left: 0; }';
     2732            // Nested children of the container with left and right padding that are not wide or full aligned do not get padding.
     2733            $css .= '.has-global-padding :where(.has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) { padding-right: 0; padding-left: 0; }';
     2734            // Nested children of the container with left and right padding that are not wide or full aligned do not get negative margin applied.
     2735            $css .= '.has-global-padding :where(.has-global-padding:not(.wp-block-block, .alignfull, .alignwide)) > .alignfull { margin-left: 0; margin-right: 0; }';
    27402736        }
    27412737
Note: See TracChangeset for help on using the changeset viewer.