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

GlobalStyles sidebar: do not show default palette if theme opts-out #36639

Merged
merged 1 commit into from
Nov 19, 2021
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
18 changes: 16 additions & 2 deletions packages/edit-site/src/components/global-styles/hooks.js
Original file line number Diff line number Diff line change
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