Skip to content

Commit

Permalink
Global styles: background UI controls (#59454)
Browse files Browse the repository at this point in the history
* Refactor global styles and refactor existing background components
* Porting over existing hook code to shared, global styles component.
* Move tests, move styles, remove duplicate code from block support hook
* Pull over changes to background.js from #59557
* Add default control values for block supports. The default backgroundSize value for block backgrounds is 'cover'
* Resetting position if it's center and size is not contain.
* Add background-image to INDIRECT_PROPERTIES_METADATA because the value is "indirectly" stored in an array, at least determined by multiple values in an array.

---------

Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
  • Loading branch information
5 people authored Mar 27, 2024
1 parent e408f73 commit a7d3a88
Show file tree
Hide file tree
Showing 13 changed files with 877 additions and 622 deletions.
17 changes: 11 additions & 6 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,26 +286,31 @@ class WP_Theme_JSON_Gutenberg {
*
* Indirect properties are not output directly by `compute_style_properties`,
* but are used elsewhere in the processing of global styles. The indirect
* property is used to validate whether or not a style value is allowed.
* property is used to validate whether a style value is allowed.
*
* @since 6.2.0
* @since 6.6.0 Added background-image properties.
*
* @var array
*/
const INDIRECT_PROPERTIES_METADATA = array(
'gap' => array(
'gap' => array(
array( 'spacing', 'blockGap' ),
),
'column-gap' => array(
'column-gap' => array(
array( 'spacing', 'blockGap', 'left' ),
),
'row-gap' => array(
'row-gap' => array(
array( 'spacing', 'blockGap', 'top' ),
),
'max-width' => array(
'max-width' => array(
array( 'layout', 'contentSize' ),
array( 'layout', 'wideSize' ),
),
'background-image' => array(
array( 'background', 'backgroundImage', 'url' ),
array( 'background', 'backgroundImage', 'source' ),
),
);

/**
Expand Down Expand Up @@ -1359,7 +1364,7 @@ public function get_block_custom_css_nodes() {
*
* @since 6.6.0
*
* @param array $css The block css node.
* @param array $css The block css node.
* @param string $selector The block selector.
*
* @return string The global styles custom CSS for the block.
Expand Down
Loading

0 comments on commit a7d3a88

Please sign in to comment.