From fca97c94d69b7000ae66f604b677413f90d45f74 Mon Sep 17 00:00:00 2001 From: AKSHAT2802 Date: Mon, 9 Sep 2024 16:54:07 +0530 Subject: [PATCH 1/7] Add all the colors in with-color-context so that they all are listed in block editor --- .../color-palette/with-color-context.js | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/block-editor/src/components/color-palette/with-color-context.js b/packages/block-editor/src/components/color-palette/with-color-context.js index 62b8c1bc4b618..e8cc9a0e65fc1 100644 --- a/packages/block-editor/src/components/color-palette/with-color-context.js +++ b/packages/block-editor/src/components/color-palette/with-color-context.js @@ -10,16 +10,26 @@ import { useSettings } from '../use-settings'; export default createHigherOrderComponent( ( WrappedComponent ) => { return ( props ) => { - const [ colorsFeature, enableCustomColors ] = useSettings( - 'color.palette', - 'color.custom' - ); - const { - colors = colorsFeature, - disableCustomColors = ! enableCustomColors, - } = props; + // Get the default colors, theme colors, and custom colors + const [ defaultColors, themeColors, customColors, enableCustomColors ] = + useSettings( + 'color.palette.default', + 'color.palette.theme', + 'color.palette.custom', + 'color.custom' + ); + + const colors = [ + ...( defaultColors || [] ), + ...( themeColors || [] ), + ...( customColors || [] ), + ]; + + const { disableCustomColors = ! enableCustomColors } = props; + const hasColorsToChoose = ( colors && colors.length > 0 ) || ! disableCustomColors; + return ( Date: Wed, 13 Nov 2024 01:40:12 +0530 Subject: [PATCH 2/7] Remove default colour pallete --- .../color-palette/with-color-context.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/packages/block-editor/src/components/color-palette/with-color-context.js b/packages/block-editor/src/components/color-palette/with-color-context.js index e8cc9a0e65fc1..41da7b06096b3 100644 --- a/packages/block-editor/src/components/color-palette/with-color-context.js +++ b/packages/block-editor/src/components/color-palette/with-color-context.js @@ -11,19 +11,13 @@ import { useSettings } from '../use-settings'; export default createHigherOrderComponent( ( WrappedComponent ) => { return ( props ) => { // Get the default colors, theme colors, and custom colors - const [ defaultColors, themeColors, customColors, enableCustomColors ] = - useSettings( - 'color.palette.default', - 'color.palette.theme', - 'color.palette.custom', - 'color.custom' - ); + const [ themeColors, customColors, enableCustomColors ] = useSettings( + 'color.palette.theme', + 'color.palette.custom', + 'color.custom' + ); - const colors = [ - ...( defaultColors || [] ), - ...( themeColors || [] ), - ...( customColors || [] ), - ]; + const colors = [ ...( themeColors || [] ), ...( customColors || [] ) ]; const { disableCustomColors = ! enableCustomColors } = props; From df3c90b2c284607fbd99f9ed2663af56f8d421f1 Mon Sep 17 00:00:00 2001 From: AKSHAT2802 Date: Wed, 13 Nov 2024 01:41:28 +0530 Subject: [PATCH 3/7] Remove extra space --- .../src/components/color-palette/with-color-context.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/block-editor/src/components/color-palette/with-color-context.js b/packages/block-editor/src/components/color-palette/with-color-context.js index 41da7b06096b3..a026a4e65903d 100644 --- a/packages/block-editor/src/components/color-palette/with-color-context.js +++ b/packages/block-editor/src/components/color-palette/with-color-context.js @@ -23,7 +23,6 @@ export default createHigherOrderComponent( ( WrappedComponent ) => { const hasColorsToChoose = ( colors && colors.length > 0 ) || ! disableCustomColors; - return ( Date: Wed, 13 Nov 2024 19:22:37 +0530 Subject: [PATCH 4/7] Update packages/block-editor/src/components/color-palette/with-color-context.js re-add default colours Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com> --- .../src/components/color-palette/with-color-context.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/color-palette/with-color-context.js b/packages/block-editor/src/components/color-palette/with-color-context.js index a026a4e65903d..8ec65b73d5704 100644 --- a/packages/block-editor/src/components/color-palette/with-color-context.js +++ b/packages/block-editor/src/components/color-palette/with-color-context.js @@ -17,7 +17,7 @@ export default createHigherOrderComponent( ( WrappedComponent ) => { 'color.custom' ); - const colors = [ ...( themeColors || [] ), ...( customColors || [] ) ]; + const colors = [ ...themeColors, ...defaultColors, ...customColors ]; const { disableCustomColors = ! enableCustomColors } = props; From fa7ac85b79d576a4554c28dae3f3aad59d3a7f18 Mon Sep 17 00:00:00 2001 From: AKSHAT2802 Date: Thu, 14 Nov 2024 15:33:13 +0530 Subject: [PATCH 5/7] Add default colours if enabled --- .../color-palette/with-color-context.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/block-editor/src/components/color-palette/with-color-context.js b/packages/block-editor/src/components/color-palette/with-color-context.js index 8ec65b73d5704..ceb2165de9564 100644 --- a/packages/block-editor/src/components/color-palette/with-color-context.js +++ b/packages/block-editor/src/components/color-palette/with-color-context.js @@ -11,13 +11,23 @@ import { useSettings } from '../use-settings'; export default createHigherOrderComponent( ( WrappedComponent ) => { return ( props ) => { // Get the default colors, theme colors, and custom colors - const [ themeColors, customColors, enableCustomColors ] = useSettings( + const [ + defaultColors, + themeColors, + customColors, + enableCustomColors, + enableDefaultColors, + ] = useSettings( + 'color.palette.default', 'color.palette.theme', 'color.palette.custom', - 'color.custom' + 'color.custom', + 'color.defaultPalette' ); - const colors = [ ...themeColors, ...defaultColors, ...customColors ]; + const colors = enableDefaultColors + ? themeColors.concat( defaultColors, customColors ) + : themeColors.concat( customColors ); const { disableCustomColors = ! enableCustomColors } = props; From 5d9668cb9c5bf8d6d5ac7cd58c49863592512ba9 Mon Sep 17 00:00:00 2001 From: Akshat Kakkad <87222220+AKSHAT2802@users.noreply.github.com> Date: Sun, 17 Nov 2024 22:57:02 +0530 Subject: [PATCH 6/7] Update packages/block-editor/src/components/color-palette/with-color-context.js Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com> --- .../components/color-palette/with-color-context.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/block-editor/src/components/color-palette/with-color-context.js b/packages/block-editor/src/components/color-palette/with-color-context.js index ceb2165de9564..38c90531edaac 100644 --- a/packages/block-editor/src/components/color-palette/with-color-context.js +++ b/packages/block-editor/src/components/color-palette/with-color-context.js @@ -25,11 +25,16 @@ export default createHigherOrderComponent( ( WrappedComponent ) => { 'color.defaultPalette' ); - const colors = enableDefaultColors - ? themeColors.concat( defaultColors, customColors ) - : themeColors.concat( customColors ); + const _colors = enableDefaultColors + ? [ + ...( themeColors || [] ), + ...( defaultColors || [] ), + ...( customColors || [] ), + ] + : [ ...( themeColors || [] ), ...( customColors || [] ) ]; - const { disableCustomColors = ! enableCustomColors } = props; + const { colors = _colors, disableCustomColors = ! enableCustomColors } = + props; const hasColorsToChoose = ( colors && colors.length > 0 ) || ! disableCustomColors; From 89a00a2fa9875444e989ac3716b7ac34e656f45e Mon Sep 17 00:00:00 2001 From: Rich Tabor Date: Thu, 21 Nov 2024 17:46:28 -0500 Subject: [PATCH 7/7] update test --- packages/block-library/src/cover/test/edit.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/cover/test/edit.js b/packages/block-library/src/cover/test/edit.js index 5c1a5b5e13e67..f5d6a5301ef6d 100644 --- a/packages/block-library/src/cover/test/edit.js +++ b/packages/block-library/src/cover/test/edit.js @@ -337,7 +337,7 @@ describe( 'Cover block', () => { describe( 'when colors are disabled', () => { test( 'does not render overlay control', async () => { await setup( undefined, true, disabledColorSettings ); - await createAndSelectBlock(); + await selectBlock( 'Block: Cover' ); await userEvent.click( screen.getByRole( 'tab', { name: 'Styles' } ) ); @@ -350,7 +350,7 @@ describe( 'Cover block', () => { } ); test( 'does not render opacity control', async () => { await setup( undefined, true, disabledColorSettings ); - await createAndSelectBlock(); + await selectBlock( 'Block: Cover' ); await userEvent.click( screen.getByRole( 'tab', { name: 'Styles' } ) );