|
@@ -23,16 +23,30 @@ type ColorPickerItemProps = {
|
|
|
|
|
|
|
|
function ColorPickerItem({ color }: ColorPickerItemProps) {
|
|
function ColorPickerItem({ color }: ColorPickerItemProps) {
|
|
|
const { selectColor, selectedColor, pickingCustomColor } = useSelectColor()
|
|
const { selectColor, selectedColor, pickingCustomColor } = useSelectColor()
|
|
|
|
|
+ const { t } = useTranslation()
|
|
|
|
|
+ const labelId = `color-picker-item-label-${color.replace('#', '')}`
|
|
|
|
|
+
|
|
|
|
|
+ function handleKeyDown(event: React.KeyboardEvent<HTMLDivElement>) {
|
|
|
|
|
+ if (event.key === 'Enter' || event.key === ' ') {
|
|
|
|
|
+ selectColor(color)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,
|
|
/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,
|
|
|
jsx-a11y/no-static-element-interactions, jsx-a11y/interactive-supports-focus */
|
|
jsx-a11y/no-static-element-interactions, jsx-a11y/interactive-supports-focus */
|
|
|
<div
|
|
<div
|
|
|
|
|
+ aria-labelledby={labelId}
|
|
|
className="color-picker-item"
|
|
className="color-picker-item"
|
|
|
|
|
+ onClick={() => selectColor(color)}
|
|
|
role="button"
|
|
role="button"
|
|
|
style={{ backgroundColor: color }}
|
|
style={{ backgroundColor: color }}
|
|
|
- onClick={() => selectColor(color)}
|
|
|
|
|
|
|
+ tabIndex={0}
|
|
|
|
|
+ onKeyDown={handleKeyDown}
|
|
|
>
|
|
>
|
|
|
|
|
+ <span id={labelId} className="sr-only">
|
|
|
|
|
+ {t('select_color', { color })}
|
|
|
|
|
+ </span>
|
|
|
{!pickingCustomColor && color === selectedColor && (
|
|
{!pickingCustomColor && color === selectedColor && (
|
|
|
<Icon type="check" className="color-picker-item-icon" />
|
|
<Icon type="check" className="color-picker-item-icon" />
|
|
|
)}
|
|
)}
|
|
@@ -41,7 +55,6 @@ function ColorPickerItem({ color }: ColorPickerItemProps) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function MoreButton() {
|
|
function MoreButton() {
|
|
|
- const { t } = useTranslation()
|
|
|
|
|
const {
|
|
const {
|
|
|
selectedColor,
|
|
selectedColor,
|
|
|
selectColor,
|
|
selectColor,
|
|
@@ -51,6 +64,7 @@ function MoreButton() {
|
|
|
setPickingCustomColor,
|
|
setPickingCustomColor,
|
|
|
} = useSelectColor()
|
|
} = useSelectColor()
|
|
|
const [localColor, setLocalColor] = useState<string>()
|
|
const [localColor, setLocalColor] = useState<string>()
|
|
|
|
|
+ const { t } = useTranslation()
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
setLocalColor(selectedColor)
|
|
setLocalColor(selectedColor)
|
|
@@ -59,6 +73,12 @@ function MoreButton() {
|
|
|
const isCustomColorSelected =
|
|
const isCustomColorSelected =
|
|
|
localColor && !PRESET_COLORS.includes(localColor)
|
|
localColor && !PRESET_COLORS.includes(localColor)
|
|
|
|
|
|
|
|
|
|
+ function handleKeyDown(event: React.KeyboardEvent<HTMLDivElement>) {
|
|
|
|
|
+ if (event.key === 'Enter' || event.key === ' ') {
|
|
|
|
|
+ showCustomPicker ? closeCustomPicker() : openCustomPicker()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<div className="color-picker-more-wrapper" data-content="My Content">
|
|
<div className="color-picker-more-wrapper" data-content="My Content">
|
|
|
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,
|
|
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,
|
|
@@ -72,6 +92,8 @@ function MoreButton() {
|
|
|
? localColor || selectedColor
|
|
? localColor || selectedColor
|
|
|
: 'white',
|
|
: 'white',
|
|
|
}}
|
|
}}
|
|
|
|
|
+ tabIndex={0}
|
|
|
|
|
+ onKeyDown={handleKeyDown}
|
|
|
>
|
|
>
|
|
|
<Tooltip
|
|
<Tooltip
|
|
|
id="tooltip-color-picker-plus"
|
|
id="tooltip-color-picker-plus"
|