Skip to content

Commit 1ada3db

Browse files
jongundmcking65
authored andcommitted
Color Viewer Slider: Improve high contrast support, touch AT support, and APG code quality guidelines support (w3c#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>
1 parent 2267e42 commit 1ada3db

File tree

8 files changed

+925
-653
lines changed

8 files changed

+925
-653
lines changed

examples/index.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ <h2 id="examples_by_role_label">Examples by Role</h2>
146146
<li><a href="carousel/carousel-1-prev-next.html">Auto-Rotating Image Carousel with Buttons for Slide Control</a></li>
147147
<li><a href="checkbox/checkbox-1/checkbox-1.html">Checkbox (Two State)</a></li>
148148
<li><a href="menubar/menubar-editor.html">Editor Menubar</a></li>
149+
<li><a href="slider/slider-color-viewer.html">Color Viewer Slider</a></li>
149150
<li><a href="spinbutton/datepicker-spinbuttons.html">Date Picker Spin Button</a></li>
150151
<li><a href="treeview/treeview-navigation.html">Navigation Treeview</a></li>
151152
</ul>
@@ -302,8 +303,8 @@ <h2 id="examples_by_role_label">Examples by Role</h2>
302303
<td>
303304
<ul>
304305
<li><a href="slider/multithumb-slider.html">Horizontal Multi-Thumb Slider</a></li>
305-
<li><a href="slider/slider-1.html">Horizontal Slider</a></li>
306306
<li><a href="slider/slider-2.html">Slider with aria-orientation and aria-valuetext</a></li>
307+
<li><a href="slider/slider-color-viewer.html">Color Viewer Slider</a></li>
307308
</ul>
308309
</td>
309310
</tr>
@@ -583,6 +584,7 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
583584
<li><a href="menubar/menubar-navigation.html">Navigation Menubar</a></li>
584585
<li><a href="radio/radio-activedescendant.html">Radio Group Using aria-activedescendant</a></li>
585586
<li><a href="radio/radio.html">Radio Group Using Roving tabindex</a></li>
587+
<li><a href="slider/slider-color-viewer.html">Color Viewer Slider</a></li>
586588
<li><a href="spinbutton/datepicker-spinbuttons.html">Date Picker Spin Button</a></li>
587589
<li><a href="table/table.html">Table</a></li>
588590
<li><a href="tabs/tabs-1/tabs.html">Tabs with Automatic Activation</a></li>
@@ -619,6 +621,7 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
619621
<li><a href="menubar/menubar-navigation.html">Navigation Menubar</a></li>
620622
<li><a href="radio/radio-activedescendant.html">Radio Group Using aria-activedescendant</a></li>
621623
<li><a href="radio/radio.html">Radio Group Using Roving tabindex</a></li>
624+
<li><a href="slider/slider-color-viewer.html">Color Viewer Slider</a></li>
622625
<li><a href="spinbutton/datepicker-spinbuttons.html">Date Picker Spin Button</a></li>
623626
<li><a href="tabs/tabs-1/tabs.html">Tabs with Automatic Activation</a></li>
624627
<li><a href="tabs/tabs-2/tabs.html">Tabs with Manual Activation</a></li>
@@ -761,8 +764,8 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
761764
<ul>
762765
<li><a href="meter/meter.html">Meter</a></li>
763766
<li><a href="slider/multithumb-slider.html">Horizontal Multi-Thumb Slider</a></li>
764-
<li><a href="slider/slider-1.html">Horizontal Slider</a></li>
765767
<li><a href="slider/slider-2.html">Slider with aria-orientation and aria-valuetext</a></li>
768+
<li><a href="slider/slider-color-viewer.html">Color Viewer Slider</a></li>
766769
<li><a href="spinbutton/datepicker-spinbuttons.html">Date Picker Spin Button</a></li>
767770
</ul>
768771
</td>
@@ -773,8 +776,8 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
773776
<ul>
774777
<li><a href="meter/meter.html">Meter</a></li>
775778
<li><a href="slider/multithumb-slider.html">Horizontal Multi-Thumb Slider</a></li>
776-
<li><a href="slider/slider-1.html">Horizontal Slider</a></li>
777779
<li><a href="slider/slider-2.html">Slider with aria-orientation and aria-valuetext</a></li>
780+
<li><a href="slider/slider-color-viewer.html">Color Viewer Slider</a></li>
778781
<li><a href="spinbutton/datepicker-spinbuttons.html">Date Picker Spin Button</a></li>
779782
<li><a href="toolbar/toolbar.html">Toolbar</a></li>
780783
</ul>
@@ -786,8 +789,8 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
786789
<ul>
787790
<li><a href="meter/meter.html">Meter</a></li>
788791
<li><a href="slider/multithumb-slider.html">Horizontal Multi-Thumb Slider</a></li>
789-
<li><a href="slider/slider-1.html">Horizontal Slider</a></li>
790792
<li><a href="slider/slider-2.html">Slider with aria-orientation and aria-valuetext</a></li>
793+
<li><a href="slider/slider-color-viewer.html">Color Viewer Slider</a></li>
791794
<li><a href="spinbutton/datepicker-spinbuttons.html">Date Picker Spin Button</a></li>
792795
<li><a href="toolbar/toolbar.html">Toolbar</a></li>
793796
</ul>
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/* CSS Document */
2+
3+
.color-viewer-sliders label {
4+
display: block;
5+
}
6+
7+
.color-viewer-sliders .color-box {
8+
width: 200px;
9+
height: 200px;
10+
border: black solid medium;
11+
text-align: center;
12+
padding: 0.25em;
13+
forced-color-adjust: none;
14+
}
15+
16+
.color-viewer-sliders .color-info {
17+
padding-top: 5px;
18+
}
19+
20+
.color-viewer-sliders .color-info label {
21+
margin-top: 0.25em;
22+
display: block;
23+
}
24+
25+
.color-slider {
26+
margin: 0;
27+
margin-bottom: 1em;
28+
padding: 2px;
29+
touch-action: pan-y;
30+
width: 350px;
31+
outline: none;
32+
}
33+
34+
.color-slider div,
35+
.color-slider svg {
36+
display: block;
37+
width: 350px;
38+
}
39+
40+
.color-slider-label {
41+
margin: 0;
42+
padding: 0;
43+
font-weight: bold;
44+
}
45+
46+
.color-slider .value {
47+
color: currentColor;
48+
fill: currentColor;
49+
}
50+
51+
.color-slider .valueBackground {
52+
fill: white;
53+
stroke-width: 0;
54+
}
55+
56+
.color-slider .rail {
57+
fill: #bbb;
58+
stroke: currentColor;
59+
stroke-width: 2px;
60+
opacity: 0.8;
61+
}
62+
63+
.color-slider .fill {
64+
stroke-width: 0;
65+
opacity: 0.5;
66+
pointer-events: none;
67+
}
68+
69+
.color-slider.red .fill {
70+
fill: red;
71+
}
72+
73+
.color-slider.green .fill {
74+
fill: green;
75+
}
76+
77+
.color-slider.blue .fill {
78+
fill: blue;
79+
}
80+
81+
.color-slider .thumb {
82+
fill: #666;
83+
stroke: currentColor;
84+
stroke-width: 2px;
85+
}
86+
87+
.color-slider .focus {
88+
fill: transparent;
89+
stroke: transparent;
90+
stroke-width: 2px;
91+
}
92+
93+
.color-slider:focus .value,
94+
.color-slider:hover .value {
95+
font-weight: bold;
96+
}
97+
98+
.color-slider:focus .fill,
99+
.color-slider:hover .fill {
100+
opacity: 1;
101+
}
102+
103+
.color-slider:focus .rail,
104+
.color-slider:hover .rail {
105+
fill: transparent;
106+
stroke: currentColor;
107+
opacity: 1;
108+
}
109+
110+
.color-slider:focus .thumb,
111+
.color-slider:hover .thumb {
112+
fill: #ddd;
113+
stroke: currentColor;
114+
opacity: 1;
115+
}
116+
117+
.color-slider:focus .focus,
118+
.color-slider:hover .focus {
119+
stroke: currentColor;
120+
}

examples/slider/css/slider.css

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)