diff --git a/packages/components/src/duotone-picker/duotone-picker.js b/packages/components/src/duotone-picker/duotone-picker.js index bb205655c8e817..2d5c51bb3d699b 100644 --- a/packages/components/src/duotone-picker/duotone-picker.js +++ b/packages/components/src/duotone-picker/duotone-picker.js @@ -29,43 +29,48 @@ function DuotonePicker( { () => getDefaultColors( colorPalette ), [ colorPalette ] ); - return ( - { - const style = { - background: getGradientFromCSSColors( colors, '135deg' ), - color: 'transparent', - }; - const tooltipText = - name ?? - sprintf( - // translators: %s: duotone code e.g: "dark-grayscale" or "7f7f7f-ffffff". - __( 'Duotone code: %s' ), - slug - ); - const label = name - ? sprintf( - // translators: %s: The name of the option e.g: "Dark grayscale". - __( 'Duotone: %s' ), - name - ) - : tooltipText; - const isSelected = isEqual( colors, value ); - return ( - { - onChange( isSelected ? undefined : colors ); - } } - /> + let duotonePresets = null; + if ( !! duotonePalette ) { + duotonePresets = duotonePalette.map( ( { colors, slug, name } ) => { + const style = { + background: getGradientFromCSSColors( colors, '135deg' ), + color: 'transparent', + }; + const tooltipText = + name ?? + sprintf( + // translators: %s: duotone code e.g: "dark-grayscale" or "7f7f7f-ffffff". + __( 'Duotone code: %s' ), + slug ); - } ) } + const label = name + ? sprintf( + // translators: %s: The name of the option e.g: "Dark grayscale". + __( 'Duotone: %s' ), + name + ) + : tooltipText; + const isSelected = isEqual( colors, value ); + + return ( + { + onChange( isSelected ? undefined : colors ); + } } + /> + ); + } ); + } + return ( + onChange( undefined ) }