Skip to content

Commit

Permalink
DuotonePicker: Fix top margin when no duotone options (#57489)
Browse files Browse the repository at this point in the history
* DuotonePicker: Fix top margin when no duotone options

* Update changelog

---------

Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com>
  • Loading branch information
mirka and ciampo authored Jan 3, 2024
1 parent 84715c0 commit 5f6467d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
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)).
- `Snackbar`: Fix icon positioning ([#57377](https://github.com/WordPress/gutenberg/pull/57377)).
- `GradientPicker`: Use slug while iterating over gradient entries to avoid React "duplicated key" warning ([#57361](https://github.com/WordPress/gutenberg/pull/57361)).
- `NavigatorProvider`: Exclude `size` value from `contain` CSS rule ([#57498](https://github.com/WordPress/gutenberg/pull/57498)).
Expand Down
10 changes: 7 additions & 3 deletions packages/components/src/duotone-picker/duotone-picker.tsx
Original file line number Diff line number Diff line change
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

0 comments on commit 5f6467d

Please sign in to comment.