Activate mobil menu with js since it depends on js.
This commit is contained in:
parent
e058a3dd5b
commit
15f9a7933f
5 changed files with 18 additions and 21 deletions
|
|
@ -4,10 +4,21 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
|
const main_menu = document.querySelector('.main-menu');
|
||||||
|
const header_region = document.querySelector('.header__region');
|
||||||
const nav = document.querySelector('.mobile-nav');
|
const nav = document.querySelector('.mobile-nav');
|
||||||
const sheet = document.querySelector('.mobile-nav__sheet');
|
const sheet = document.querySelector('.mobile-nav__sheet');
|
||||||
const toggle = document.querySelector('.mobile-nav__toggle');
|
const toggle = document.querySelector('.mobile-nav__toggle');
|
||||||
|
|
||||||
|
// Switch to mobil menu on small screens.
|
||||||
|
// The mobile menu depends on js so we use js to activate it.
|
||||||
|
const small_screen = window.matchMedia('(max-width: 666px)').matches;
|
||||||
|
if (small_screen) {
|
||||||
|
main_menu.hidden = true;
|
||||||
|
header_region.hidden = true;
|
||||||
|
nav.hidden = false;
|
||||||
|
}
|
||||||
|
|
||||||
function navopen() {
|
function navopen() {
|
||||||
nav.dataset.navopen = 'true';
|
nav.dataset.navopen = 'true';
|
||||||
sheet.setAttribute('aria-hidden', 'false');
|
sheet.setAttribute('aria-hidden', 'false');
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@
|
||||||
--anchor-opacity: .4;
|
--anchor-opacity: .4;
|
||||||
|
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: auto 1fr;
|
grid-template-columns: auto auto;
|
||||||
|
justify-content: start;
|
||||||
align-items: baseline;
|
align-items: baseline;
|
||||||
gap: var(--anchor-gap);
|
gap: var(--anchor-gap);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,14 +88,16 @@ button,
|
||||||
appearance: none;
|
appearance: none;
|
||||||
padding: .5rem;
|
padding: .5rem;
|
||||||
color: currentcolor;
|
color: currentcolor;
|
||||||
background-color: unset;
|
background: unset;
|
||||||
border: unset;
|
border: unset;
|
||||||
|
text-shadow: unset;
|
||||||
|
|
||||||
&:hover,
|
&:hover,
|
||||||
&:focus-visible,
|
&:focus-visible,
|
||||||
&:active {
|
&:active {
|
||||||
color: currentcolor;
|
color: currentcolor;
|
||||||
background-color: unset;
|
background: unset;
|
||||||
|
text-shadow: unset;
|
||||||
scale: 1.15;
|
scale: 1.15;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,6 @@
|
||||||
|
|
||||||
@import 'init';
|
@import 'init';
|
||||||
|
|
||||||
.main-menu,
|
|
||||||
.header__region { // stylelint-disable selector-class-pattern
|
|
||||||
display: none;
|
|
||||||
|
|
||||||
@media (min-width: 666px) {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
} // stylelint-enable selector-class-pattern
|
|
||||||
|
|
||||||
.mobile-nav {
|
.mobile-nav {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0;
|
right: 0;
|
||||||
|
|
@ -22,10 +13,6 @@
|
||||||
z-index: 20;
|
z-index: 20;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|
||||||
@media (min-width: 666px) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
&[data-navopen] {
|
&[data-navopen] {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
}
|
}
|
||||||
|
|
@ -60,10 +47,6 @@
|
||||||
z-index: 22;
|
z-index: 22;
|
||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
|
|
||||||
@media (min-width: 666px) {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover,
|
&:hover,
|
||||||
&:focus-visible {
|
&:focus-visible {
|
||||||
svg {
|
svg {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="mobile-nav" dir="ltr">
|
<div class="mobile-nav" dir="ltr" hidden>
|
||||||
<div class="mobile-nav__cover"></div>
|
<div class="mobile-nav__cover"></div>
|
||||||
<button class="mobile-nav__toggle{{ if $.Param "mobilemenuoutline" }} button--outline{{ end }}" aria-expanded="false" aria-controls="sheet">
|
<button class="mobile-nav__toggle{{ if $.Param "mobilemenuoutline" }} button--outline{{ end }}" aria-expanded="false" aria-controls="sheet">
|
||||||
{{ i18n "menu_mobile" }}
|
{{ i18n "menu_mobile" }}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue