Skip to content

Commit

Permalink
Color Viewer Slider: Improve high contrast support, touch AT support,…
Browse files Browse the repository at this point in the history
… and APG code quality guidelines support (#1746)

Makes the following changes to the color viewer slider example:
* Align with current APG code quality guidelines, including using a single object for the color viewer.
* Use SVG graphic elements instead of HTML elements for the visual rendering.
* Use currentColor  value for SVG stroke  property to support high contrast modes in operating systems.
* Use event.key  instead of event.keyCode for responding to keyboard events, which also provides support for iOS and Android screen readers.
* Updated focus styling to have a ring around the thumb.
* Use pointer  events instead of mouse  events, which provides support  for moving the slider thumb with touch.
* Added group  role and accessible name for the color viewer widget.

Co-authored-by: Matt King <a11yThinker@gmail.com>
  • Loading branch information
jongund and mcking65 authored Mar 3, 2021
1 parent 0e7acce commit dec293c
Show file tree
Hide file tree
Showing 8 changed files with 925 additions and 653 deletions.
11 changes: 7 additions & 4 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ <h2 id="examples_by_role_label">Examples by Role</h2>
<li><a href="carousel/carousel-1-prev-next.html">Auto-Rotating Image Carousel with Buttons for Slide Control</a></li>
<li><a href="checkbox/checkbox-1/checkbox-1.html">Checkbox (Two State)</a></li>
<li><a href="menubar/menubar-editor.html">Editor Menubar</a></li>
<li><a href="slider/slider-color-viewer.html">Color Viewer Slider</a></li>
<li><a href="spinbutton/datepicker-spinbuttons.html">Date Picker Spin Button</a></li>
<li><a href="treeview/treeview-navigation.html">Navigation Treeview</a></li>
</ul>
Expand Down Expand Up @@ -302,8 +303,8 @@ <h2 id="examples_by_role_label">Examples by Role</h2>
<td>
<ul>
<li><a href="slider/multithumb-slider.html">Horizontal Multi-Thumb Slider</a></li>
<li><a href="slider/slider-1.html">Horizontal Slider</a></li>
<li><a href="slider/slider-2.html">Slider with aria-orientation and aria-valuetext</a></li>
<li><a href="slider/slider-color-viewer.html">Color Viewer Slider</a></li>
</ul>
</td>
</tr>
Expand Down Expand Up @@ -583,6 +584,7 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
<li><a href="menubar/menubar-navigation.html">Navigation Menubar</a></li>
<li><a href="radio/radio-activedescendant.html">Radio Group Using aria-activedescendant</a></li>
<li><a href="radio/radio.html">Radio Group Using Roving tabindex</a></li>
<li><a href="slider/slider-color-viewer.html">Color Viewer Slider</a></li>
<li><a href="spinbutton/datepicker-spinbuttons.html">Date Picker Spin Button</a></li>
<li><a href="table/table.html">Table</a></li>
<li><a href="tabs/tabs-1/tabs.html">Tabs with Automatic Activation</a></li>
Expand Down Expand Up @@ -619,6 +621,7 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
<li><a href="menubar/menubar-navigation.html">Navigation Menubar</a></li>
<li><a href="radio/radio-activedescendant.html">Radio Group Using aria-activedescendant</a></li>
<li><a href="radio/radio.html">Radio Group Using Roving tabindex</a></li>
<li><a href="slider/slider-color-viewer.html">Color Viewer Slider</a></li>
<li><a href="spinbutton/datepicker-spinbuttons.html">Date Picker Spin Button</a></li>
<li><a href="tabs/tabs-1/tabs.html">Tabs with Automatic Activation</a></li>
<li><a href="tabs/tabs-2/tabs.html">Tabs with Manual Activation</a></li>
Expand Down Expand Up @@ -761,8 +764,8 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
<ul>
<li><a href="meter/meter.html">Meter</a></li>
<li><a href="slider/multithumb-slider.html">Horizontal Multi-Thumb Slider</a></li>
<li><a href="slider/slider-1.html">Horizontal Slider</a></li>
<li><a href="slider/slider-2.html">Slider with aria-orientation and aria-valuetext</a></li>
<li><a href="slider/slider-color-viewer.html">Color Viewer Slider</a></li>
<li><a href="spinbutton/datepicker-spinbuttons.html">Date Picker Spin Button</a></li>
</ul>
</td>
Expand All @@ -773,8 +776,8 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
<ul>
<li><a href="meter/meter.html">Meter</a></li>
<li><a href="slider/multithumb-slider.html">Horizontal Multi-Thumb Slider</a></li>
<li><a href="slider/slider-1.html">Horizontal Slider</a></li>
<li><a href="slider/slider-2.html">Slider with aria-orientation and aria-valuetext</a></li>
<li><a href="slider/slider-color-viewer.html">Color Viewer Slider</a></li>
<li><a href="spinbutton/datepicker-spinbuttons.html">Date Picker Spin Button</a></li>
<li><a href="toolbar/toolbar.html">Toolbar</a></li>
</ul>
Expand All @@ -786,8 +789,8 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
<ul>
<li><a href="meter/meter.html">Meter</a></li>
<li><a href="slider/multithumb-slider.html">Horizontal Multi-Thumb Slider</a></li>
<li><a href="slider/slider-1.html">Horizontal Slider</a></li>
<li><a href="slider/slider-2.html">Slider with aria-orientation and aria-valuetext</a></li>
<li><a href="slider/slider-color-viewer.html">Color Viewer Slider</a></li>
<li><a href="spinbutton/datepicker-spinbuttons.html">Date Picker Spin Button</a></li>
<li><a href="toolbar/toolbar.html">Toolbar</a></li>
</ul>
Expand Down
120 changes: 120 additions & 0 deletions examples/slider/css/slider-color-viewer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
/* CSS Document */

.color-viewer-sliders label {
display: block;
}

.color-viewer-sliders .color-box {
width: 200px;
height: 200px;
border: black solid medium;
text-align: center;
padding: 0.25em;
forced-color-adjust: none;
}

.color-viewer-sliders .color-info {
padding-top: 5px;
}

.color-viewer-sliders .color-info label {
margin-top: 0.25em;
display: block;
}

.color-slider {
margin: 0;
margin-bottom: 1em;
padding: 2px;
touch-action: pan-y;
width: 350px;
outline: none;
}

.color-slider div,
.color-slider svg {
display: block;
width: 350px;
}

.color-slider-label {
margin: 0;
padding: 0;
font-weight: bold;
}

.color-slider .value {
color: currentColor;
fill: currentColor;
}

.color-slider .valueBackground {
fill: white;
stroke-width: 0;
}

.color-slider .rail {
fill: #bbb;
stroke: currentColor;
stroke-width: 2px;
opacity: 0.8;
}

.color-slider .fill {
stroke-width: 0;
opacity: 0.5;
pointer-events: none;
}

.color-slider.red .fill {
fill: red;
}

.color-slider.green .fill {
fill: green;
}

.color-slider.blue .fill {
fill: blue;
}

.color-slider .thumb {
fill: #666;
stroke: currentColor;
stroke-width: 2px;
}

.color-slider .focus {
fill: transparent;
stroke: transparent;
stroke-width: 2px;
}

.color-slider:focus .value,
.color-slider:hover .value {
font-weight: bold;
}

.color-slider:focus .fill,
.color-slider:hover .fill {
opacity: 1;
}

.color-slider:focus .rail,
.color-slider:hover .rail {
fill: transparent;
stroke: currentColor;
opacity: 1;
}

.color-slider:focus .thumb,
.color-slider:hover .thumb {
fill: #ddd;
stroke: currentColor;
opacity: 1;
}

.color-slider:focus .focus,
.color-slider:hover .focus {
stroke: currentColor;
}
59 changes: 0 additions & 59 deletions examples/slider/css/slider.css

This file was deleted.

Loading

0 comments on commit dec293c

Please sign in to comment.