Skip to content

Commit 90d3645

Browse files
committed
getting to a stopping point
1 parent aded6c9 commit 90d3645

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

js/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import autocomplete from './algolia'
2323
import mapTable from './map-table'
2424
import expando from './expando'
2525
import codeCopy from './code-copy'
26+
import skipNav from './skip-nav'
2627

2728
feedback()
2829
accordion()
@@ -47,4 +48,5 @@ searchBar()
4748
glightbox()
4849
mapTable()
4950
expando()
50-
codeCopy()
51+
codeCopy()
52+
skipNav()

js/skip-nav/skip-nav.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const button =
2+
document.createElement ('skiplink');
3+
button.textContent = 'Skip to main content';
4+
5+
button.addEventListener ('focus-visible', => {
6+
button.style.display = 'inline-block';
7+
});
8+
9+
button.addEventListener ('focus-invisible', => {
10+
button.style.display = 'none';
11+
});
12+

src/_layouts/default.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
<link rel="stylesheet" href="{{ '/assets/algolia.css' | relative_url }}">
8181
</head>
8282
<body>
83+
<a href="#breadcrumbs__link" class="skiplink">Skip to main content</a>
8384
<div id="consent-manager"></div>
8485
{{ content }}
8586
<a class="back-scrolling" data-back-scrolling data-active-class="back-scrolling--active">

src/_sass/components/skip-nav.scss

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.skiplink {
2+
position: absolute;
3+
left: -1000px;
4+
top: auto;
5+
height: 1px;
6+
width: 1px;
7+
overflow: hidden;
8+
display: block;
9+
z-index: 999;
10+
}
11+
.skiplink:focus-visible {
12+
background: color(gray-700)
13+
padding: 2px;
14+
color: color(secondary);
15+
position: static;
16+
width: 200px;
17+
height: auto;
18+
overflow: visible;
19+
}

0 commit comments

Comments
 (0)