Adds proper aria-label to gradient knobs

This commit is contained in:
Josh Perez 2023-05-04 22:49:00 -04:00
parent f69c533d23
commit 80d37e2df1
3 changed files with 14 additions and 2 deletions

View file

@ -9810,6 +9810,14 @@
"messageformat": "Custom Color", "messageformat": "Custom Color",
"description": "Modal title for the custom color editor" "description": "Modal title for the custom color editor"
}, },
"icu:GradientDial__knob-start": {
"messageformat": "Gradient start",
"description": "aria-label for the custom color gradient creator knob"
},
"icu:GradientDial__knob-end": {
"messageformat": "Gradient end",
"description": "aria-label for the custom color gradient creator knob"
},
"customDisappearingTimeOption": { "customDisappearingTimeOption": {
"message": "Custom time...", "message": "Custom time...",
"description": "(deleted 03/29/2023) Text for an option in Disappearing Messages menu and Conversation Details Disappearing Messages setting when no user value is available" "description": "(deleted 03/29/2023) Text for an option in Disappearing Messages menu and Conversation Details Disappearing Messages setting when no user value is available"

View file

@ -99,6 +99,7 @@ export function CustomColorEditor({
<div data-supertab> <div data-supertab>
<GradientDial <GradientDial
deg={color.deg} deg={color.deg}
i18n={i18n}
knob1Style={{ backgroundColor: getHSL(color.start) }} knob1Style={{ backgroundColor: getHSL(color.start) }}
knob2Style={{ knob2Style={{
backgroundColor: getHSL( backgroundColor: getHSL(

View file

@ -5,6 +5,7 @@ import type { CSSProperties, KeyboardEvent } from 'react';
import React, { useEffect, useRef, useState } from 'react'; import React, { useEffect, useRef, useState } from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import { arrow } from '../util/keyboard'; import { arrow } from '../util/keyboard';
import type { LocalizerType } from '../types/Util';
export enum KnobType { export enum KnobType {
start = 'start', start = 'start',
@ -13,6 +14,7 @@ export enum KnobType {
export type PropsType = { export type PropsType = {
deg?: number; deg?: number;
i18n: LocalizerType;
knob1Style: CSSProperties; knob1Style: CSSProperties;
knob2Style: CSSProperties; knob2Style: CSSProperties;
onChange: (deg: number) => unknown; onChange: (deg: number) => unknown;
@ -187,6 +189,7 @@ function getKnobCoordinates(
export function GradientDial({ export function GradientDial({
deg = 180, deg = 180,
i18n,
knob1Style, knob1Style,
knob2Style, knob2Style,
onChange, onChange,
@ -274,7 +277,7 @@ export function GradientDial({
<div className="GradientDial__container" ref={containerRef}> <div className="GradientDial__container" ref={containerRef}>
{knobDim.start && ( {knobDim.start && (
<div <div
aria-label="0" aria-label={i18n('icu:GradientDial__knob-start')}
className={classNames('GradientDial__knob', { className={classNames('GradientDial__knob', {
'GradientDial__knob--selected': selectedKnob === KnobType.start, 'GradientDial__knob--selected': selectedKnob === KnobType.start,
})} })}
@ -297,7 +300,7 @@ export function GradientDial({
)} )}
{knobDim.end && ( {knobDim.end && (
<div <div
aria-label="1" aria-label={i18n('icu:GradientDial__knob-end')}
className={classNames('GradientDial__knob', { className={classNames('GradientDial__knob', {
'GradientDial__knob--selected': selectedKnob === KnobType.end, 'GradientDial__knob--selected': selectedKnob === KnobType.end,
})} })}