Make WordPress Core


Ignore:
Timestamp:
12/19/2022 08:53:15 PM (4 years ago)
Author:
hellofromTonya
Message:

Themes: Adds outline CSS properties support in theme.json.

Adds the ability to define outline CSS properties for elements and blocks within theme.json to render outline-color, outline-offset, outline-style, and outline-width styles.

Originally developed and tested in ​Gutenberg PR 43526.

Props onemaggie, hellofromTonya, audrasjb, ironprogrammer.
Fixes #57354.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/theme/wpThemeJson.php

    r54889 r55008  
    40914091                );
    40924092        }
     4093
     4094        /**
     4095         * @ticket 57354
     4096         */
     4097        public function test_get_stylesheet_returns_outline_styles() {
     4098                $theme_json = new WP_Theme_JSON(
     4099                        array(
     4100                                'version' => WP_Theme_JSON::LATEST_SCHEMA,
     4101                                'styles'  => array(
     4102                                        'elements' => array(
     4103                                                'button' => array(
     4104                                                        'outline' => array(
     4105                                                                'offset' => '3px',
     4106                                                                'width'  => '3px',
     4107                                                                'style'  => 'dashed',
     4108                                                                'color'  => 'red',
     4109                                                        ),
     4110                                                        ':hover'  => array(
     4111                                                                'outline' => array(
     4112                                                                        'offset' => '3px',
     4113                                                                        'width'  => '3px',
     4114                                                                        'style'  => 'solid',
     4115                                                                        'color'  => 'blue',
     4116                                                                ),
     4117                                                        ),
     4118                                                ),
     4119                                        ),
     4120                                ),
     4121                        )
     4122                );
     4123
     4124                $base_styles = '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; }';
     4125
     4126                $element_styles = '.wp-element-button, .wp-block-button__link{outline-color: red;outline-offset: 3px;outline-style: dashed;outline-width: 3px;}.wp-element-button:hover, .wp-block-button__link:hover{outline-color: blue;outline-offset: 3px;outline-style: solid;outline-width: 3px;}';
     4127
     4128                $expected = $base_styles . $element_styles;
     4129                $this->assertSame( $expected, $theme_json->get_stylesheet() );
     4130        }
    40934131}
Note: See TracChangeset for help on using the changeset viewer.