Skip to content

Commit

Permalink
The theme palette goes before the default one
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Nov 18, 2021
1 parent cedf0e4 commit 936c2c8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ const PanelColorGradientSettingsMultipleSelect = ( props ) => {

colorGradientSettings.colors = useMemo( () => {
const result = [];
if ( themeColors && themeColors.length ) {
result.push( {
name: __( 'Theme' ),
colors: themeColors,
} );
}
if (
shouldDisplayDefaultColors &&
defaultColors &&
Expand All @@ -189,12 +195,6 @@ const PanelColorGradientSettingsMultipleSelect = ( props ) => {
colors: defaultColors,
} );
}
if ( themeColors && themeColors.length ) {
result.push( {
name: __( 'Theme' ),
colors: themeColors,
} );
}
if ( customColors && customColors.length ) {
result.push( {
name: __( 'Custom' ),
Expand All @@ -212,6 +212,12 @@ const PanelColorGradientSettingsMultipleSelect = ( props ) => {
);
colorGradientSettings.gradients = useMemo( () => {
const result = [];
if ( themeGradients && themeGradients.length ) {
result.push( {
name: __( 'Theme' ),
gradients: themeGradients,
} );
}
if (
shouldDisplayDefaultGradients &&
defaultGradients &&
Expand All @@ -222,12 +228,6 @@ const PanelColorGradientSettingsMultipleSelect = ( props ) => {
gradients: defaultGradients,
} );
}
if ( themeGradients && themeGradients.length ) {
result.push( {
name: __( 'Theme' ),
gradients: themeGradients,
} );
}
if ( customGradients && customGradients.length ) {
result.push( {
name: __( 'Custom' ),
Expand Down
24 changes: 12 additions & 12 deletions packages/edit-site/src/components/global-styles/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,18 +223,18 @@ export function useColorsPerOrigin( name ) {
const [ defaultColors ] = useSetting( 'color.palette.core', name );
return useMemo( () => {
const result = [];
if ( defaultColors && defaultColors.length ) {
result.push( {
name: __( 'Default' ),
colors: defaultColors,
} );
}
if ( themeColors && themeColors.length ) {
result.push( {
name: __( 'Theme' ),
colors: themeColors,
} );
}
if ( defaultColors && defaultColors.length ) {
result.push( {
name: __( 'Default' ),
colors: defaultColors,
} );
}
if ( customColors && customColors.length ) {
result.push( {
name: __( 'Custom' ),
Expand All @@ -251,18 +251,18 @@ export function useGradientsPerOrigin( name ) {
const [ defaultGradients ] = useSetting( 'color.gradients.core', name );
return useMemo( () => {
const result = [];
if ( defaultGradients && defaultGradients.length ) {
result.push( {
name: __( 'Default' ),
gradients: defaultGradients,
} );
}
if ( themeGradients && themeGradients.length ) {
result.push( {
name: __( 'Theme' ),
gradients: themeGradients,
} );
}
if ( defaultGradients && defaultGradients.length ) {
result.push( {
name: __( 'Default' ),
gradients: defaultGradients,
} );
}
if ( customGradients && customGradients.length ) {
result.push( {
name: __( 'Custom' ),
Expand Down

0 comments on commit 936c2c8

Please sign in to comment.