Skip to content

Commit 800b27e

Browse files
committed
feat: add screen reader support
1 parent 1fdb705 commit 800b27e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/ColorPicker.vue

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<template>
22
<div
3+
role="slider"
4+
:aria-roledescription="ariaRoledescription"
5+
:aria-label="ariaLabel"
6+
:aria-expanded="isPaletteIn ? 'true' : 'false'"
7+
aria-valuemin="0"
8+
aria-valuemax="359"
9+
:aria-valuenow="hue"
10+
:aria-valuetext="ariaValuetext || valuetext"
11+
:aria-disabled="disabled ? 'true' : 'false'"
312
class="rcp"
413
:class="{ dragging: isDragging, disabled: disabled }"
514
:tabindex="disabled ? -1 : 0"
@@ -29,6 +38,9 @@
2938
<button
3039
type="button"
3140
class="rcp__well"
41+
:aria-label="ariaLabelColorWell"
42+
:disabled="disabled"
43+
:tabindex="disabled ? -1 : 0"
3244
:class="{ pressed: isPressed }"
3345
:style="{ backgroundColor: color }"
3446
@animationend="togglePicker"
@@ -41,6 +53,8 @@
4153
import fillColorWheel from '@radial-color-picker/color-wheel';
4254
import Rotator from '@radial-color-picker/rotator';
4355
56+
const colors = ['red', 'yellow', 'green', 'cyan', 'blue', 'magenta', 'red'];
57+
4458
export default {
4559
rcp: null,
4660
name: 'ColorPicker',
@@ -72,6 +86,18 @@ export default {
7286
initiallyCollapsed: {
7387
default: false,
7488
},
89+
ariaLabel: {
90+
default: 'color picker',
91+
},
92+
ariaRoledescription: {
93+
default: 'radial slider',
94+
},
95+
ariaValuetext: {
96+
default: '',
97+
},
98+
ariaLabelColorWell: {
99+
default: 'color well',
100+
},
75101
},
76102
data() {
77103
return {
@@ -87,6 +113,9 @@ export default {
87113
color() {
88114
return `hsla(${this.hue}, ${this.saturation}%, ${this.luminosity}%, ${this.alpha})`;
89115
},
116+
valuetext() {
117+
return colors[Math.round(this.hue / 60)];
118+
},
90119
},
91120
watch: {
92121
hue: function (angle) {

0 commit comments

Comments
 (0)