header : menu mobile avec toggle et styles responsive
All checks were successful
Deploy / Deploy to Production (push) Successful in 5s

Ajoute le bouton toggle-mobile-nav, le module JS dédié
(mobile-nav.js) qui gère l'ouverture/fermeture, et les styles
responsive associés (header, grille events).
This commit is contained in:
isUnknown 2026-07-15 18:35:20 +02:00
parent 8a41b767dd
commit 9e3a158a1f
9 changed files with 188 additions and 137 deletions

View file

@ -25,3 +25,7 @@
.background-grey {
background-color: var(--color-beige);
}
.mobile-only {
display: none;
}

View file

@ -13,11 +13,6 @@
border-bottom: var(--border);
border-radius: 0 0 var(--radius) var(--radius);
font-family: var(--font-sans-serif);
font-size: var(--font-size-L);
font-weight: 900;
text-align: center;
.logo-menu {
font-family: var(--font-sans-serif);
font-weight: 700;
@ -34,13 +29,16 @@
align-items: center;
a {
font-weight: 900;
font-family: var(--font-sans-serif);
font-size: max(2.8vw, 2rem);
text-align: center;
}
}
li.characters {
flex: 0 0 200px;
justify-content: center;
margin-right: 5vw;
margin-left: 2vw;
margin-left: 2rem;
svg {
width: var(--char-size);
@ -118,46 +116,46 @@
}
}
@media (max-width: 700px) {
.main-header {
nav {
display: none;
opacity: 0;
}
// @media (max-width: 700px) {
// .main-header {
// nav {
// display: none;
// opacity: 0;
// }
&.open {
height: 100%;
transition-duration: 1s;
border-bottom: 0;
border-radius: 0;
.logo {
padding-top: 5vh;
margin-top: inherit;
display: block;
}
.card {
height: 100%;
}
}
&.open nav {
display: block;
opacity: 1;
transition-duration: 0.1s;
position: absolute;
width: 100%;
z-index: 1;
bottom: 0;
top: 50vh;
display: flex;
justify-content: space-around;
align-items: center;
font-size: 1.5em;
ul {
display: block;
}
}
button.toggle-nav {
display: block;
}
}
}
// &.open {
// height: 100%;
// transition-duration: 1s;
// border-bottom: 0;
// border-radius: 0;
// .logo {
// padding-top: 5vh;
// margin-top: inherit;
// display: block;
// }
// .card {
// height: 100%;
// }
// }
// &.open nav {
// display: block;
// opacity: 1;
// transition-duration: 0.1s;
// position: absolute;
// width: 100%;
// z-index: 1;
// bottom: 0;
// top: 50vh;
// display: flex;
// justify-content: space-around;
// align-items: center;
// font-size: 1.5em;
// ul {
// display: block;
// }
// }
// button.toggle-nav {
// display: block;
// }
// }
// }

View file

@ -0,0 +1,69 @@
@media screen and (max-width: 1200px) {
.mobile-only {
display: inherit;
}
[data-template="events"] {
main {
.events-grid-container {
.events-grid {
grid-template-columns: repeat(2, 1fr);
}
}
}
}
}
@media screen and (max-width: 1000px) {
.main-header {
transition: height 0.3s var(--curve);
nav {
ul {
justify-content: center;
li {
&.characters {
margin: 0;
}
&:not(.characters) {
display: none;
}
}
}
}
button.toggle-mobile-nav {
font-family: var(--font-sans-serif);
font-weight: bold;
text-transform: uppercase;
position: absolute;
font-size: 1rem;
top: 1rem;
right: 1rem;
}
&.open {
height: 100vh;
}
}
}
@media screen and (max-width: 800px) {
// TEMPLATES
[data-template="events"] {
main {
.events-grid-container {
padding: 0 1rem 4rem 1rem;
.events-grid {
grid-template-columns: repeat(1, 1fr);
}
}
}
}
.view-buttons {
li {
button {
font-size: 1rem;
}
}
}
}

View file

