Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use color.customDuotone to control visibility of controls
  • Loading branch information
oandregal committed Jul 12, 2021
commit 7cc88ae6a78afd542d3989f32ddff5187d86a029
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function DuotonePickerPopover( {
duotonePalette,
colorPalette,
disableCustomColors,
disableCustomDuotone,
} ) {
return (
<Popover
Expand All @@ -23,6 +24,7 @@ function DuotonePickerPopover( {
colorPalette={ colorPalette }
duotonePalette={ duotonePalette }
disableCustomColors={ disableCustomColors }
disableCustomDuotone={ disableCustomDuotone }
value={ value }
onChange={ onChange }
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function DuotoneControl( {
colorPalette,
duotonePalette,
disableCustomColors,
disableCustomDuotone,
value,
onChange,
} ) {
Expand Down Expand Up @@ -51,6 +52,7 @@ function DuotoneControl( {
duotonePalette={ duotonePalette }
colorPalette={ colorPalette }
disableCustomColors={ disableCustomColors }
disableCustomDuotone={ disableCustomDuotone }
/>
) }
</>
Expand Down
8 changes: 5 additions & 3 deletions packages/block-editor/src/hooks/duotone.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,13 @@ function DuotonePanel( { name, attributes, setAttributes } ) {
const duotonePalette = useSetting( 'color.duotone' ) || EMPTY_ARRAY;
const colorPalette = useSetting( 'color.palette' ) || EMPTY_ARRAY;
const disableCustomColors = ! useSetting( 'color.custom' );
const disableCustomDuotone =
! useSetting( 'color.customDuotone' ) ||
( colorPalette?.length === 0 && disableCustomColors );

if (
! hasBlockSupport( name, 'color.__experimentalDuotone' ) ||
( duotonePalette?.length === 0 &&
colorPalette?.length === 0 &&
disableCustomColors )
( duotonePalette?.length === 0 && disableCustomDuotone )
) {
return null;
}
Expand All @@ -144,6 +145,7 @@ function DuotonePanel( { name, attributes, setAttributes } ) {
<DuotoneControl
duotonePalette={ duotonePalette }
colorPalette={ colorPalette }
disableCustomDuotone={ disableCustomDuotone }
disableCustomColors={ disableCustomColors }
value={ duotone }
onChange={ ( newDuotone ) => {
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/duotone-picker/duotone-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function DuotonePicker( {
colorPalette,
duotonePalette,
disableCustomColors,
disableCustomDuotone,
value,
onChange,
} ) {
Expand Down Expand Up @@ -78,7 +79,7 @@ function DuotonePicker( {
{ ! disableCustomColors && (
<CustomDuotoneBar value={ value } onChange={ onChange } />
) }
{ ( ! disableCustomColors || colorPalette?.length > 0 ) && (
{ ! disableCustomDuotone && (
<ColorListPicker
labels={ [ __( 'Shadows' ), __( 'Highlights' ) ] }
colors={ colorPalette }
Expand Down