Skip to content

Commit 5314053

Browse files
committed
fix accessibility issues with docs section anchors not having any content
Signed-off-by: Grace Grimwood <[email protected]>
1 parent 57d9fb6 commit 5314053

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

_layouts/docs.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ <h3 class="card-title">
2121
<div class="card-body mx-2">
2222
<div class="row g-0">
2323
<div class="col-auto">
24-
<div class="card-text m-2">
24+
<div class="card-text ms-3 m-2">
2525
{% if page.version_warning %}
2626
{% include bs-alert.html type="warning" content=page.version_warning %}
2727
{% endif %}
@@ -33,3 +33,16 @@ <h3 class="card-title">
3333
</div>
3434
</div>
3535
</div>
36+
<!-- The following script fixes an accessibility issue with the sectanchors injected by AsciiDoc not containing any content. -->
37+
<!-- The script adds a span which the anchor CSS applies to, then moves the header text inside the anchor element. -->
38+
<script>
39+
document.addEventListener("DOMContentLoaded", function () {
40+
document.querySelectorAll("a.anchor").forEach((anchorElem) => {
41+
var anchorSpan = document.createElement('span');
42+
anchorSpan.setAttribute("class", "anchor-icon");
43+
anchorElem.appendChild(anchorSpan);
44+
anchorElem.appendChild(anchorElem.nextSibling);
45+
anchorElem.setAttribute("class", anchorElem.getAttribute("class") + " text-decoration-none text-reset")
46+
})
47+
})
48+
</script>

_sass/kroxylicious.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ div.highlighter-rouge {
155155

156156
// Anchor Links
157157

158-
h2>a.anchor, h3>a.anchor, h4>a.anchor, h5>a.anchor, h6>a.anchor {
158+
h2>a.anchor>span, h3>a.anchor>span, h4>a.anchor>span, h5>a.anchor>span, h6>a.anchor>span {
159159
font-family: bootstrap-icons!important;
160160
color: rgba($primary, 0);
161161
display: block;
@@ -169,15 +169,15 @@ h2>a.anchor, h3>a.anchor, h4>a.anchor, h5>a.anchor, h6>a.anchor {
169169
color 200ms ease-in-out;
170170
}
171171

172-
h2>a.anchor::before, h3>a.anchor::before, h4>a.anchor::before, h5>a.anchor::before, h6>a.anchor::before {
172+
h2>a.anchor>span::before, h3>a.anchor>span::before, h4>a.anchor>span::before, h5>a.anchor>span::before, h6>a.anchor>span::before {
173173
content: "\f470";
174174
}
175175

176-
h2:hover>a.anchor, h3:hover>a.anchor, h4:hover>a.anchor, h5:hover>a.anchor, h6:hover>a.anchor {
176+
h2:hover>a.anchor>span, h3:hover>a.anchor>span, h4:hover>a.anchor>span, h5:hover>a.anchor>span, h6:hover>a.anchor>span {
177177
visibility: visible;
178178
color: rgba($primary, 1);
179179
}
180180

181-
h2:hover>a.anchor:hover, h3:hover>a.anchor:hover, h4:hover>a.anchor:hover, h5:hover>a.anchor:hover, h6:hover>a.anchor:hover {
181+
h2:hover>a.anchor>span:hover, h3:hover>a.anchor>span:hover, h4:hover>a.anchor>span:hover, h5:hover>a.anchor>span:hover, h6:hover>a.anchor>span:hover {
182182
color: rgba($secondary, 1);
183183
}

0 commit comments

Comments
 (0)