Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global Styles: Use text and button background color for color indicators #59514

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading