Skip to content

Commit 2b06d5b

Browse files
authored
feat(a11y): add skip to content link (#84)
1 parent 1bfaf5b commit 2b06d5b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

_includes/base.njk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
{% include 'html-head.njk' %}
1010

1111
<body>
12+
<a href="#main-content" class="skip-to-content">Skip to main content</a>
13+
1214
{% include 'header.njk' %}
1315

1416
<div class="wrapper">
@@ -17,7 +19,7 @@
1719
<div class="main-container">
1820
{% include 'version-note.njk' %}
1921

20-
<main>
22+
<main id="main-content">
2123
{% block content %}
2224
{% endblock %}
2325
</main>

assets/sass/_links.scss

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,24 @@ a {
4343
}
4444
}
4545
}
46+
47+
/* Same style can be used on both light theme and dark theme. */
48+
.skip-to-content {
49+
position: fixed;
50+
top: 1rem;
51+
left: 1rem;
52+
z-index: -1;
53+
padding-inline: 1.75ch;
54+
padding-block: 0.75ch;
55+
border-radius: 0.5ch;
56+
background: #ffe633 !important;
57+
font-weight: bold;
58+
opacity: 0;
59+
color: black !important;
60+
border: 3px solid black;
61+
}
62+
63+
.skip-to-content:focus-visible {
64+
opacity: 1;
65+
z-index: 1001;
66+
}

0 commit comments

Comments
 (0)