Skip to content

Commit acec93f

Browse files
committed
Implemented omgovich#177 PR
1 parent 12d86c5 commit acec93f

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

src/components/common/Alpha.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const Alpha = ({ className, hsva, onChange }: Props): JSX.Element => {
3535
};
3636

3737
const nodeClassName = formatClassName(["react-colorful__alpha", className]);
38+
const ariaValue = round(hsva.a * 100);
3839

3940
return (
4041
<div className={nodeClassName}>
@@ -43,7 +44,10 @@ export const Alpha = ({ className, hsva, onChange }: Props): JSX.Element => {
4344
onMove={handleMove}
4445
onKey={handleKey}
4546
aria-label="Alpha"
46-
aria-valuetext={`${round(hsva.a * 100)}%`}
47+
aria-valuetext={`${ariaValue}%`}
48+
aria-valuenow={ariaValue}
49+
aria-valuemin="0"
50+
aria-valuemax="100"
4751
>
4852
<Pointer
4953
className="react-colorful__alpha-pointer"

src/components/common/Hue.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ const HueBase = ({ className, hue, onChange }: Props) => {
3434
onMove={handleMove}
3535
onKey={handleKey}
3636
aria-label="Hue"
37-
aria-valuetext={round(hue)}
37+
aria-valuenow={round(hue)}
38+
aria-valuemax="360"
39+
aria-valuemin="0"
3840
>
3941
<Pointer
4042
className="react-colorful__hue-pointer"

tests/__snapshots__/components.test.js.snap

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ exports[`Accepts any valid \`div\` attributes 1`] = `
3333
>
3434
<div
3535
aria-label="Hue"
36-
aria-valuetext="0"
36+
aria-valuemax="360"
37+
aria-valuemin="0"
38+
aria-valuenow="0"
3739
class="react-colorful__interactive"
3840
role="slider"
3941
tabindex="0"
@@ -92,7 +94,9 @@ exports[`Renders proper alpha color picker markup 1`] = `
9294
>
9395
<div
9496
aria-label="Hue"
95-
aria-valuetext="0"
97+
aria-valuemax="360"
98+
aria-valuemin="0"
99+
aria-valuenow="0"
96100
class="react-colorful__interactive"
97101
role="slider"
98102
tabindex="0"
@@ -116,6 +120,9 @@ exports[`Renders proper alpha color picker markup 1`] = `
116120
/>
117121
<div
118122
aria-label="Alpha"
123+
aria-valuemax="100"
124+
aria-valuemin="0"
125+
aria-valuenow="50"
119126
aria-valuetext="50%"
120127
class="react-colorful__interactive"
121128
role="slider"
@@ -166,7 +173,9 @@ exports[`Renders proper color picker markup 1`] = `
166173
>
167174
<div
168175
aria-label="Hue"
169-
aria-valuetext="0"
176+
aria-valuemax="360"
177+
aria-valuemin="0"
178+
aria-valuenow="0"
170179
class="react-colorful__interactive"
171180
role="slider"
172181
tabindex="0"
@@ -216,7 +225,9 @@ exports[`Works with no props 1`] = `
216225
>
217226
<div
218227
aria-label="Hue"
219-
aria-valuetext="0"
228+
aria-valuemax="360"
229+
aria-valuemin="0"
230+
aria-valuenow="0"
220231
class="react-colorful__interactive"
221232
role="slider"
222233
tabindex="0"

0 commit comments

Comments
 (0)