From 5f5604389e7831f4ebfd129309611c744cc33a59 Mon Sep 17 00:00:00 2001 From: Alex Lende Date: Fri, 13 Oct 2023 15:35:40 -0500 Subject: [PATCH 1/8] Hide filters style panel when empty --- .../src/components/global-styles/filters-panel.js | 5 ++--- .../src/components/global-styles/screen-block.js | 8 +------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/packages/block-editor/src/components/global-styles/filters-panel.js b/packages/block-editor/src/components/global-styles/filters-panel.js index ef972de3f13cdf..14060cd3b9cbca 100644 --- a/packages/block-editor/src/components/global-styles/filters-panel.js +++ b/packages/block-editor/src/components/global-styles/filters-panel.js @@ -54,9 +54,8 @@ function useMultiOriginColorPresets( } export function useHasFiltersPanel( settings ) { - const hasDuotone = useHasDuotoneControl( settings ); - - return hasDuotone; + // TODO: Add customDuotone when we have a control for custom duotone filters. + return settings.color.defaultDuotone; } function useHasDuotoneControl( settings ) { diff --git a/packages/edit-site/src/components/global-styles/screen-block.js b/packages/edit-site/src/components/global-styles/screen-block.js index c6c642998695b7..def7d1d627fe46 100644 --- a/packages/edit-site/src/components/global-styles/screen-block.js +++ b/packages/edit-site/src/components/global-styles/screen-block.js @@ -283,13 +283,7 @@ function ScreenBlock( { name, variation } ) { inheritedValue={ inheritedStyleWithLayout } value={ styleWithLayout } onChange={ setStyle } - settings={ { - ...settings, - color: { - ...settings.color, - customDuotone: false, //TO FIX: Custom duotone only works on the block level right now - }, - } } + settings={ settings } includeLayoutControls /> ) } From d1dde625a82cab91e99458209e3cd2f5ffb057c7 Mon Sep 17 00:00:00 2001 From: Alex Lende Date: Fri, 13 Oct 2023 16:01:51 -0500 Subject: [PATCH 2/8] Fix when to show duotone controls --- .../block-editor/src/components/global-styles/filters-panel.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/global-styles/filters-panel.js b/packages/block-editor/src/components/global-styles/filters-panel.js index 14060cd3b9cbca..439da1390d4cd1 100644 --- a/packages/block-editor/src/components/global-styles/filters-panel.js +++ b/packages/block-editor/src/components/global-styles/filters-panel.js @@ -54,8 +54,7 @@ function useMultiOriginColorPresets( } export function useHasFiltersPanel( settings ) { - // TODO: Add customDuotone when we have a control for custom duotone filters. - return settings.color.defaultDuotone; + return useHasDuotoneControl( settings ); } function useHasDuotoneControl( settings ) { From 7f21624c41eec6ebbe58d8eadf831e0564087a36 Mon Sep 17 00:00:00 2001 From: Alex Lende Date: Fri, 13 Oct 2023 16:10:05 -0500 Subject: [PATCH 3/8] Show duotone selector when theme supplies duotone filters --- .../src/components/global-styles/filters-panel.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/global-styles/filters-panel.js b/packages/block-editor/src/components/global-styles/filters-panel.js index 439da1390d4cd1..76b6c0b44c465a 100644 --- a/packages/block-editor/src/components/global-styles/filters-panel.js +++ b/packages/block-editor/src/components/global-styles/filters-panel.js @@ -58,7 +58,11 @@ export function useHasFiltersPanel( settings ) { } function useHasDuotoneControl( settings ) { - return settings.color.customDuotone || settings.color.defaultDuotone; + return ( + settings.color.customDuotone || + settings.color.defaultDuotone || + settings.color.duotone.length > 0 + ); } function FiltersToolsPanel( { From 254f16a8641e6efb8fcf758bfd0129d3fb16464f Mon Sep 17 00:00:00 2001 From: Alex Lende Date: Fri, 13 Oct 2023 16:29:59 -0500 Subject: [PATCH 4/8] Disable custom colors in the duotone panel --- .../src/components/global-styles/filters-panel.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/packages/block-editor/src/components/global-styles/filters-panel.js b/packages/block-editor/src/components/global-styles/filters-panel.js index 76b6c0b44c465a..6477f354280e12 100644 --- a/packages/block-editor/src/components/global-styles/filters-panel.js +++ b/packages/block-editor/src/components/global-styles/filters-panel.js @@ -150,11 +150,6 @@ export default function FiltersPanel( { const hasDuotone = () => !! value?.filter?.duotone; const resetDuotone = () => setDuotone( undefined ); - const disableCustomColors = ! settings?.color?.custom; - const disableCustomDuotone = - ! settings?.color?.customDuotone || - ( colorPalette?.length === 0 && disableCustomColors ); - const resetAllFilter = useCallback( ( previousValue ) => { return { ...previousValue, @@ -212,12 +207,9 @@ export default function FiltersPanel( { From 3331b882025aaed7270a0e513bc5c136cb6eab72 Mon Sep 17 00:00:00 2001 From: Alex Lende Date: Fri, 13 Oct 2023 16:33:40 -0500 Subject: [PATCH 5/8] Don't show when only customDuotone is enabled --- .../src/components/global-styles/filters-panel.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/block-editor/src/components/global-styles/filters-panel.js b/packages/block-editor/src/components/global-styles/filters-panel.js index 6477f354280e12..0b576a62e75b57 100644 --- a/packages/block-editor/src/components/global-styles/filters-panel.js +++ b/packages/block-editor/src/components/global-styles/filters-panel.js @@ -58,11 +58,7 @@ export function useHasFiltersPanel( settings ) { } function useHasDuotoneControl( settings ) { - return ( - settings.color.customDuotone || - settings.color.defaultDuotone || - settings.color.duotone.length > 0 - ); + return settings.color.defaultDuotone || settings.color.duotone.length > 0; } function FiltersToolsPanel( { From be4ab99c1a1ff392397446dc8ec8dbc3bc058977 Mon Sep 17 00:00:00 2001 From: Alex Lende Date: Fri, 13 Oct 2023 17:48:08 -0500 Subject: [PATCH 6/8] Revert "Don't show when only customDuotone is enabled" This reverts commit 5550a60a872b1d9609fd5294fe58cf5f0163e187. --- .../src/components/global-styles/filters-panel.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/global-styles/filters-panel.js b/packages/block-editor/src/components/global-styles/filters-panel.js index 0b576a62e75b57..6477f354280e12 100644 --- a/packages/block-editor/src/components/global-styles/filters-panel.js +++ b/packages/block-editor/src/components/global-styles/filters-panel.js @@ -58,7 +58,11 @@ export function useHasFiltersPanel( settings ) { } function useHasDuotoneControl( settings ) { - return settings.color.defaultDuotone || settings.color.duotone.length > 0; + return ( + settings.color.customDuotone || + settings.color.defaultDuotone || + settings.color.duotone.length > 0 + ); } function FiltersToolsPanel( { From 3c06c2a87edb4792e278d02374eed26ecda6466a Mon Sep 17 00:00:00 2001 From: Alex Lende Date: Fri, 13 Oct 2023 17:48:20 -0500 Subject: [PATCH 7/8] Revert "Disable custom colors in the duotone panel" This reverts commit 0da2522c34c8388c163f2c3a8c1d424b4d254916. --- .../src/components/global-styles/filters-panel.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/block-editor/src/components/global-styles/filters-panel.js b/packages/block-editor/src/components/global-styles/filters-panel.js index 6477f354280e12..76b6c0b44c465a 100644 --- a/packages/block-editor/src/components/global-styles/filters-panel.js +++ b/packages/block-editor/src/components/global-styles/filters-panel.js @@ -150,6 +150,11 @@ export default function FiltersPanel( { const hasDuotone = () => !! value?.filter?.duotone; const resetDuotone = () => setDuotone( undefined ); + const disableCustomColors = ! settings?.color?.custom; + const disableCustomDuotone = + ! settings?.color?.customDuotone || + ( colorPalette?.length === 0 && disableCustomColors ); + const resetAllFilter = useCallback( ( previousValue ) => { return { ...previousValue, @@ -207,9 +212,12 @@ export default function FiltersPanel( { From b9bdc6e4dbbdf7f93d240fbccd4122621c69b63d Mon Sep 17 00:00:00 2001 From: Alex Lende Date: Fri, 13 Oct 2023 17:51:43 -0500 Subject: [PATCH 8/8] disable --- .../src/components/global-styles/filters-panel.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/packages/block-editor/src/components/global-styles/filters-panel.js b/packages/block-editor/src/components/global-styles/filters-panel.js index 76b6c0b44c465a..6477f354280e12 100644 --- a/packages/block-editor/src/components/global-styles/filters-panel.js +++ b/packages/block-editor/src/components/global-styles/filters-panel.js @@ -150,11 +150,6 @@ export default function FiltersPanel( { const hasDuotone = () => !! value?.filter?.duotone; const resetDuotone = () => setDuotone( undefined ); - const disableCustomColors = ! settings?.color?.custom; - const disableCustomDuotone = - ! settings?.color?.customDuotone || - ( colorPalette?.length === 0 && disableCustomColors ); - const resetAllFilter = useCallback( ( previousValue ) => { return { ...previousValue, @@ -212,12 +207,9 @@ export default function FiltersPanel( {