Skip to content

Commit

Permalink
Add all color palettes to select from editor panel (#65148)
Browse files Browse the repository at this point in the history
* Add all the colors in with-color-context so that they all are listed in block editor

* Remove default colour pallete

* Remove extra space

* Update packages/block-editor/src/components/color-palette/with-color-context.js

re-add default colours

Co-authored-by: Aki Hamano <[email protected]>

* Add default colours if enabled

* Update packages/block-editor/src/components/color-palette/with-color-context.js

Co-authored-by: Aki Hamano <[email protected]>

* update test

---------

Unlinked contributors: EddyBoels, burnuser.

Co-authored-by: AKSHAT2802 <[email protected]>
Co-authored-by: richtabor <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: ndiego <[email protected]>
Co-authored-by: rohitmathur-7 <[email protected]>
Co-authored-by: javiercasares <[email protected]>
  • Loading branch information
7 people authored Nov 22, 2024
1 parent 4d2fb64 commit 452de1b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,32 @@ import { useSettings } from '../use-settings';

export default createHigherOrderComponent( ( WrappedComponent ) => {
return ( props ) => {
const [ colorsFeature, enableCustomColors ] = useSettings(
'color.palette',
'color.custom'
// Get the default colors, theme colors, and custom colors
const [
defaultColors,
themeColors,
customColors,
enableCustomColors,
enableDefaultColors,
] = useSettings(
'color.palette.default',
'color.palette.theme',
'color.palette.custom',
'color.custom',
'color.defaultPalette'
);
const {
colors = colorsFeature,
disableCustomColors = ! enableCustomColors,
} = props;

const _colors = enableDefaultColors
? [
...( themeColors || [] ),
...( defaultColors || [] ),
...( customColors || [] ),
]
: [ ...( themeColors || [] ), ...( customColors || [] ) ];

const { colors = _colors, disableCustomColors = ! enableCustomColors } =
props;

const hasColorsToChoose =
( colors && colors.length > 0 ) || ! disableCustomColors;
return (
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/cover/test/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' } )
);
Expand All @@ -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' } )
);
Expand Down

0 comments on commit 452de1b

Please sign in to comment.