@ -220,6 +220,10 @@ main {
background-color: var(--color-beige);
}
.mobile-only {
display: none;
}
.view-buttons {
display: flex;
gap: 4rem;
@ -254,10 +258,6 @@ main {
border-left: var(--border);
border-bottom: var(--border);
border-radius: 0 0 var(--radius) var(--radius);
font-family: var(--font-sans-serif);
font-size: var(--font-size-L);
font-weight: 900;
text-align: center;
}
.main-header .logo-menu {
font-family: var(--font-sans-serif);
@ -276,12 +276,15 @@ main {
}
.main-header nav ul li a {
font-weight: 900;
font-family: var(--font-sans-serif);
font-size: max(2.8vw, 2rem);
text-align: center;
}
.main-header nav ul li.characters {
flex: 0 0 200px;
justify-content: center;
margin-right: 5vw;
margin-left: 2vw;
margin-left: 2rem;
}
.main-header nav ul li.characters svg {
width: var(--char-size);
@ -341,46 +344,6 @@ main {
display: none;
}
@media (max-width: 700px) {
.main-header nav {
display: none;
opacity: 0;
}
.main-header.open {
height: 100%;
transition-duration: 1s;
border-bottom: 0;
border-radius: 0;
}
.main-header.open .logo {
padding-top: 5vh;
margin-top: inherit;
display: block;
}
.main-header.open .card {
height: 100%;
}
.main-header.open nav {
display: block;
opacity: 1;
transition-duration: 0.1s;
position: absolute;
width: 100%;
z-index: 1;
bottom: 0;
top: 50vh;
display: flex;
justify-content: space-around;
align-items: center;
font-size: 1.5em;
}
.main-header.open nav ul {
display: block;
}
.main-header button.toggle-nav {
display: block;
}
}
@keyframes flip {
0% {
transform: rotateX(0deg);
@ -869,4 +832,50 @@ main {
font-size: 0.7rem;
text-transform: uppercase;
letter-spacing: var(--letter-space-large);
}
@media screen and (max-width: 1200px) {
.mobile-only {
display: inherit;
}
[data-template=events] main .events-grid-container .events-grid {
grid-template-columns: repeat(2, 1fr);
}
}
@media screen and (max-width: 1000px) {
.main-header {
transition: height 0.3s var(--curve);
}
.main-header nav ul {
justify-content: center;
}
.main-header nav ul li.characters {
margin: 0;
}
.main-header nav ul li:not(.characters) {
display: none;
}
.main-header button.toggle-mobile-nav {
font-family: var(--font-sans-serif);
font-weight: bold;
text-transform: uppercase;
position: absolute;
font-size: 1rem;
top: 1rem;
right: 1rem;
}
.main-header.open {
height: 100vh;
}
}
@media screen and (max-width: 800px) {
[data-template=events] main .events-grid-container {
padding: 0 1rem 4rem 1rem;
}
[data-template=events] main .events-grid-container .events-grid {
grid-template-columns: repeat(1, 1fr);
}
.view-buttons li button {
font-size: 1rem;
}
}/*# sourceMappingURL=style.css.map */

File diff suppressed because one or more lines are too long

View file

@ -12,3 +12,4 @@
@import "src/pages/agenda";
@import "src/slideshow";
@import "src/footer";
@import "src/responsive";

10
assets/js/mobile-nav.js Normal file
View file

@ -0,0 +1,10 @@
export function initMobileNav() {
const header = document.querySelector(".main-header");
const toggleBtn = document.querySelector(".toggle-mobile-nav");
if (!header || !toggleBtn) return;
toggleBtn.addEventListener("click", () => {
header.classList.toggle("open");
});
}

View file

@ -6,54 +6,13 @@ import { Slideshow } from "./slideshow.js";
import { initRollOutfit } from "./characters/roll.js";
import { initMorphMouth } from "./characters/morphMouth.js";
import { initMorphEyes } from "./characters/morphEyes.js";
import { initMobileNav } from "./mobile-nav.js";
document.addEventListener("DOMContentLoaded", () => {
const header = document.querySelector(".main-header");
const charactersWrapper = document.querySelector(".characters");
const svg = charactersWrapper?.querySelector("svg");
let menuOpen = false;
let menuTransitioning = false;
const toggleBtn = document.querySelector(".toggle-nav");
if (toggleBtn) {
function openMenu() {
menuOpen = true;
header.classList.add("menu-transitioning", "big");
header.classList.add("open");
toggleBtn.textContent = "fermer";
document.body.style.overflow = "hidden";
}
function closeMenu() {
menuOpen = false;
menuTransitioning = true;
header.classList.remove("big");
header.classList.remove("open");
toggleBtn.textContent = "menu";
document.body.style.overflow = "";
setTimeout(() => {
header.classList.remove("menu-transitioning");
menuTransitioning = false;
}, 500);
}
toggleBtn.addEventListener("click", () => {
header.classList.contains("open") ? closeMenu() : openMenu();
});
document.addEventListener("keydown", (event) => {
if (event.key === "Escape" && menuOpen) closeMenu();
});
document.addEventListener("click", (event) => {
if (!menuOpen) return;
if (event.target.closest(".toggle-nav")) return;
if (!event.target.closest(".main-header")) closeMenu();
});
}
initMobileNav();
initCharacterJump();
if (svg) initPupilTracking(svg);
if (document.body.dataset.template !== "event") initCharactersResizeOnScroll();

View file

@ -27,5 +27,6 @@
</li>
</ul>
</nav>
<button class="toggle-mobile-nav mobile-only">Menu</button>
</header>
<main>