Skip to content

Commit

Permalink
Global Styles: Update color indicators for style previews (WordPress#…
Browse files Browse the repository at this point in the history
…59514)

Co-authored-by: scruffian <scruffian@git.wordpress.org>
Co-authored-by: richtabor <richtabor@git.wordpress.org>
Co-authored-by: bgardner <bgardner@git.wordpress.org>
Co-authored-by: mtias <matveb@git.wordpress.org>
Co-authored-by: spencerfinnell <spencerfinnell@git.wordpress.org>
  • Loading branch information
6 people authored and cbravobernal committed Apr 9, 2024
1 parent c7fa3c8 commit 71b2955
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 71b2955

Please sign in to comment.