Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ARIA attributes for states #1006

Merged
merged 14 commits into from
Jan 23, 2020
6 changes: 3 additions & 3 deletions docs/content/components/breadcrumb.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Breadcrumbs are used to show taxonomical context on pages that are many levels d
```html live
<nav aria-label="Breadcrumb">
<ol>
<li class="breadcrumb-item text-small"><a href="https://github.com/business">Business</a></li>
<li class="breadcrumb-item text-small"><a href="https://github.com/business/customers">Customers</a></li>
<li class="breadcrumb-item breadcrumb-item-selected text-small text-gray" aria-current="page">MailChimp</li>
<li class="breadcrumb-item"><a href="https://github.com/business">Business</a></li>
<li class="breadcrumb-item"><a href="https://github.com/business/customers">Customers</a></li>
<li class="breadcrumb-item" aria-current="page">MailChimp</li>
</ol>
</nav>
```
2 changes: 1 addition & 1 deletion docs/content/components/labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Use the `Counter` in navigation to indicate the number of items without the user
```html live title="Counter in tabs"
<div class="tabnav">
<nav class="tabnav-tabs" aria-label="Foo bar">
<a href="#url" class="tabnav-tab selected" aria-current="page">Foo tab <span class="Counter">23</a>
<a href="#url" class="tabnav-tab" aria-current="page">Foo tab <span class="Counter">23</a>
<a href="#url" class="tabnav-tab">Bar tab</a>
</nav>
</div>
Expand Down
187 changes: 68 additions & 119 deletions docs/content/components/navigation.md

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions docs/content/components/pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,18 @@ You can make a very simple pagination container with just the Previous and Next

For pagination across multiple pages, make sure it's clear to the user where they are in a set of pages.

To do this, add anchor links to the `pagination` element. Previous and Next buttons should always be present. Add the `aria-disabled="true"` attribute to the Previous button if you're on the first page. Apply the class `current` to the current numbered page.
To do this, add anchor links to the `pagination` element. Previous and Next buttons should always be present. Add the `aria-disabled="true"` attribute to the Previous button if you're on the first page. Apply the `aria-current="page"` attribute to the current numbered page.

As always, make sure to include the appropriate `aria` attributes to make the element accessible.

- Add `aria-label="Pagination"` to the the `paginate-container` element.
- Add `aria-current="true"` to the current page marker.
- Add `aria-label="Page X"` to each anchor link.

```html live
<nav class="paginate-container" aria-label="Pagination">
<div class="pagination">
<span class="previous_page" aria-disabled="true">Previous</span>
<em class="current selected" aria-current="true">1</em>
<em aria-current="page">1</em>
<a href="#url" aria-label="Page 2">2</a>
<a href="#url" aria-label="Page 3">3</a>
<span class="gap">…</span>
Expand Down
2 changes: 1 addition & 1 deletion src/autocomplete/autocomplete.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
cursor: pointer;

&:hover,
&[aria-selected="true"],
&.selected,
&[aria-selected=true],
&.navigation-focus {
color: $text-white;
text-decoration: none;
Expand Down
5 changes: 4 additions & 1 deletion src/breadcrumb/breadcrumb.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
}
}

.breadcrumb-item-selected {
.breadcrumb-item-selected,
.breadcrumb-item[aria-current] {
color: $text-gray;

&::after {
content: none;
}
Expand Down
2 changes: 2 additions & 0 deletions src/buttons/button-group.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
}

&.selected,
&[aria-selected=true],
&:focus,
&:active,
&:hover {
Expand Down Expand Up @@ -65,6 +66,7 @@
}

&.selected,
&[aria-selected=true],
&:focus,
&:active,
&:hover {
Expand Down
4 changes: 3 additions & 1 deletion src/buttons/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
}

&:active,
&.selected {
&.selected,
&[aria-selected=true] {
background-image: none;
}
}
Expand Down Expand Up @@ -155,6 +156,7 @@
&:active,
&:focus,
&.selected,
&[aria-selected=true],
&.zeroclipboard-is-hover,
&.zeroclipboard-is-active {
color: $text-blue;
Expand Down
4 changes: 3 additions & 1 deletion src/navigation/filter-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
background-color: lighten($gray-200, 3%);
}

&.selected {
&.selected,
&[aria-selected=true],
&[aria-current] {
color: $text-white;
background-color: $bg-blue;
}
Expand Down
4 changes: 3 additions & 1 deletion src/navigation/menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
background-color: $bg-gray;
}

&.selected {
&.selected,
&[aria-selected=true],
&[aria-current] {
font-weight: $font-weight-bold;
color: $text-gray-dark;
cursor: default;
Expand Down
4 changes: 2 additions & 2 deletions src/navigation/subnav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
}

&.selected,
&.selected:hover,
&.selected:focus {
&[aria-selected=true],
&[aria-current] {
z-index: 2;
color: $text-white;
background-color: $bg-blue;
Expand Down
3 changes: 2 additions & 1 deletion src/navigation/tabnav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
border: $border-width $border-style transparent;
border-bottom: 0;

&.selected,
&[aria-selected=true],
&.selected {
&[aria-current] {
color: $text-gray-dark;
background-color: $bg-white;
border-color: $border-gray-dark;
Expand Down
1 change: 1 addition & 0 deletions src/navigation/underline-nav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
line-height: $lh-default;
color: $text-gray;
text-align: center;
border: 0;
// stylelint-disable-next-line primer/borders
border-bottom: 2px $border-style transparent;

Expand Down
4 changes: 3 additions & 1 deletion src/pagination/pagination.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
.selected { z-index: 3; }

.current,
.current:hover {
.current:hover,
[aria-current],
[aria-current]:hover {
z-index: 3;
color: $text-white;
background-color: $bg-blue;
Expand Down
4 changes: 4 additions & 0 deletions src/support/mixins/buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

&:active,
&.selected,
&[aria-selected=true],
[open] > & {
background-color: darken(desaturate($bg, 10%), 6%);
background-image: none;
Expand Down Expand Up @@ -56,6 +57,7 @@

&:active,
&.selected,
&[aria-selected=true],
[open] > & {
background-color: darken(mix($bg, $bg2, 50%), 7%);
background-image: none;
Expand Down Expand Up @@ -103,6 +105,7 @@

&:active,
&.selected,
&[aria-selected=true],
[open] > & {
color: $text-white;
background-color: darken($color, 5%);
Expand Down Expand Up @@ -135,6 +138,7 @@
&:hover,
&:active,
&.selected,
&[aria-selected=true],
[open] > & {
color: $bg-color;
background-color: $text-color;
Expand Down