Skip to content

Commit

Permalink
Global Styles sidebar: do not show default palette if theme opts-out (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Nov 19, 2021
1 parent d718cb0 commit e081de4
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/edit-site/src/components/global-styles/hooks.js
Expand Up @@ -221,6 +221,8 @@ export function useColorsPerOrigin( name ) {
const [ customColors ] = useSetting( 'color.palette.user', name );
const [ themeColors ] = useSetting( 'color.palette.theme', name );
const [ defaultColors ] = useSetting( 'color.palette.core', name );
const [ shouldDisplayDefaultColors ] = useSetting( 'color.defaultPalette' );

return useMemo( () => {
const result = [];
if ( themeColors && themeColors.length ) {
Expand All @@ -232,7 +234,11 @@ export function useColorsPerOrigin( name ) {
colors: themeColors,
} );
}
if ( defaultColors && defaultColors.length ) {
if (
shouldDisplayDefaultColors &&
defaultColors &&
defaultColors.length
) {
result.push( {
name: _x(
'Default',
Expand All @@ -258,6 +264,10 @@ export function useGradientsPerOrigin( name ) {
const [ customGradients ] = useSetting( 'color.gradients.user', name );
const [ themeGradients ] = useSetting( 'color.gradients.theme', name );
const [ defaultGradients ] = useSetting( 'color.gradients.core', name );
const [ shouldDisplayDefaultGradients ] = useSetting(
'color.defaultGradients'
);

return useMemo( () => {
const result = [];
if ( themeGradients && themeGradients.length ) {
Expand All @@ -269,7 +279,11 @@ export function useGradientsPerOrigin( name ) {
gradients: themeGradients,
} );
}
if ( defaultGradients && defaultGradients.length ) {
if (
shouldDisplayDefaultGradients &&
defaultGradients &&
defaultGradients.length
) {
result.push( {
name: _x(
'Default',
Expand Down

0 comments on commit e081de4

Please sign in to comment.