Make WordPress Core

Changeset 60892


Ignore:
Timestamp:
10/02/2025 11:53:19 PM (13 months ago)
Author:
andrewserong
Message:

Editor: introduce border.radiusSizes support in theme.json.

Adds site front end rendering logic for the border.radiusSizes border radius presets, as well as the required logic in WP_Theme_JSON and the style engine.

Props aaronrobertshaw, youknowriad, ramonopoly, poena, joen, jameskoster, richtabor, asafm7, fabiankaegy
Fixes #63799.

Location:
trunk
Files:
4 edited

Legend:

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

    r60809 r60892  
    127127         *              Updated the 'prevent_override' value for font size presets to use 'typography.defaultFontSizes'
    128128         *              and spacing size presets to use `spacing.defaultSpacingSizes`.
     129         * @since 6.9.0 Added `border.radiusSizes`.
    129130         * @var array
    130131         */
    … …  
    206207                        'properties'        => array( 'box-shadow' ),
    207208                ),
     209                array(
     210                        'path'              => array( 'border', 'radiusSizes' ),
     211                        'prevent_override'  => false,
     212                        'use_default_names' => false,
     213                        'value_key'         => 'size',
     214                        'css_vars'          => '--wp--preset--border-radius--$slug',
     215                        'classes'           => array(),
     216                        'properties'        => array( 'border-radius' ),
     217                ),
    208218        );
    209219
    … …  
    385395         * @since 6.6.0 Added support for 'dimensions.aspectRatios', 'dimensions.defaultAspectRatios',
    386396         *              'typography.defaultFontSizes', and 'spacing.defaultSpacingSizes'.
     397         * @since 6.9.0 Added support for `border.radiusSizes`.
    387398         * @var array
    388399         */
    … …  
    395406                ),
    396407                'border'                        => array(
    397                         'color'  => null,
    398                         'radius' => null,
    399                         'style'  => null,
    400                         'width'  => null,
     408                        'color'       => null,
     409                        'radius'      => null,
     410                        'radiusSizes' => null,
     411                        'style'       => null,
     412                        'width'       => null,
    401413                ),
    402414                'color'                         => array(
  • trunk/src/wp-includes/style-engine/class-wp-style-engine.php

    r59442 r60892  
    143143                                ),
    144144                                'path'          => array( 'border', 'radius' ),
     145                                'css_vars'      => array(
     146                                        'border-radius' => '--wp--preset--border-radius--$slug',
     147                                ),
    145148                        ),
    146149                        'style'  => array(
  • trunk/tests/phpunit/tests/style-engine/styleEngine.php

    r59199 r60892  
    3131         * @ticket 61720
    3232         * @ticket 62189
     33         * @ticket 63799
    3334         *
    3435         * @covers ::wp_style_engine_get_styles
    … …  
    172173                        ),
    173174
     175                        'inline_valid_border_radius_presets'           => array(
     176                                'block_styles'    => array(
     177                                        'border' => array(
     178                                                'radius' => array(
     179                                                        'topLeft'     => 'var:preset|border-radius|large',
     180                                                        'topRight'    => 'var:preset|border-radius|large',
     181                                                        'bottomLeft'  => 'var:preset|border-radius|large',
     182                                                        'bottomRight' => 'var:preset|border-radius|large',
     183                                                ),
     184                                        ),
     185                                ),
     186                                'options'         => null,
     187                                'expected_output' => array(
     188                                        'css'          => 'border-top-left-radius:var(--wp--preset--border-radius--large);border-top-right-radius:var(--wp--preset--border-radius--large);border-bottom-left-radius:var(--wp--preset--border-radius--large);border-bottom-right-radius:var(--wp--preset--border-radius--large);',
     189                                        'declarations' => array(
     190                                                'border-top-left-radius'     => 'var(--wp--preset--border-radius--large)',
     191                                                'border-top-right-radius'    => 'var(--wp--preset--border-radius--large)',
     192                                                'border-bottom-left-radius'  => 'var(--wp--preset--border-radius--large)',
     193                                                'border-bottom-right-radius' => 'var(--wp--preset--border-radius--large)',
     194                                        ),
     195                                ),
     196                        ),
     197
    174198                        'inline_valid_dimensions_style'                => array(
    175199                                'block_styles'    => array(
  • trunk/tests/phpunit/tests/theme/wpThemeJson.php

    r60731 r60892  
    398398         * @ticket 61630
    399399         * @ticket 61704
     400         * @ticket 63799
    400401         */
    401402        public function test_get_stylesheet() {
    … …  
    404405                                'version'  => WP_Theme_JSON::LATEST_SCHEMA,
    405406                                'settings' => array(
     407                                        'border'     => array(
     408                                                'radiusSizes' => array(
     409                                                        array(
     410                                                                'name' => 'Small',
     411                                                                'slug' => 'small',
     412                                                                'size' => '2px',
     413                                                        ),
     414                                                        array(
     415                                                                'name' => 'Medium',
     416                                                                'slug' => 'medium',
     417                                                                'size' => '4px',
     418                                                        ),
     419                                                ),
     420                                        ),
    406421                                        'color'      => array(
    407422                                                'text'      => 'value',
    … …  
    478493                                        'blocks'   => array(
    479494                                                'core/cover'        => array(
     495                                                        'border'     => array(
     496                                                                'radius' => 'var:preset|border-radius|small',
     497                                                        ),
    480498                                                        'dimensions' => array(
    481499                                                                'aspectRatio' => '16/9',
    … …  
    567585                );
    568586
    569                 $variables = ':root{--wp--preset--color--grey: grey;--wp--preset--gradient--custom-gradient: linear-gradient(135deg,rgba(0,0,0) 0%,rgb(0,0,0) 100%);--wp--preset--font-size--small: 14px;--wp--preset--font-size--big: 41px;--wp--preset--font-family--arial: Arial, serif;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}';
    570                 $styles    = ':where(body) { margin: 0; }.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }:where(.is-layout-flex){gap: 0.5em;}:where(.is-layout-grid){gap: 0.5em;}.is-layout-flow > .alignleft{float: left;margin-inline-start: 0;margin-inline-end: 2em;}.is-layout-flow > .alignright{float: right;margin-inline-start: 2em;margin-inline-end: 0;}.is-layout-flow > .aligncenter{margin-left: auto !important;margin-right: auto !important;}.is-layout-constrained > .alignleft{float: left;margin-inline-start: 0;margin-inline-end: 2em;}.is-layout-constrained > .alignright{float: right;margin-inline-start: 2em;margin-inline-end: 0;}.is-layout-constrained > .aligncenter{margin-left: auto !important;margin-right: auto !important;}.is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)){margin-left: auto !important;margin-right: auto !important;}body .is-layout-flex{display: flex;}.is-layout-flex{flex-wrap: wrap;align-items: center;}.is-layout-flex > :is(*, div){margin: 0;}body .is-layout-grid{display: grid;}.is-layout-grid > :is(*, div){margin: 0;}body{color: var(--wp--preset--color--grey);}a:where(:not(.wp-element-button)){background-color: #333;color: #111;}:root :where(.wp-element-button, .wp-block-button__link){box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.66);}:root :where(.wp-block-cover){min-height: unset;aspect-ratio: 16/9;}:root :where(.wp-block-group){background: var(--wp--preset--gradient--custom-gradient);border-radius: 10px;min-height: 50vh;padding: 24px;}:root :where(.wp-block-group a:where(:not(.wp-element-button))){color: #111;}:root :where(.wp-block-heading){color: #123456;}:root :where(.wp-block-heading a:where(:not(.wp-element-button))){background-color: #333;color: #111;font-size: 60px;}:root :where(.wp-block-media-text){text-align: center;}:root :where(.wp-block-post-date){color: #123456;}:root :where(.wp-block-post-date a:where(:not(.wp-element-button))){background-color: #777;color: #555;}:root :where(.wp-block-post-excerpt){column-count: 2;}:root :where(.wp-block-image){margin-bottom: 30px;}:root :where(.wp-block-image img, .wp-block-image .wp-block-image__crop-area, .wp-block-image .components-placeholder){border-top-left-radius: 10px;border-bottom-right-radius: 1em;}:root :where(.wp-block-image img, .wp-block-image .components-placeholder){filter: var(--wp--preset--duotone--custom-duotone);}';
     587                $variables = ':root{--wp--preset--color--grey: grey;--wp--preset--gradient--custom-gradient: linear-gradient(135deg,rgba(0,0,0) 0%,rgb(0,0,0) 100%);--wp--preset--font-size--small: 14px;--wp--preset--font-size--big: 41px;--wp--preset--font-family--arial: Arial, serif;--wp--preset--border-radius--small: 2px;--wp--preset--border-radius--medium: 4px;}.wp-block-group{--wp--custom--base-font: 16;--wp--custom--line-height--small: 1.2;--wp--custom--line-height--medium: 1.4;--wp--custom--line-height--large: 1.8;}';
     588                $styles    = ':where(body) { margin: 0; }.wp-site-blocks > .alignleft { float: left; margin-right: 2em; }.wp-site-blocks > .alignright { float: right; margin-left: 2em; }.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }:where(.is-layout-flex){gap: 0.5em;}:where(.is-layout-grid){gap: 0.5em;}.is-layout-flow > .alignleft{float: left;margin-inline-start: 0;margin-inline-end: 2em;}.is-layout-flow > .alignright{float: right;margin-inline-start: 2em;margin-inline-end: 0;}.is-layout-flow > .aligncenter{margin-left: auto !important;margin-right: auto !important;}.is-layout-constrained > .alignleft{float: left;margin-inline-start: 0;margin-inline-end: 2em;}.is-layout-constrained > .alignright{float: right;margin-inline-start: 2em;margin-inline-end: 0;}.is-layout-constrained > .aligncenter{margin-left: auto !important;margin-right: auto !important;}.is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)){margin-left: auto !important;margin-right: auto !important;}body .is-layout-flex{display: flex;}.is-layout-flex{flex-wrap: wrap;align-items: center;}.is-layout-flex > :is(*, div){margin: 0;}body .is-layout-grid{display: grid;}.is-layout-grid > :is(*, div){margin: 0;}body{color: var(--wp--preset--color--grey);}a:where(:not(.wp-element-button)){background-color: #333;color: #111;}:root :where(.wp-element-button, .wp-block-button__link){box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.66);}:root :where(.wp-block-cover){min-height: unset;aspect-ratio: 16/9;border-radius: var(--wp--preset--border-radius--small);}:root :where(.wp-block-group){background: var(--wp--preset--gradient--custom-gradient);border-radius: 10px;min-height: 50vh;padding: 24px;}:root :where(.wp-block-group a:where(:not(.wp-element-button))){color: #111;}:root :where(.wp-block-heading){color: #123456;}:root :where(.wp-block-heading a:where(:not(.wp-element-button))){background-color: #333;color: #111;font-size: 60px;}:root :where(.wp-block-media-text){text-align: center;}:root :where(.wp-block-post-date){color: #123456;}:root :where(.wp-block-post-date a:where(:not(.wp-element-button))){background-color: #777;color: #555;}:root :where(.wp-block-post-excerpt){column-count: 2;}:root :where(.wp-block-image){margin-bottom: 30px;}:root :where(.wp-block-image img, .wp-block-image .wp-block-image__crop-area, .wp-block-image .components-placeholder){border-top-left-radius: 10px;border-bottom-right-radius: 1em;}:root :where(.wp-block-image img, .wp-block-image .components-placeholder){filter: var(--wp--preset--duotone--custom-duotone);}';
    571589                $presets   = '.has-grey-color{color: var(--wp--preset--color--grey) !important;}.has-grey-background-color{background-color: var(--wp--preset--color--grey) !important;}.has-grey-border-color{border-color: var(--wp--preset--color--grey) !important;}.has-custom-gradient-gradient-background{background: var(--wp--preset--gradient--custom-gradient) !important;}.has-small-font-size{font-size: var(--wp--preset--font-size--small) !important;}.has-big-font-size{font-size: var(--wp--preset--font-size--big) !important;}.has-arial-font-family{font-family: var(--wp--preset--font-family--arial) !important;}';
    572590                $all       = $variables . $styles . $presets;
Note: See TracChangeset for help on using the changeset viewer.