Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

Commit daa2427

Browse files
committed
Change header links to be accessible
Updated application.js, styling, and added the SVG to the footer. This update is so the heading links will be accessible to screenreaders, instead of reading `#`.
1 parent f196d7f commit daa2427

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

_includes/footer.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
Get in touch
1919
</a>
2020

21+
<!--Add SVG for header links-->
22+
<div style="display: none">
23+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
24+
<symbol viewBox="0 0 24 24" id="svg-link" xmlns="http://www.w3.org/2000/svg"><path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"></path></symbol>
25+
</svg>
26+
</div>
27+
2128
<!--<script src="{{site.baseurl}}/assets/js/site.js"/>-->
2229
<!-- Digital Analytics Program roll-up, see https://analytics.usa.gov for data -->
2330
<script id="_fed_an_ua_tag"

_sass/footer.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,14 @@
88
padding-left: units(3);
99
}
1010
}
11+
12+
// Styling for heading links
13+
.heading-permalink {
14+
text-decoration: none;
15+
opacity: 0.2;
16+
}
17+
18+
a.heading-permalink:hover,
19+
a.heading-permalink:focus {
20+
opacity: 1;
21+
}

assets/application.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,16 @@ const addHeadingLinks = () => {
2525
};
2626

2727
const headings = document.querySelectorAll(
28-
"main h1, main h2, main h3, main h4, main h5, main h6"
28+
"main h2, main h3, main h4, main h5, main h6"
2929
);
3030
for (const heading of headings) {
3131
if (!heading.id) {
3232
heading.id = slugify(heading.innerText);
3333
}
3434

35-
heading.innerHTML = `${heading.innerText} <a href="#${heading.id}" aria-hidden="true" tabindex="-1" class="usa-link heading-link--symbol">#</a>`;
35+
heading.innerHTML = `${heading.innerText} <span aria-hidden="true"><a href="#${heading.id}" aria-label="Permanent link to ${heading.innerText}" class="usa-link heading-permalink heading-link--symbol"><svg class="usa-icon" aria-hidden="true" focusable="false" role="img">
36+
<use xlink:href="#svg-link"></use>
37+
</svg></a></span>`;
3638
}
3739
};
3840

0 commit comments

Comments
 (0)