Skip to content

Commit

Permalink
Tabs Examples: Improve high contrast support and code quality (pull #…
Browse files Browse the repository at this point in the history
…2194)

This commit updates the two examples of the tabs design pattern by:
* Improving support for high contrast settings by changing how keyboard focus and the selected state are rendered.
* Improving clarity of guidance related to focusability of tab panels; one example illustrates focusable tab panels and the other illustrates omitting the panel from the page tab sequence.
* Reducing complexity by removing the delete tab feature; this advanced functionality may later be illustrated in a separate example.
* Improving documentation of accessibility features.
* Updating Javascript and CSS to implement practices specified in the latest APG Code Guide.

Co-authored-by: Carolyn MacLeod <Carolyn_MacLeod@ca.ibm.com>
Co-authored-by: Matt King <a11yThinker@gmail.com>
  • Loading branch information
3 people authored Mar 22, 2022
1 parent c66cb52 commit d324b85
Show file tree
Hide file tree
Showing 12 changed files with 605 additions and 839 deletions.
7 changes: 4 additions & 3 deletions aria-practices.html
Original file line number Diff line number Diff line change
Expand Up @@ -2772,8 +2772,8 @@ <h3>Tabs</h3>
<section class="notoc">
<h4>Examples</h4>
<ul>
<li><a href="examples/tabs/tabs-1/tabs.html">Tabs With Automatic Activation</a>: A tabs widget where tabs are automatically activated and their panel is displayed when they receive focus.</li>
<li><a href="examples/tabs/tabs-2/tabs.html">Tabs With Manual Activation</a>: A tabs widget where users activate a tab and display its panel by pressing <kbd>Space</kbd> or <kbd>Enter</kbd>.</li>
<li><a href="examples/tabs/tabs-automatic.html">Tabs With Automatic Activation</a>: A tabs widget where tabs are automatically activated and their panel is displayed when they receive focus.</li>
<li><a href="examples/tabs/tabs-manual.html">Tabs With Manual Activation</a>: A tabs widget where users activate a tab and display its panel by pressing <kbd>Space</kbd> or <kbd>Enter</kbd>.</li>
</ul>
</section>

Expand Down Expand Up @@ -2835,6 +2835,7 @@ <h4>Keyboard Interaction</h4>
</ol>
</li>
<li>If the tab list is horizontal, it does not listen for <kbd>Down Arrow</kbd> or <kbd>Up Arrow</kbd> so those keys can provide their normal browser scrolling functions even when focus is inside the tab list.</li>
<li>When the tabpanel does not contain any focusable elements or the first element with content is not focusable, the tabpanel should set <code>tabindex="0"</code> to include it in the tab sequence of the page.</li>
</ol>
</section>
<section class="notoc">
Expand All @@ -2849,7 +2850,7 @@ <h4>WAI-ARIA Roles, States, and Properties</h4>
</li>
<li>Each element with role <code>tab</code> has the property <a href="#aria-controls" class="property-reference">aria-controls</a> referring to its associated <code>tabpanel</code> element.</li>
<li>The active <code>tab</code> element has the state <a href="#aria-selected" class="state-reference">aria-selected</a> set to <code>true</code> and all other <code>tab</code> elements have it set to <code>false</code>.</li>
<li>Each element with role <code>tabpanel</code> has the property <a href="#aria-labelledby" class="property-reference">aria-labelledby</a> referring to its associated <code>tab</code> element. </li>
<li>Each element with role <code>tabpanel</code> has the property <a href="#aria-labelledby" class="property-reference">aria-labelledby</a> referring to its associated <code>tab</code> element.</li>
<li>If a <code>tab</code> element has a popup menu, it has the property <a href="#aria-haspopup" class="property-reference">aria-haspopup</a> set to either <code>menu</code> or <code>true</code>. </li>
<li>
If the <code>tablist</code> element is vertically oriented, it has the property <a href="#aria-orientation" class="property-reference">aria-orientation</a> set to <code>vertical</code>.
Expand Down
11 changes: 11 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"Accesskey",
"activedescendants",
"affordance",
"Ahlefeldt",
"alertdialog",
"Anjou",
"Aristov",
Expand Down Expand Up @@ -74,6 +75,7 @@
"Focusability",
"focusable",
"Foltz",
"Fonseca",
"Foyle",
"Frahm",
"funders",
Expand All @@ -87,6 +89,7 @@
"Gunderson",
"Hassium",
"Hausler",
"Henriette",
"highlighttext",
"Higley",
"Hillen",
Expand All @@ -104,8 +107,10 @@
"jumpto",
"Kasper",
"kbdshortcuts",
"Kiærskou",
"Kowno",
"Labelable",
"Lange",
"Lauke",
"Leventhal",
"Lewandowski",
Expand All @@ -129,6 +134,7 @@
"moreaccessible",
"Moscovium",
"MSAA",
"Müller",
"multithumb",
"navs",
"Nemeth",
Expand Down Expand Up @@ -179,8 +185,10 @@
"Ségur",
"Shirisha",
"shizzle",
"Siboni",
"Shopify",
"Smorgeni",
"Sofie",
"sortability",
"sourcecode",
"Spinbuttons",
Expand All @@ -202,9 +210,11 @@
"textarea's",
"textfield",
"Thaarup",
"Theresia",
"Thiel",
"Thiers",
"thomascorthals",
"Tonekunstnerinde",
"togglable",
"transactinide",
"transuranic",
Expand All @@ -220,6 +230,7 @@
"unmanaged",
"Vasily",
"Vinkle",
"virkelig",
"vnurc",
"Vyacheslav",
"walkability",
Expand Down
26 changes: 12 additions & 14 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ <h2 id="examples_by_role_label">Examples by Role</h2>
<td>
<ul>
<li><a href="carousel/carousel-2-tablist.html">Auto-Rotating Image Carousel with Tabs for Slide Control</a> (<abbr title="High Contrast Support">HC</abbr>)</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>
<li><a href="tabs/tabs-automatic.html">Tabs with Automatic Activation</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="tabs/tabs-manual.html">Tabs with Manual Activation</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
</ul>
</td>
</tr>
Expand All @@ -393,8 +393,8 @@ <h2 id="examples_by_role_label">Examples by Role</h2>
<td>
<ul>
<li><a href="carousel/carousel-2-tablist.html">Auto-Rotating Image Carousel with Tabs for Slide Control</a> (<abbr title="High Contrast Support">HC</abbr>)</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>
<li><a href="tabs/tabs-automatic.html">Tabs with Automatic Activation</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="tabs/tabs-manual.html">Tabs with Manual Activation</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
</ul>
</td>
</tr>
Expand All @@ -403,8 +403,8 @@ <h2 id="examples_by_role_label">Examples by Role</h2>
<td>
<ul>
<li><a href="carousel/carousel-2-tablist.html">Auto-Rotating Image Carousel with Tabs for Slide Control</a> (<abbr title="High Contrast Support">HC</abbr>)</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>
<li><a href="tabs/tabs-automatic.html">Tabs with Automatic Activation</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="tabs/tabs-manual.html">Tabs with Manual Activation</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
</ul>
</td>
</tr>
Expand Down Expand Up @@ -532,8 +532,8 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
<li><a href="menu-button/menu-button-actions-active-descendant.html">Actions Menu Button Using aria-activedescendant</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="menu-button/menu-button-actions.html">Actions Menu Button Using element.focus()</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="menu-button/menu-button-links.html">Navigation Menu Button</a> (<abbr title="High Contrast Support">HC</abbr>)</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>
<li><a href="tabs/tabs-automatic.html">Tabs with Automatic Activation</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="tabs/tabs-manual.html">Tabs with Manual Activation</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="toolbar/toolbar.html">Toolbar</a></li>
</ul>
</td>
Expand Down Expand Up @@ -655,8 +655,6 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
<li><a href="slider/slider-multithumb.html">Horizontal Multi-Thumb 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="table/table.html">Table</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>
<li><a href="toolbar/toolbar.html">Toolbar</a></li>
<li><a href="treegrid/treegrid-1.html">Treegrid Email Inbox</a></li>
<li><a href="treeview/treeview-navigation.html">Navigation Treeview</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
Expand Down Expand Up @@ -695,8 +693,8 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
<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="switch/switch-button.html">Switch Using HTML Button</a> (<abbr title="High Contrast Support">HC</abbr>)</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>
<li><a href="tabs/tabs-automatic.html">Tabs with Automatic Activation</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="tabs/tabs-manual.html">Tabs with Manual Activation</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="treeview/treeview-1/treeview-1a.html">File Directory Treeview Using Computed Properties</a></li>
<li><a href="treeview/treeview-1/treeview-1b.html">File Directory Treeview Using Declared Properties</a></li>
<li><a href="treeview/treeview-navigation.html">Navigation Treeview</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
Expand Down Expand Up @@ -816,8 +814,8 @@ <h2 id="examples_by_props_label">Examples By Properties and States</h2>
<li><a href="listbox/listbox-grouped.html">Listbox with Grouped Options</a></li>
<li><a href="listbox/listbox-rearrangeable.html">Listboxes with Rearrangeable Options</a></li>
<li><a href="listbox/listbox-scrollable.html">Scrollable Listbox</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>
<li><a href="tabs/tabs-automatic.html">Tabs with Automatic Activation</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="tabs/tabs-manual.html">Tabs with Manual Activation</a> (<abbr title="High Contrast Support">HC</abbr>)</li>
<li><a href="treeview/treeview-1/treeview-1a.html">File Directory Treeview Using Computed Properties</a></li>
<li><a href="treeview/treeview-1/treeview-1b.html">File Directory Treeview Using Declared Properties</a></li>
</ul>
Expand Down
108 changes: 36 additions & 72 deletions examples/tabs/css/tabs.css
Original file line number Diff line number Diff line change
@@ -1,107 +1,71 @@
.tabs {
width: 20em;
font-family: "lucida grande", sans-serif;
}

[role="tablist"] {
margin: 0 0 -0.1em;
overflow: visible;
min-width: 550px;
}

[role="tab"] {
[role="tab"],
[role="tab"]:focus,
[role="tab"]:hover {
position: relative;
z-index: 2;
top: 2px;
margin: 0;
padding: 0.3em 0.5em 0.4em;
margin-top: 4px;
padding: 3px 3px 4px;
border: 1px solid hsl(219deg 1% 72%);
border-radius: 0.2em 0.2em 0 0;
box-shadow: 0 0 0.2em hsl(219deg 1% 72%);
border-bottom: 2px solid hsl(219deg 1% 72%);
border-radius: 5px 5px 0 0;
overflow: visible;
font-family: inherit;
font-size: inherit;
background: hsl(220deg 20% 94%);
}

[role="tab"]:hover::before,
[role="tab"]:focus::before,
[role="tab"][aria-selected="true"]::before {
position: absolute;
bottom: 100%;
right: -1px;
left: -1px;
border-radius: 0.2em 0.2em 0 0;
border-top: 3px solid hsl(20deg 96% 48%);
content: "";
outline: none;
font-weight: bold;
}

[role="tab"][aria-selected="true"] {
border-radius: 0;
padding: 2px 2px 4px;
margin-top: 0;
border-width: 2px;
border-top-width: 6px;
border-top-color: rgb(36 116 214);
border-bottom-color: hsl(220deg 43% 99%);
background: hsl(220deg 43% 99%);
outline: 0;
}

[role="tab"][aria-selected="true"]:not(:focus):not(:hover)::before {
border-top: 5px solid hsl(218deg 96% 48%);
[role="tab"][aria-selected="false"] {
border-bottom: 1px solid hsl(219deg 1% 72%);
}

[role="tab"][aria-selected="true"]::after {
position: absolute;
z-index: 3;
bottom: -1px;
right: 0;
left: 0;
height: 0.3em;
background: hsl(220deg 43% 99%);
box-shadow: none;
content: "";
}

[role="tab"]:hover,
[role="tab"]:focus,
[role="tab"]:active {
outline: 0;
border-radius: 0;
color: inherit;
[role="tab"] span.focus {
display: inline-block;
margin: 2px;
padding: 4px 6px;
}

[role="tab"]:hover::before,
[role="tab"]:focus::before {
border-color: hsl(20deg 96% 48%);
[role="tab"]:hover span.focus,
[role="tab"]:focus span.focus,
[role="tab"]:active span.focus {
padding: 2px 4px;
border: 2px solid rgb(36 116 214);
border-radius: 3px;
}

[role="tabpanel"] {
position: relative;
z-index: 2;
padding: 0.5em 0.5em 0.7em;
border: 1px solid hsl(219deg 1% 72%);
border-radius: 0 0.2em 0.2em;
box-shadow: 0 0 0.2em hsl(219deg 1% 72%);
padding: 5px;
border: 2px solid hsl(219deg 1% 72%);
border-radius: 0 5px 5px;
background: hsl(220deg 43% 99%);
min-height: 10em;
min-width: 550px;
overflow: auto;
}

[role="tabpanel"].is-hidden {
display: none;
}

[role="tabpanel"]:focus {
border-color: hsl(20deg 96% 48%);
box-shadow: 0 0 0.2em hsl(20deg 96% 48%);
outline: 0;
}

[role="tabpanel"]:focus::after {
position: absolute;
bottom: 0;
right: -1px;
left: -1px;
border-bottom: 3px solid hsl(20deg 96% 48%);
border-radius: 0 0 0.2em 0.2em;
content: "";
}

[role="tabpanel"] p {
margin: 0;
}

[role="tabpanel"] * + p {
margin-top: 1em;
}
Loading

0 comments on commit d324b85

Please sign in to comment.