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

DuotonePicker: Fix top margin when no duotone options #57489

Merged
merged 3 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Expand Up @@ -16,6 +16,7 @@
- `Truncate`: improve handling of non-string `children` ([#57261](https://github.com/WordPress/gutenberg/pull/57261)).
- `PaletteEdit`: Don't discard colors with default name and slug ([#54332](https://github.com/WordPress/gutenberg/pull/54332)).
- `RadioControl`: Fully encapsulate styles ([#57347](https://github.com/WordPress/gutenberg/pull/57347)).
- `DuotonePicker`: Remove top margin when no duotone options ([#57489](https://github.com/WordPress/gutenberg/pull/57489)).
- `GradientPicker`: Use slug while iterating over gradient entries to avoid React "duplicated key" warning ([#57361](https://github.com/WordPress/gutenberg/pull/57361)).

### Enhancements
Expand Down
10 changes: 7 additions & 3 deletions packages/components/src/duotone-picker/duotone-picker.tsx
Expand Up @@ -91,7 +91,7 @@ function DuotonePicker( {
/>
);

const options = duotonePalette.map( ( { colors, slug, name } ) => {
const duotoneOptions = duotonePalette.map( ( { colors, slug, name } ) => {
const style = {
background: getGradientFromCSSColors( colors, '135deg' ),
color: 'transparent',
Expand Down Expand Up @@ -155,11 +155,15 @@ function DuotonePicker( {
}
}

const options = unsetable
? [ unsetOption, ...duotoneOptions ]
: duotoneOptions;

return (
<CircularOptionPicker
{ ...otherProps }
{ ...metaProps }
options={ unsetable ? [ unsetOption, ...options ] : options }
options={ options }
actions={
!! clearable && (
<CircularOptionPicker.ButtonAction
Expand All @@ -170,7 +174,7 @@ function DuotonePicker( {
)
}
>
<Spacer paddingTop={ 4 }>
<Spacer paddingTop={ options.length === 0 ? 0 : 4 }>
<VStack spacing={ 3 }>
{ ! disableCustomColors && ! disableCustomDuotone && (
<CustomDuotoneBar
Expand Down