Skip to content

Commit

Permalink
feat: add screen reader support
Browse files Browse the repository at this point in the history
  • Loading branch information
rkunev committed May 1, 2020
1 parent 1fdb705 commit 800b27e
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/ColorPicker.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<template>
<div
role="slider"
:aria-roledescription="ariaRoledescription"
:aria-label="ariaLabel"
:aria-expanded="isPaletteIn ? 'true' : 'false'"
aria-valuemin="0"
aria-valuemax="359"
:aria-valuenow="hue"
:aria-valuetext="ariaValuetext || valuetext"
:aria-disabled="disabled ? 'true' : 'false'"
class="rcp"
:class="{ dragging: isDragging, disabled: disabled }"
:tabindex="disabled ? -1 : 0"
Expand Down Expand Up @@ -29,6 +38,9 @@
<button
type="button"
class="rcp__well"
:aria-label="ariaLabelColorWell"
:disabled="disabled"
:tabindex="disabled ? -1 : 0"
:class="{ pressed: isPressed }"
:style="{ backgroundColor: color }"
@animationend="togglePicker"
Expand All @@ -41,6 +53,8 @@
import fillColorWheel from '@radial-color-picker/color-wheel';
import Rotator from '@radial-color-picker/rotator';
const colors = ['red', 'yellow', 'green', 'cyan', 'blue', 'magenta', 'red'];
export default {
rcp: null,
name: 'ColorPicker',
Expand Down Expand Up @@ -72,6 +86,18 @@ export default {
initiallyCollapsed: {
default: false,
},
ariaLabel: {
default: 'color picker',
},
ariaRoledescription: {
default: 'radial slider',
},
ariaValuetext: {
default: '',
},
ariaLabelColorWell: {
default: 'color well',
},
},
data() {
return {
Expand All @@ -87,6 +113,9 @@ export default {
color() {
return `hsla(${this.hue}, ${this.saturation}%, ${this.luminosity}%, ${this.alpha})`;
},
valuetext() {
return colors[Math.round(this.hue / 60)];
},
},
watch: {
hue: function (angle) {
Expand Down

0 comments on commit 800b27e

Please sign in to comment.