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

Make it clearer how to edit a site's palette #61364

Merged
merged 5 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
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
27 changes: 9 additions & 18 deletions packages/edit-site/src/components/global-styles/palette.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
ColorIndicator,
Button,
} from '@wordpress/components';
import { __, _n, sprintf } from '@wordpress/i18n';
import { shuffle } from '@wordpress/icons';
import { isRTL, __ } from '@wordpress/i18n';
import { Icon, shuffle, chevronLeft, chevronRight } from '@wordpress/icons';
import { useMemo } from '@wordpress/element';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';

Expand Down Expand Up @@ -55,27 +55,20 @@ function Palette( { name } ) {
? '/colors/palette'
: '/blocks/' + encodeURIComponent( name ) + '/colors/palette';
const paletteButtonText =
colors.length > 0
? sprintf(
// Translators: %d: Number of palette colors.
_n( '%d color', '%d colors', colors.length ),
colors.length
)
: __( 'Add custom colors' );
colors.length > 0 ? __( 'Edit palette' ) : __( 'Add colors' );

return (
<VStack spacing={ 3 }>
<Subtitle level={ 3 }>{ __( 'Palette' ) }</Subtitle>
<ItemGroup isBordered isSeparated>
<NavigationButtonAsItem
path={ screenPath }
aria-label={ __( 'Color palettes' ) }
aria-label={ paletteButtonText }
>
<HStack
direction={
colors.length === 0 ? 'row-reverse' : 'row'
}
>
<HStack direction="row">
{ colors.length <= 0 && (
<FlexItem>{ __( 'Add colors' ) }</FlexItem>
) }
<ZStack isLayered={ false } offset={ -8 }>
{ colors
.slice( 0, 5 )
Expand All @@ -87,9 +80,7 @@ function Palette( { name } ) {
</ColorIndicatorWrapper>
) ) }
</ZStack>
<FlexItem className="edit-site-global-styles-screen-colors__palette-count">
{ paletteButtonText }
</FlexItem>
<Icon icon={ isRTL() ? chevronLeft : chevronRight } />
</HStack>
</NavigationButtonAsItem>
</ItemGroup>
Expand Down
4 changes: 0 additions & 4 deletions packages/edit-site/src/components/global-styles/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@
row-gap: calc(#{$grid-unit-05} * 3);
}

.edit-site-global-styles-screen-colors__palette-count {
color: $gray-700;
}

.edit-site-global-styles-header__description {
padding: 0 $grid-unit-20;
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/site-editor/style-variations.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ test.describe( 'Global styles variations', () => {
await page.click( 'role=button[name="pink"i]' );
await page.click( 'role=button[name="Back"i]' );
await page.click( 'role=button[name="Colors styles"i]' );
await page.click( 'role=button[name="Color palettes"i]' );
await page.click( 'role=button[name="Edit palette"i]' );

await expect(
page.locator( 'role=option[name="Color: Foreground"i]' )
Expand Down
Loading