Skip to content

Commit

Permalink
Global Styles: Use text and button background color for color indicators
Browse files Browse the repository at this point in the history
  • Loading branch information
scruffian authored and richtabor committed Apr 3, 2024
1 parent e54644e commit f4e4a5c
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions packages/edit-site/src/components/global-styles/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,34 @@ 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' );

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 );

Expand Down

0 comments on commit f4e4a5c

Please sign in to comment.