Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions assets/scss/_a11y.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@use '@/assets/scss/layout';

/**
* Visually hide an element and leave it only for screenreaders
*/
@mixin screen-reader-only {
border: 0;
clip: rect(0, 0, 0, 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}

/**
* Sets initial styles for the 'Skip to content' link; hidden until it has focus.
*/
@mixin skip-link {
@include layout.auto-margins;
background-color: #fff;
color: inherit;
left: 0;
opacity: 0;
overflow: hidden;
padding: rem(10);
position: absolute;
right: 0;
text-align: center;
text-decoration: none;
top: 0;
transform: translateY(-100%);
width: max-content;
z-index: -1;

&:focus {
opacity: 1;
transform: translateY(0);
z-index: 2147483647; // Theoretical max.
}
}
9 changes: 9 additions & 0 deletions assets/scss/_layout.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Layout-related mixins go here.

/**
* Centered block.
*/
@mixin auto-margins {
margin-left: auto;
margin-right: auto;
}
9 changes: 9 additions & 0 deletions entries/global/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,13 @@ global entry styles.

*/

@use '@/assets/scss/a11y';
@use '@/assets/scss/normalize' as *;

.screen-reader-text {
@include a11y.screen-reader-only;
}

.skip-link {
@include a11y.skip-link;
}
1 change: 1 addition & 0 deletions parts/header.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<a class="skip-link screen-reader-text" href="#main">Skip to Content</a>
<!--
wp:group {
"className": "site-header",
Expand Down
Loading