Skip to content

Commit

Permalink
Update: Global Styes: Make the color palette counter count all color …
Browse files Browse the repository at this point in the history
…origins.
  • Loading branch information
jorgefilipecosta committed Nov 26, 2021
1 parent 628e956 commit 30352fe
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions packages/edit-site/src/components/global-styles/palette.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
ColorIndicator,
} from '@wordpress/components';
import { __, _n, sprintf } from '@wordpress/i18n';
import { useMemo } from '@wordpress/element';

/**
* Internal dependencies
Expand All @@ -22,12 +23,29 @@ import { useSetting } from './hooks';
const EMPTY_COLORS = [];

function Palette( { name } ) {
const [ colorsSetting ] = useSetting( 'color.palette.custom', name );
const colors = colorsSetting || EMPTY_COLORS;
const [ customColors ] = useSetting( 'color.palette.custom' );
const [ themeColors ] = useSetting( 'color.palette.theme' );
const [ defaultColors ] = useSetting( 'color.palette.default' );

const [ defaultPaletteEnabled ] = useSetting(
'color.defaultPalette',
name
);
const colors = useMemo(
() => [
...( customColors || EMPTY_COLORS ),
...( themeColors || EMPTY_COLORS ),
...( defaultColors && defaultPaletteEnabled
? defaultColors
: EMPTY_COLORS ),
],
[ customColors, themeColors, defaultColors, defaultPaletteEnabled ]
);

const screenPath = ! name
? '/colors/palette'
: '/blocks/' + name + '/colors/palette';
const palleteButtonText =
const paletteButtonText =
colors.length > 0
? sprintf(
// Translators: %d: Number of palette colors.
Expand All @@ -52,7 +70,7 @@ function Palette( { name } ) {
) ) }
</ZStack>
</FlexBlock>
<FlexItem>{ palleteButtonText }</FlexItem>
<FlexItem>{ paletteButtonText }</FlexItem>
</HStack>
</NavigationButton>
</ItemGroup>
Expand Down

0 comments on commit 30352fe

Please sign in to comment.