diff --git a/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php b/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php index 55716b3cf58fa..b02fffdbbbd0d 100644 --- a/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php +++ b/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php @@ -91,7 +91,12 @@ protected static function get_blocks_metadata() { break; } - $element_selector[] = $selector . ' ' . $el_selector; + // This converts selectors like '.wp-element-button, .wp-block-button__link' + // to an array, so that the block selector is added to both parts of the selector. + $el_selectors = explode( ',', $el_selector ); + foreach ( $el_selectors as $el_selector_item ) { + $element_selector[] = $selector . ' ' . $el_selector_item; + } } static::$blocks_metadata[ $block_name ]['elements'][ $el_name ] = implode( ',', $element_selector ); } diff --git a/lib/compat/wordpress-6.1/class-wp-theme-json-resolver-6-1.php b/lib/compat/wordpress-6.1/class-wp-theme-json-resolver-6-1.php new file mode 100644 index 0000000000000..58abcc27c04ec --- /dev/null +++ b/lib/compat/wordpress-6.1/class-wp-theme-json-resolver-6-1.php @@ -0,0 +1,35 @@ + 0 || areCustomSolidsEnabled ); // TODO - use the right check + + const [ buttonTextColor, setButtonTextColor ] = useStyle( + 'elements.button.color.text', + name + ); + const [ userButtonTextColor ] = useStyle( + 'elements.button.color.text', + name, + 'user' + ); + + const [ buttonBgColor, setButtonBgColor ] = useStyle( + 'elements.button.color.background', + name + ); + const [ userButtonBgColor ] = useStyle( + 'elements.button.color.background', + name, + 'user' + ); + + if ( ! hasButtonColor ) { + return null; + } + + return ( + <> + + +

+ { __( 'Text color' ) } +

+ + + +

+ { __( 'Background color' ) } +

