Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ exports[`ColorPaletteControl matches the snapshot 1`] = `
style={
Object {
"background": "#f00",
"color": "#000",
}
}
>
Expand Down
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

### Bug Fix

- Improve accessibility and visibility in `ColorPallete` ([#36925](https://github.com/WordPress/gutenberg/pull/36925))
- Fixed spacing between `BaseControl` fields and help text within the `ToolsPanel` ([#36334](https://github.com/WordPress/gutenberg/pull/36334))
- Replaced hardcoded blue in `ColorPicker` with UI theme color ([#36153](https://github.com/WordPress/gutenberg/pull/36153)).
- Fixed empty `ToolsPanel` height by correcting menu button line-height ([#36895](https://github.com/WordPress/gutenberg/pull/36895)).
Expand Down
12 changes: 11 additions & 1 deletion packages/components/src/color-palette/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function SinglePalette( {
const colorOptions = useMemo( () => {
return map( colors, ( { color, name } ) => {
const colordColor = colord( color );

return (
<CircularOptionPicker.Option
key={ color }
Expand Down Expand Up @@ -133,6 +134,8 @@ export default function ColorPalette( {
/>
);

const colordColor = colord( value );

return (
<VStack spacing={ 3 } className={ className }>
{ ! disableCustomColors && (
Expand All @@ -151,7 +154,14 @@ export default function ColorPalette( {
aria-haspopup="true"
onClick={ onToggle }
aria-label={ __( 'Custom color picker' ) }
style={ { background: value } }
style={ {
background: value,
color:
colordColor.contrast() >
colordColor.contrast( '#000' )
? '#fff'
: '#000',
} }
>
{ value }
</button>
Expand Down
11 changes: 10 additions & 1 deletion packages/components/src/color-palette/style.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.components-color-palette__custom-color {
position: relative;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This relative position was probably needed for the abs positioned pseudo element but isn't needed anymore.

border: none;
background: none;
outline: 0;
display: block;
border-radius: $radius-block-ui;
height: $grid-unit-60;
Expand All @@ -15,6 +15,15 @@
box-sizing: border-box;
color: $white;
cursor: pointer;
box-shadow: inset 0 0 0 $border-width rgba(0, 0, 0, 0.2);
// Show a thin outline in Windows high contrast mode.
outline: 1px solid transparent;

&:focus {
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
// Show a outline in Windows high contrast mode.
outline-width: 2px;
}
}

.components-dropdown__content.components-color-palette__custom-color-dropdown-content .components-popover__content {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ exports[`ColorPalette Dropdown .renderToggle should render dropdown content 1`]
style={
Object {
"background": "#f00",
"color": "#000",
}
}
>
Expand Down Expand Up @@ -44,6 +45,7 @@ exports[`ColorPalette Dropdown should render it correctly 1`] = `
style={
Object {
"background": "#f00",
"color": "#000",
}
}
>
Expand Down Expand Up @@ -196,6 +198,7 @@ exports[`ColorPalette should render a dynamic toolbar of colors 1`] = `
style={
Object {
"background": "#f00",
"color": "#000",
}
}
>
Expand Down