Skip to content

Commit 34dad51

Browse files
committed
Fix mobile skiplinks to focus the menu toggle and add a new mobile-to-desktop-nav breakpoint
1 parent ed363aa commit 34dad51

4 files changed

Lines changed: 36 additions & 5 deletions

File tree

header.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@
2727
<?php wp_body_open(); ?>
2828
<nav class="skip-links skip-links--hidden" aria-label="<?php esc_attr_e( 'Fast access links', 'beapi-frontend-framework' ); ?>">
2929
<ul>
30-
<li>
30+
<li class="display-desktop-only">
3131
<a href="#menu"><?php esc_html_e( 'Go to main navigation menu', 'beapi-frontend-framework' ); ?></a>
3232
</li>
33+
<li class="display-mobile-only">
34+
<a href="#menu-toggle"><?php esc_html_e( 'Go to main navigation menu', 'beapi-frontend-framework' ); ?></a>
35+
</li>
3336
<li>
3437
<a href="#content"><?php esc_html_e( 'Go to main content', 'beapi-frontend-framework' ); ?></a>
3538
</li>
@@ -46,7 +49,7 @@
4649
<span class="sr-only"><?php echo esc_html( get_bloginfo( 'name' ) ); ?></span>
4750
</a>
4851
<?php if ( has_nav_menu( 'menu-main' ) ) : ?>
49-
<button class="header__menu-toggle" aria-expanded="false" aria-controls="menu">
52+
<button id="menu-toggle" class="header__menu-toggle" aria-expanded="false" aria-controls="menu">
5053
<span></span>
5154
<span class="sr-only aria-expanded-false-text"><?php esc_html_e( 'Open the menu', 'beapi-frontend-framework' ); ?></span>
5255
<span class="sr-only aria-expanded-true-text"><?php esc_html_e( 'Close the menu', 'beapi-frontend-framework' ); ?></span>

src/scss/01-abstract/_variables.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ $breakpoints: (
5353
admin-bar: 784, // admin bar height change
5454
m: 960,
5555
md: 1080,
56+
mobile-to-desktop-nav: 1200,
5657
mdl: 1279, // Do not use 1280px, it causes a bug under Window Edge with a device pixel ratio higher than 1
5758
l: 1440,
5859
);
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
@use "../02-tools/m-breakpoint" as *;
2+
@use "../02-tools/m-style-only" as *;
3+
4+
/**
5+
* Display utilities
6+
*
7+
* Utility classes for showing/hiding elements based on the mobile-to-desktop-nav breakpoint.
8+
* Used primarily for skip links and navigation-related elements.
9+
*/
10+
11+
// Visible only on mobile (below mobile-to-desktop-nav breakpoint)
12+
.display-mobile-only {
13+
@include breakpoints(mobile-to-desktop-nav) {
14+
@include style-only {
15+
display: none !important;
16+
}
17+
}
18+
}
19+
20+
// Visible only on desktop (at or above mobile-to-desktop-nav breakpoint)
21+
.display-desktop-only {
22+
@include breakpoints(mobile-to-desktop-nav, max) {
23+
@include style-only {
24+
display: none !important;
25+
}
26+
}
27+
}

src/scss/08-template-parts/_header.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@
180180
}
181181
}
182182

183-
@include breakpoints(mdl, max) {
183+
@include breakpoints(mobile-to-desktop-nav, max) {
184184
&__menu {
185185
position: absolute;
186186
top: 0;
@@ -229,7 +229,7 @@
229229
}
230230
}
231231

232-
@include breakpoints(sm, mdl) {
232+
@include breakpoints(sm, mobile-to-desktop-nav) {
233233
#{$el}__menu {
234234
right: 0;
235235
left: auto;
@@ -248,7 +248,7 @@
248248
}
249249
}
250250

251-
@include breakpoints(mdl) {
251+
@include breakpoints(mobile-to-desktop-nav) {
252252
.container {
253253
display: flex;
254254
align-items: flex-start;

0 commit comments

Comments
 (0)