Skip to content

Commit

Permalink
Implemented omgovich#177 PR
Browse files Browse the repository at this point in the history
  • Loading branch information
royeden committed Jun 24, 2022
1 parent 12d86c5 commit acec93f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/components/common/Alpha.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const Alpha = ({ className, hsva, onChange }: Props): JSX.Element => {
};

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

return (
<div className={nodeClassName}>
Expand All @@ -43,7 +44,10 @@ export const Alpha = ({ className, hsva, onChange }: Props): JSX.Element => {
onMove={handleMove}
onKey={handleKey}
aria-label="Alpha"
aria-valuetext={`${round(hsva.a * 100)}%`}
aria-valuetext={`${ariaValue}%`}
aria-valuenow={ariaValue}
aria-valuemin="0"
aria-valuemax="100"
>
<Pointer
className="react-colorful__alpha-pointer"
Expand Down
4 changes: 3 additions & 1 deletion src/components/common/Hue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ const HueBase = ({ className, hue, onChange }: Props) => {
onMove={handleMove}
onKey={handleKey}
aria-label="Hue"
aria-valuetext={round(hue)}
aria-valuenow={round(hue)}
aria-valuemax="360"
aria-valuemin="0"
>
<Pointer
className="react-colorful__hue-pointer"
Expand Down
19 changes: 15 additions & 4 deletions tests/__snapshots__/components.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ exports[`Accepts any valid \`div\` attributes 1`] = `
>
<div
aria-label="Hue"
aria-valuetext="0"
aria-valuemax="360"
aria-valuemin="0"
aria-valuenow="0"
class="react-colorful__interactive"
role="slider"
tabindex="0"
Expand Down Expand Up @@ -92,7 +94,9 @@ exports[`Renders proper alpha color picker markup 1`] = `
>
<div
aria-label="Hue"
aria-valuetext="0"
aria-valuemax="360"
aria-valuemin="0"
aria-valuenow="0"
class="react-colorful__interactive"
role="slider"
tabindex="0"
Expand All @@ -116,6 +120,9 @@ exports[`Renders proper alpha color picker markup 1`] = `
/>
<div
aria-label="Alpha"
aria-valuemax="100"
aria-valuemin="0"
aria-valuenow="50"
aria-valuetext="50%"
class="react-colorful__interactive"
role="slider"
Expand Down Expand Up @@ -166,7 +173,9 @@ exports[`Renders proper color picker markup 1`] = `
>
<div
aria-label="Hue"
aria-valuetext="0"
aria-valuemax="360"
aria-valuemin="0"
aria-valuenow="0"
class="react-colorful__interactive"
role="slider"
tabindex="0"
Expand Down Expand Up @@ -216,7 +225,9 @@ exports[`Works with no props 1`] = `
>
<div
aria-label="Hue"
aria-valuetext="0"
aria-valuemax="360"
aria-valuemin="0"
aria-valuenow="0"
class="react-colorful__interactive"
role="slider"
tabindex="0"
Expand Down

0 comments on commit acec93f

Please sign in to comment.