Skip to content

Commit

Permalink
Add a vertical temperature slider example (pull #1864)
Browse files Browse the repository at this point in the history
Replacement for temperature slider that was part of previous thermostat example.
* Simplifies the example by including only one slider on the page
* Uses aria-valuetext for unit of measure
* Uses SVG graphics elements 
* Increased size of clickable area on rail to change value with pointing device 
* Improves high contrast support 
* Implements latest APG coding practices, including conversion to event.key and pointer events 

Co-authored-by: Matt King <a11yThinker@gmail.com>
  • Loading branch information
jongund and mcking65 authored May 23, 2021
1 parent 35bff94 commit 1379b72
Show file tree
Hide file tree
Showing 9 changed files with 1,171 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .vnurc
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ The “row” role is unnecessary for element “tr”.
Attribute “aria-activedescendant” value should either refer to a descendant element, or should be accompanied by attribute “aria-owns”.
# https://github.com/w3c/aria-practices/issues/1678
Section lacks heading. Consider using “h2”-“h6” elements to add identifying headings to all sections.
# https://github.com/validator/validator/issues/1096
Bad value “none” for attribute “role” on element “svg”.
Bad value “presentation” for attribute “role” on element “svg”.
5 changes: 3 additions & 2 deletions aria-practices.html
Original file line number Diff line number Diff line change
Expand Up @@ -2361,8 +2361,9 @@ <h3>Slider</h3>
<section class="notoc">
<h4>Examples</h4>
<ul>
<li><a href="examples/slider/slider-color-viewer.html">Color Viewer Slider Examples</a>: Demonstrates using three horizontally aligned sliders to make a color viewer.</li>
<li><a href="examples/slider/slider-2.html">Slider Examples with aria-orientation and aria-valuetext</a>: Three thermostat control sliders that demonstrate using aria-orientation and aria-valuetext.</li>
<li><a href="examples/slider/slider-color-viewer.html">Color Viewer Slider Example</a>: Basic horizontal sliders that illustrate setting numeric values for a color picker.</li>
<li><a href="examples/slider/slider-temperature.html">Temperature Selector Slider Example</a>: Demonstrates using <code>aria-orientation</code> to specify vertical orientation and <code>aria-valuetext</code> to communicate unit of measure for a temperature input.</li>
<li><a href="examples/slider/slider-rating.html">Rating Slider Example</a>: Horizontal slider that demonstrates using <code>aria-valuetext</code> to communicate current and maximum value of a rating input for a five star rating scale.</li>
</ul>
</section>

Expand Down
12 changes: 12 additions & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ <h2 id="examples_by_role_label">Examples by Role</h2>
<ul>
<li><a href="menu-button/menu-button-links.html">Navigation Menu Button</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="menubar/menubar-navigation.html">Navigation Menubar</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="slider/slider-temperature.html">Vertical Temperature Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="treeview/treeview-navigation.html">Navigation Treeview</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
</ul>
</td>
Expand Down Expand Up @@ -344,6 +345,7 @@ <h2 id="examples_by_role_label">Examples by Role</h2>
<li><a href="slider/multithumb-slider.html">Horizontal Multi-Thumb Slider</a></li>
<li><a href="slider/slider-color-viewer.html">Color Viewer Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="slider/slider-rating.html">Rating Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="slider/slider-temperature.html">Vertical Temperature Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
</ul>
</td>
</tr>
Expand Down Expand Up @@ -603,6 +605,7 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
<li><a href="button/button_idl.html">Button (IDL Version)</a></li>
<li><a href="slider/slider-color-viewer.html">Color Viewer Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="slider/slider-rating.html">Rating Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="slider/slider-temperature.html">Vertical Temperature Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</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 Expand Up @@ -660,6 +663,7 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
<li><a href="radio/radio.html">Radio Group Using Roving tabindex</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="slider/slider-color-viewer.html">Color Viewer Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="slider/slider-rating.html">Rating Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="slider/slider-temperature.html">Vertical Temperature Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</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 @@ -711,6 +715,10 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
<td><code>aria-multiselectable</code></td>
<td><a href="listbox/listbox-rearrangeable.html">Listboxes with Rearrangeable Options</a></td>
</tr>
<tr>
<td><code>aria-orientation</code></td>
<td><a href="slider/slider-temperature.html">Vertical Temperature Slider</a></td>
</tr>
<tr>
<td><code>aria-owns</code></td>
<td><a href="treeview/treeview-navigation.html">Navigation Treeview</a></td>
Expand Down Expand Up @@ -805,6 +813,7 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
<li><a href="slider/multithumb-slider.html">Horizontal Multi-Thumb Slider</a></li>
<li><a href="slider/slider-color-viewer.html">Color Viewer Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="slider/slider-rating.html">Rating Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="slider/slider-temperature.html">Vertical Temperature Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</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 @@ -818,6 +827,7 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
<li><a href="slider/multithumb-slider.html">Horizontal Multi-Thumb Slider</a></li>
<li><a href="slider/slider-color-viewer.html">Color Viewer Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="slider/slider-rating.html">Rating Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="slider/slider-temperature.html">Vertical Temperature Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</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 @@ -831,6 +841,7 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
<li><a href="slider/multithumb-slider.html">Horizontal Multi-Thumb Slider</a></li>
<li><a href="slider/slider-color-viewer.html">Color Viewer Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="slider/slider-rating.html">Rating Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="slider/slider-temperature.html">Vertical Temperature Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</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 @@ -842,6 +853,7 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
<ul>
<li><a href="slider/multithumb-slider.html">Horizontal Multi-Thumb Slider</a></li>
<li><a href="slider/slider-rating.html">Rating Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="slider/slider-temperature.html">Vertical Temperature Slider</a> (<abbr title="High Contrast Support">HC</abbr>)</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
107 changes: 107 additions & 0 deletions examples/slider/css/slider-temperature.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/* CSS Document */

.slider-valuetext h3 {
color: black;
font-weight: bold;
font-size: 150%;
}

.slider-temperature .label,
.slider-seek .label {
font-weight: bold;
font-size: 125%;
}

.slider-temperature svg,
.slider-seek svg {
forced-color-adjust: auto;
}

.slider-temperature text,
.slider-seek text {
font-weight: bold;
fill: currentColor;
font-family: sans-serif;
}

.slider-temperature {
width: 12em;
}

.slider-temperature,
.slider-seek {
margin-top: 1em;
padding: 6px;
color: black;
}

.slider-temperature .value,
.slider-slider .value {
position: relative;
top: 20px;
height: 1.5em;
font-size: 80%;
}

.slider-temperature .temp-value,
.slider-seek .temp-value {
padding-left: 24px;
font-size: 200%;
}

.slider-temperature .rail,
.slider-seek .rail {
stroke: currentColor;
stroke-width: 2px;
fill: currentColor;
fill-opacity: 25%;
}

.slider-temperature .thumb,
.slider-seek .thumb {
stroke-width: 0;
fill: currentColor;
}

.slider-temperature .focus-ring,
.slider-seek .focus-ring {
stroke: currentColor;
stroke-opacity: 0;
fill-opacity: 0;
stroke-width: 3px;
display: none;
}

.slider-temperature .slider-group {
touch-action: pan-x;
}

.slider-seek .slider-group {
touch-action: pan-y;
}

.slider-seek .slider-group .value {
display: none;
}

/* Focus and hover styling */

.slider-seek.focus [role="slider"],
.slider-temperature.focus [role="slider"] {
color: #005a9c;
}

.slider-temperature [role="slider"]:focus,
.slider-seek [role="slider"]:focus {
outline: none;
}

.slider-temperature [role="slider"]:focus .focus-ring,
.slider-seek [role="slider"]:focus .focus-ring {
display: block;
stroke-opacity: 1;
}

.slider-seek [role="slider"]:focus .value {
display: block;
}
Loading

0 comments on commit 1379b72

Please sign in to comment.