From f4e4a5c600b46f36f44596f4a833c8511014474f Mon Sep 17 00:00:00 2001 From: scruffian Date: Fri, 1 Mar 2024 20:28:25 +0000 Subject: [PATCH] Global Styles: Use text and button background color for color indicators --- .../src/components/global-styles/hooks.js | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/edit-site/src/components/global-styles/hooks.js b/packages/edit-site/src/components/global-styles/hooks.js index 86daf02c46344b..6ecb1de03a1446 100644 --- a/packages/edit-site/src/components/global-styles/hooks.js +++ b/packages/edit-site/src/components/global-styles/hooks.js @@ -65,6 +65,13 @@ export function useStylesPreviewColors() { const [ headingColor = textColor ] = useGlobalStyle( 'elements.h1.color.text' ); + const [ linkColor = headingColor ] = useGlobalStyle( + 'elements.link.color.text' + ); + + const [ buttonBackgroundColor = linkColor ] = useGlobalStyle( + 'elements.button.color.background' + ); const [ coreColors ] = useGlobalSetting( 'color.palette.core' ); const [ themeColors ] = useGlobalSetting( 'color.palette.theme' ); const [ customColors ] = useGlobalSetting( 'color.palette.custom' ); @@ -72,10 +79,20 @@ export function useStylesPreviewColors() { const paletteColors = ( themeColors ?? [] ) .concat( customColors ?? [] ) .concat( coreColors ?? [] ); - const highlightedColors = paletteColors + + const textColorObject = paletteColors.filter( + ( { color } ) => color === textColor + ); + const buttonBackgroundColorObject = paletteColors.filter( + ( { color } ) => color === buttonBackgroundColor + ); + + const highlightedColors = textColorObject + .concat( buttonBackgroundColorObject ) + .concat( paletteColors ) .filter( - // we exclude these two colors because they are already visible in the preview. - ( { color } ) => color !== backgroundColor && color !== headingColor + // we exclude these background color because it is already visible in the preview. + ( { color } ) => color !== backgroundColor ) .slice( 0, 2 );