[CYS- Core] Improve default palette (#44722)
* improve default palette * improve comment * Add changefile(s) from automation for the following project(s): woocommerce * improve comment * fix theme.json --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
parent
62f2782715
commit
879cfaec46
|
@ -13,7 +13,7 @@ export const COLOR_PALETTES = [
|
|||
slug: 'primary',
|
||||
},
|
||||
{
|
||||
color: '#000000',
|
||||
color: '#636363',
|
||||
name: 'Secondary',
|
||||
slug: 'secondary',
|
||||
},
|
||||
|
@ -37,6 +37,9 @@ export const COLOR_PALETTES = [
|
|||
},
|
||||
},
|
||||
styles: {
|
||||
blocks: {
|
||||
'core/button': {},
|
||||
},
|
||||
color: {
|
||||
background: 'var(--wp--preset--color--background)',
|
||||
text: 'var(--wp--preset--color--foreground)',
|
||||
|
@ -47,6 +50,12 @@ export const COLOR_PALETTES = [
|
|||
background: 'var(--wp--preset--color--primary)',
|
||||
text: 'var(--wp--preset--color--background)',
|
||||
},
|
||||
':hover': {
|
||||
color: {
|
||||
background: 'var(--wp--preset--color--secondary)',
|
||||
text: 'var(--wp--preset--color--background)',
|
||||
},
|
||||
},
|
||||
},
|
||||
link: {
|
||||
color: {
|
||||
|
|
|
@ -33,6 +33,17 @@ const resetTypographySettings = ( variation, userStyles ) => {
|
|||
return userStyles;
|
||||
};
|
||||
|
||||
// mergeBaseAndUserConfigs is just a wrapper around deepmerge library: https://github.com/WordPress/gutenberg/blob/237865fad0864c209a7c3e771e23fe66f4fbca25/packages/edit-site/src/components/global-styles/global-styles-provider.js/#L24-L31
|
||||
// Deepmerge library merges two objects x and y deeply, returning a new merged object with the elements from both x and y.
|
||||
// In the case of the variation.title === 'New - Neutral', the core/button is an empty object, because we don't want that the classes for the core/button are created.
|
||||
// Deepmerge merges the userStyles.blocks[ 'core/button' ] with the variation.styles.blocks[ 'core/button' ] and the result is an object with values that doesn't match with the variation. For this reason it is necessary remove the userStyles.blocks[ 'core/button' ].
|
||||
const resetStyleSettings = ( variation, userStyles ) => {
|
||||
if ( variation.title === 'New - Neutral' ) {
|
||||
delete userStyles.blocks[ 'core/button' ];
|
||||
}
|
||||
return userStyles;
|
||||
};
|
||||
|
||||
export const VariationContainer = ( { variation, children } ) => {
|
||||
const { base, user, setUserConfig } = useContext( GlobalStylesContext );
|
||||
const context = useMemo( () => {
|
||||
|
@ -68,6 +79,15 @@ export const VariationContainer = ( { variation, children } ) => {
|
|||
}
|
||||
}
|
||||
|
||||
const resetTypographySettingsStyles = resetTypographySettings(
|
||||
variation,
|
||||
user.styles
|
||||
);
|
||||
const resetStyleSettingsStyles = resetStyleSettings(
|
||||
variation,
|
||||
resetTypographySettingsStyles
|
||||
);
|
||||
|
||||
setUserConfig( () => {
|
||||
return {
|
||||
settings: mergeBaseAndUserConfigs(
|
||||
|
@ -75,7 +95,7 @@ export const VariationContainer = ( { variation, children } ) => {
|
|||
variation.settings
|
||||
),
|
||||
styles: mergeBaseAndUserConfigs(
|
||||
resetTypographySettings( variation, user.styles ),
|
||||
resetStyleSettingsStyles,
|
||||
variation.styles
|
||||
),
|
||||
};
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: fix
|
||||
|
||||
[CYS- Core] Improve the default palette.
|
Loading…
Reference in New Issue