+ + + + ); +} + +export default ScreenButtonColor; diff --git a/packages/edit-site/src/components/global-styles/screen-colors.js b/packages/edit-site/src/components/global-styles/screen-colors.js index 4e961dcf0e75b..24d6f4260b252 100644 --- a/packages/edit-site/src/components/global-styles/screen-colors.js +++ b/packages/edit-site/src/components/global-styles/screen-colors.js @@ -6,6 +6,7 @@ import { __experimentalItemGroup as ItemGroup, __experimentalHStack as HStack, __experimentalVStack as VStack, + __experimentalZStack as ZStack, FlexItem, ColorIndicator, } from '@wordpress/components'; @@ -88,6 +89,33 @@ function LinkColorItem( { name, parentMenu } ) { ); } +function ButtonColorItem( { name, parentMenu } ) { + const supports = getSupportedGlobalStylesPanels( name ); + const hasSupport = supports.includes( 'linkColor' ); // TODO - use a real support + const [ color ] = useStyle( 'elements.button.color.text', name ); + const [ bgColor ] = useStyle( 'elements.button.color.background', name ); + + if ( ! hasSupport ) { + return null; + } + + return ( + + + + + + + + + + + { __( 'Buttons' ) } + + + ); +} + function ScreenColors( { name } ) { const parentMenu = name === undefined ? '' : '/blocks/' + name; @@ -119,6 +147,10 @@ function ScreenColors( { name } ) { name={ name } parentMenu={ parentMenu } /> + diff --git a/packages/edit-site/src/components/global-styles/screen-typography-element.js b/packages/edit-site/src/components/global-styles/screen-typography-element.js index 46b53a3a7b3d3..4f7abe955803e 100644 --- a/packages/edit-site/src/components/global-styles/screen-typography-element.js +++ b/packages/edit-site/src/components/global-styles/screen-typography-element.js @@ -18,6 +18,10 @@ const elements = { description: __( 'Manage the fonts and typography used on the links.' ), title: __( 'Links' ), }, + button: { + description: __( 'Manage the fonts and typography used on buttons.' ), + title: __( 'Buttons' ), + }, }; function ScreenTypographyElement( { name, element } ) { diff --git a/packages/edit-site/src/components/global-styles/screen-typography.js b/packages/edit-site/src/components/global-styles/screen-typography.js index 32e93cd6af37e..08fda42065f0d 100644 --- a/packages/edit-site/src/components/global-styles/screen-typography.js +++ b/packages/edit-site/src/components/global-styles/screen-typography.js @@ -95,6 +95,12 @@ function ScreenTypography( { name } ) { element="link" label={ __( 'Links' ) } /> + diff --git a/packages/edit-site/src/components/global-styles/style.scss b/packages/edit-site/src/components/global-styles/style.scss index 122b753dffa17..1b58a0ec05adb 100644 --- a/packages/edit-site/src/components/global-styles/style.scss +++ b/packages/edit-site/src/components/global-styles/style.scss @@ -57,6 +57,16 @@ font-size: 11px !important; } +.edit-site-global-styles-section-title { + font-size: calc(1.95 * 8px); + color: rgb(30, 30, 30); + font-weight: 600; + line-height: 1.2; + padding: $grid-unit-20; + padding-bottom: 0; + margin: 0; +} + .edit-site-screen-color-palette-toggle.edit-site-screen-color-palette-toggle { margin-right: $grid-unit-20; margin-left: $grid-unit-20; @@ -68,6 +78,7 @@ .edit-site-screen-text-color__control, .edit-site-screen-link-color__control, +.edit-site-screen-button-color__control, .edit-site-screen-background-color__control { padding: $grid-unit-20; } diff --git a/packages/edit-site/src/components/global-styles/ui.js b/packages/edit-site/src/components/global-styles/ui.js index 793b0939d9014..750985ad1f94f 100644 --- a/packages/edit-site/src/components/global-styles/ui.js +++ b/packages/edit-site/src/components/global-styles/ui.js @@ -20,6 +20,7 @@ import ScreenColorPalette from './screen-color-palette'; import ScreenBackgroundColor from './screen-background-color'; import ScreenTextColor from './screen-text-color'; import ScreenLinkColor from './screen-link-color'; +import ScreenButtonColor from './screen-button-color'; import ScreenLayout from './screen-layout'; import ScreenStyleVariations from './screen-style-variations'; @@ -58,6 +59,12 @@ function ContextScreens( { name } ) { + + + + @@ -82,6 +89,12 @@ function ContextScreens( { name } ) { + + + + diff --git a/packages/edit-site/src/components/global-styles/use-global-styles-output.js b/packages/edit-site/src/components/global-styles/use-global-styles-output.js index 0be47a7000b53..4f6265a56a920 100644 --- a/packages/edit-site/src/components/global-styles/use-global-styles-output.js +++ b/packages/edit-site/src/components/global-styles/use-global-styles-output.js @@ -283,7 +283,14 @@ export const getNodesWithStyles = ( tree, blockSelectors ) => { styles: value, selector: blockSelectors[ blockName ].selector .split( ',' ) - .map( ( sel ) => sel + ' ' + ELEMENTS[ elementName ] ) + .map( ( sel ) => { + const elementSelectors = + ELEMENTS[ elementName ].split( ',' ); + return elementSelectors.map( + ( elementSelector ) => + sel + ' ' + elementSelector + ); + } ) .join( ',' ), } ); } diff --git a/packages/edit-site/src/components/global-styles/utils.js b/packages/edit-site/src/components/global-styles/utils.js index 50c412fc06cd5..833255b624b47 100644 --- a/packages/edit-site/src/components/global-styles/utils.js +++ b/packages/edit-site/src/components/global-styles/utils.js @@ -11,6 +11,7 @@ export const ROOT_BLOCK_SUPPORTS = [ 'backgroundColor', 'color', 'linkColor', + 'buttonColor', 'fontFamily', 'fontSize', 'fontStyle', @@ -75,6 +76,8 @@ const STYLE_PATH_TO_CSS_VAR_INFIX = { 'color.background': 'color', 'color.text': 'color', 'elements.link.color.text': 'color', + 'elements.button.color.text': 'color', + 'elements.button.backgroundColor': 'background-color', 'color.gradient': 'gradient', 'typography.fontSize': 'font-size', 'typography.fontFamily': 'font-family',