corrections menu static toggle

This commit is contained in:
Valentin 2024-10-22 11:50:33 +02:00
parent 002857163d
commit 14893a9c28
3 changed files with 51 additions and 23 deletions

View File

@ -5,6 +5,7 @@ export const useLayoutStore = defineStore('layout', {
minDesktopWidth: 992, minDesktopWidth: 992,
isDesktop: Boolean, isDesktop: Boolean,
isEtapeListRetracted: Boolean, isEtapeListRetracted: Boolean,
isHamburgerMenuOpen: false,
}), }),
actions: { actions: {
setupResizeListenner () { setupResizeListenner () {
@ -32,5 +33,39 @@ export const useLayoutStore = defineStore('layout', {
}, 300); }, 300);
this.isEtapeListRetracted = false; this.isEtapeListRetracted = false;
}, },
setUpHamburgerToggle(menuBurger, menuContainer) {
const menuTitle = document.querySelector('#menu-title');
const menuH2 = document.querySelector('#menu > h2');
menuBurger.addEventListener('click', (e) => {
setTimeout(() => {
if (!this.isHamburgerMenuOpen) menuContainer.style.display = 'block';
menuContainer.classList.toggle('open');
menuTitle.classList.toggle('open');
menuBurger.classList.toggle('open');
menuH2.classList.toggle('open');
if (this.isHamburgerMenuOpen) {
setTimeout(() => {
menuContainer.style.display = 'none';
this.isHamburgerMenuOpen = !this.isHamburgerMenuOpen;
}, 300);
}
}, 50);
document.addEventListener('click', (e) => {
if (!menuContainer.contains(e.target) && !menuBurger.contains(e.target)) {
menuContainer.classList.remove('open');
menuTitle.classList.remove('open');
menuBurger.classList.remove('open');
menuH2.classList.remove('open');
setTimeout(() => {
if (this.isHamburgerMenuOpen) {
menuContainer.style.display = 'none';
}
this.isHamburgerMenuOpen = false;
}, 300);
}
});
});
}
}, },
}) })

View File

@ -33,27 +33,11 @@ export function handleReactiveness() {
} }
export function setMenuToggle() { export function setMenuToggle() {
const menuButton = document.querySelector('#block-caravane-mainnavigation > #menu'); const layoutStore = useLayoutStore();
const menuContainer = document.querySelector('#block-caravane-mainnavigation > #menu > ul');
const menuTitle = document.querySelector('#menu-title');
const menuBurger = document.querySelector('#hamburger'); const menuBurger = document.querySelector('#hamburger');
const menuH2 = document.querySelector('#menu > h2'); const menuContainer = document.querySelector('#block-caravane-mainnavigation > #menu > ul');
menuButton.addEventListener('click', (e) => {
setTimeout(() => { layoutStore.setUpHamburgerToggle(menuBurger, menuContainer);
menuContainer.classList.toggle('open');
menuTitle.classList.toggle('open');
menuBurger.classList.toggle('open');
menuH2.classList.toggle('open');
}, 50);
});
document.addEventListener('click', (e) => {
if (!menuContainer.contains(e.target) && !menuBurger.contains(e.target)) {
menuContainer.classList.remove('open');
menuTitle.classList.remove('open');
menuBurger.classList.remove('open');
menuH2.classList.remove('open');
}
});
} }
export function setHamburgerWhenLogged(drupalSettings) { export function setHamburgerWhenLogged(drupalSettings) {

View File

@ -181,9 +181,14 @@ body{
height: 3px; height: 3px;
margin: 4px 0; margin: 4px 0;
border-radius: 2px; border-radius: 2px;
background-color: $main-color-light; background-color: white;
opacity: 1; opacity: 1;
transition: transform 0.5s, opacity 0.2s; transition: transform 0.5s, opacity 0.2s;
margin-right: 3vw;
@media screen and (min-width: $desktop-min-width) {
margin-right: 0;
background-color: $main-color-light;
}
} }
} }
> #hamburger:hover { > #hamburger:hover {
@ -216,7 +221,7 @@ body{
width: $menu-mobile-width; width: $menu-mobile-width;
right: $body-margin-x; right: $body-margin-x;
padding: 0; padding: 0;
padding-top: 1.5rem; padding-top: 2rem;
padding-bottom: 1.5rem; padding-bottom: 1.5rem;
top: -5vh; top: -5vh;
opacity: 0; opacity: 0;
@ -254,7 +259,7 @@ body{
} }
> ul.open { > ul.open {
opacity: 1; opacity: 1;
top: 7vh; top: 6vh;
} }
} }
} }
@ -365,6 +370,9 @@ body{
.leaflet-tooltip-pane { .leaflet-tooltip-pane {
width: 75vw; width: 75vw;
pointer-events: none; pointer-events: none;
@media screen and (min-width: $tablet-min-width) {
width: 40vw;
}
@media screen and (min-width: $desktop-min-width) { @media screen and (min-width: $desktop-min-width) {
width: 25vw; width: 25vw;
} }
@ -376,6 +384,7 @@ body{
border-radius: 0 !important; border-radius: 0 !important;
background-color: transparent; background-color: transparent;
border: none; border: none;
width: 100%;
> div { > div {
max-height: 15vh; max-height: 15vh;
overflow: hidden; overflow: hidden;