-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Color UI component: reorder palettes and update names (core by defaults, user by custom) #36622
Changes from 7 commits
bc16651
7af1cca
fdc0314
4e77fd6
a592b3c
cedf0e4
936c2c8
58cd85b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,64 +172,70 @@ const PanelColorGradientSettingsSingleSelect = ( props ) => { | |
|
||
const PanelColorGradientSettingsMultipleSelect = ( props ) => { | ||
const colorGradientSettings = useCommonSingleMultipleSelects(); | ||
const userColors = useSetting( 'color.palette.user' ); | ||
const customColors = useSetting( 'color.palette.user' ); | ||
const themeColors = useSetting( 'color.palette.theme' ); | ||
const coreColors = useSetting( 'color.palette.core' ); | ||
const shouldDisplayCoreColors = useSetting( 'color.corePalette' ); | ||
const defaultColors = useSetting( 'color.palette.core' ); | ||
const shouldDisplayDefaultColors = useSetting( 'color.defaultPalette' ); | ||
|
||
colorGradientSettings.colors = useMemo( () => { | ||
const result = []; | ||
if ( shouldDisplayCoreColors && coreColors && coreColors.length ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per the mockups, the order in which the palettes should be shown is: defaults, theme, user. |
||
result.push( { | ||
name: __( 'Core' ), | ||
colors: coreColors, | ||
} ); | ||
} | ||
if ( themeColors && themeColors.length ) { | ||
result.push( { | ||
name: __( 'Theme' ), | ||
colors: themeColors, | ||
} ); | ||
} | ||
if ( userColors && userColors.length ) { | ||
if ( | ||
shouldDisplayDefaultColors && | ||
defaultColors && | ||
defaultColors.length | ||
) { | ||
result.push( { | ||
name: __( 'Default' ), | ||
colors: defaultColors, | ||
} ); | ||
} | ||
if ( customColors && customColors.length ) { | ||
result.push( { | ||
name: __( 'User' ), | ||
colors: userColors, | ||
name: __( 'Custom' ), | ||
colors: customColors, | ||
} ); | ||
} | ||
return result; | ||
}, [ coreColors, themeColors, userColors ] ); | ||
}, [ defaultColors, themeColors, customColors ] ); | ||
|
||
const userGradients = useSetting( 'color.gradients.user' ); | ||
const customGradients = useSetting( 'color.gradients.user' ); | ||
const themeGradients = useSetting( 'color.gradients.theme' ); | ||
const coreGradients = useSetting( 'color.gradients.core' ); | ||
const shouldDisplayCoreGradients = useSetting( 'color.coreGradients' ); | ||
const defaultGradients = useSetting( 'color.gradients.core' ); | ||
const shouldDisplayDefaultGradients = useSetting( | ||
'color.defaultGradients' | ||
); | ||
colorGradientSettings.gradients = useMemo( () => { | ||
const result = []; | ||
if ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per the mockups, the order in which the palettes should be shown is: defaults, theme, user. |
||
shouldDisplayCoreGradients && | ||
coreGradients && | ||
coreGradients.length | ||
) { | ||
result.push( { | ||
name: __( 'Core' ), | ||
gradients: coreGradients, | ||
} ); | ||
} | ||
if ( themeGradients && themeGradients.length ) { | ||
result.push( { | ||
name: __( 'Theme' ), | ||
gradients: themeGradients, | ||
} ); | ||
} | ||
if ( userGradients && userGradients.length ) { | ||
if ( | ||
shouldDisplayDefaultGradients && | ||
defaultGradients && | ||
defaultGradients.length | ||
) { | ||
result.push( { | ||
name: __( 'Default' ), | ||
gradients: defaultGradients, | ||
} ); | ||
} | ||
if ( customGradients && customGradients.length ) { | ||
result.push( { | ||
name: __( 'User' ), | ||
gradients: userGradients, | ||
name: __( 'Custom' ), | ||
gradients: customGradients, | ||
} ); | ||
} | ||
return result; | ||
}, [ userGradients, themeGradients, coreGradients ] ); | ||
}, [ customGradients, themeGradients, defaultGradients ] ); | ||
return ( | ||
<PanelColorGradientSettingsInner | ||
{ ...{ ...colorGradientSettings, ...props } } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -218,57 +218,57 @@ export function getSupportedGlobalStylesPanels( name ) { | |
} | ||
|
||
export function useColorsPerOrigin( name ) { | ||
const [ userColors ] = useSetting( 'color.palette.user', name ); | ||
const [ customColors ] = useSetting( 'color.palette.user', name ); | ||
const [ themeColors ] = useSetting( 'color.palette.theme', name ); | ||
const [ coreColors ] = useSetting( 'color.palette.core', name ); | ||
const [ defaultColors ] = useSetting( 'color.palette.core', name ); | ||
return useMemo( () => { | ||
const result = []; | ||
if ( coreColors && coreColors.length ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per the mockups, the order of teh palettes is: theme, defaults, custom. |
||
result.push( { | ||
name: __( 'Core' ), | ||
colors: coreColors, | ||
} ); | ||
} | ||
if ( themeColors && themeColors.length ) { | ||
result.push( { | ||
name: __( 'Theme' ), | ||
colors: themeColors, | ||
} ); | ||
} | ||
if ( userColors && userColors.length ) { | ||
if ( defaultColors && defaultColors.length ) { | ||
result.push( { | ||
name: __( 'Default' ), | ||
colors: defaultColors, | ||
} ); | ||
} | ||
if ( customColors && customColors.length ) { | ||
result.push( { | ||
name: __( 'User' ), | ||
colors: userColors, | ||
name: __( 'Custom' ), | ||
colors: customColors, | ||
} ); | ||
} | ||
return result; | ||
}, [ userColors, themeColors, coreColors ] ); | ||
}, [ customColors, themeColors, defaultColors ] ); | ||
} | ||
|
||
export function useGradientsPerOrigin( name ) { | ||
const [ userGradients ] = useSetting( 'color.gradients.user', name ); | ||
const [ customGradients ] = useSetting( 'color.gradients.user', name ); | ||
const [ themeGradients ] = useSetting( 'color.gradients.theme', name ); | ||
const [ coreGradients ] = useSetting( 'color.gradients.core', name ); | ||
const [ defaultGradients ] = useSetting( 'color.gradients.core', name ); | ||
return useMemo( () => { | ||
const result = []; | ||
if ( coreGradients && coreGradients.length ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Per the mockups, the order of teh palettes is: theme, defaults, custom. |
||
result.push( { | ||
name: __( 'Core' ), | ||
gradients: coreGradients, | ||
} ); | ||
} | ||
if ( themeGradients && themeGradients.length ) { | ||
result.push( { | ||
name: __( 'Theme' ), | ||
gradients: themeGradients, | ||
} ); | ||
} | ||
if ( userGradients && userGradients.length ) { | ||
if ( defaultGradients && defaultGradients.length ) { | ||
result.push( { | ||
name: __( 'Default' ), | ||
gradients: defaultGradients, | ||
} ); | ||
} | ||
if ( customGradients && customGradients.length ) { | ||
result.push( { | ||
name: __( 'User' ), | ||
gradients: userGradients, | ||
name: __( 'Custom' ), | ||
gradients: customGradients, | ||
} ); | ||
} | ||
return result; | ||
}, [ userGradients, themeGradients, coreGradients ] ); | ||
}, [ customGradients, themeGradients, defaultGradients ] ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume these settings were only recently introduced, which is why we don't need migrations.