Skip to content

Commit 698769e

Browse files
authored
Merge pull request #3718 from mlama007/accessibility-nav-TOC
Accessibility updates to Main Nav and Table of Contents
2 parents ebc9678 + da3be4f commit 698769e

4 files changed

Lines changed: 28 additions & 21 deletions

File tree

_includes/nav.html

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
{% assign t = site.data.locales[page.lang][page.lang] %}
22
<nav class="main-nav">
33
<div class="container-lg mx-auto clearfix">
4+
{% if page.layout != 'index' %}
5+
<div class="float-sm-left pl-3 breadcrumb">
6+
<p class="my-0 py-3 py-sm-4 text-gray">
7+
{% assign lang_url = '/' | append: page.lang | append: '/' %}
8+
{% assign lang_index = site.pages | where: "url", lang_url %}
9+
{% if page.lang != 'en' and lang_index.size > 0 %}
10+
<a href="{{ lang_url }}" class="text-gray">{{ site.title }}</a>
11+
{% elsif page.lang != 'en' %}
12+
<a href="{{ '/' | relative_url }}" class="text-gray">{{ site.title }}</a>
13+
{% else %}
14+
<a href="/" class="text-gray">{{ site.title }}</a>
15+
{% endif %}
16+
</p>
17+
</div>
18+
{% endif %}
419
<div class="float-sm-right">
520
<ul
621
class="main-links d-flex flex-wrap flex-items-stretch flex-justify-center border-left border-bottom border-sm-0 list-style-none">
@@ -34,20 +49,5 @@
3449
{% endif %}
3550
</ul>
3651
</div>
37-
{% if page.layout != 'index' %}
38-
<div class="float-sm-left pl-3 breadcrumb">
39-
<p class="my-0 py-3 py-sm-4 text-gray">
40-
{% assign lang_url = '/' | append: page.lang | append: '/' %}
41-
{% assign lang_index = site.pages | where: "url", lang_url %}
42-
{% if page.lang != 'en' and lang_index.size > 0 %}
43-
<a href="{{ lang_url }}" class="text-gray">{{ site.title }}</a>
44-
{% elsif page.lang != 'en' %}
45-
<a href="{{ '/' | relative_url }}" class="text-gray">{{ site.title }}</a>
46-
{% else %}
47-
<a href="/" class="text-gray">{{ site.title }}</a>
48-
{% endif %}
49-
</p>
50-
</div>
51-
{% endif %}
5252
</div>
5353
</nav>

_layouts/article.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ <h1 class="h0-mktg lh-condensed text-center mb-3">{{ page.title }}</h1>
1111
<p class="lead text-center text-gray col-md-8 mx-auto mb-4 position-relative">{{ page.description }}</p>
1212
<nav class="toc mb-4 mb-md-6">
1313
<div class="Box col-sm-8 col-md-4 col-lg-3 mx-auto">
14-
<a class="toc-trigger d-block text-center p-3">
14+
<button type="button" class="toc-trigger d-block text-center p-3" aria-expanded="false" aria-controls="toc-list">
1515
<span class="text-black">{{ t.article.table_of_contents }}</span><svg height="18"
1616
class="octicon octicon-triangle-down ml-2 fill-blue v-align-middle icon-flip" viewBox="0 0 12 16"
17-
version="1.1" width="13" role="img">
17+
version="1.1" width="13" aria-hidden="true" focusable="false">
1818
<path fill-rule="evenodd" d="M0 5l6 6 6-6z"></path>
1919
</svg>
20-
</a>
21-
{% include jekyll-toc.html html=content h_max=2 ordered=true class="toc-list list-style-none"
20+
</button>
21+
{% include jekyll-toc.html html=content h_max=2 ordered=true id="toc-list" class="toc-list list-style-none"
2222
item_class="border-top" anchor_class="d-block py-3 px-3" %}
2323
</div>
2424
</nav>

assets/css/toc.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
}
99

1010
.toc-trigger {
11+
width: 100%;
12+
background: transparent;
13+
border: 0;
14+
font: inherit;
15+
color: inherit;
16+
1117
&:hover {
1218
text-decoration: none;
1319
cursor: pointer;

assets/js/toc.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
$(function() {
22
$(document).click(function() {
33
// Hiding ToC
4-
$('.toc-trigger').removeClass('toc-open');
4+
$('.toc-trigger').removeClass('toc-open').attr('aria-expanded', 'false');
55
$('.toc-list').removeClass('is-shown');
66
});
77

@@ -10,7 +10,8 @@ $(function() {
1010
// Prevent bubbling event for proper hiding
1111
e.stopPropagation();
1212
// Calling a function in case you want to expand upon this.
13-
$(this).toggleClass('toc-open');
13+
var $trigger = $(this).toggleClass('toc-open');
14+
$trigger.attr('aria-expanded', $trigger.hasClass('toc-open') ? 'true' : 'false');
1415
$('.toc-list').toggleClass('is-shown');
1516
});
1617
});

0 commit comments

Comments
 (0)