From 7fb5a901ad106dc5cc2ff9f9313c21bf27860fe3 Mon Sep 17 00:00:00 2001 From: Ploush Date: Wed, 10 Jun 2026 17:55:39 +0200 Subject: [PATCH] menu mobile --- .../controllers/header-mobile_controller.js | 16 ++++ app/assets/styles/partials/header.css | 94 ++++++++++++++++++- app/templates/partials/_header.html.twig | 29 ++++-- 3 files changed, 128 insertions(+), 11 deletions(-) create mode 100644 app/assets/controllers/header-mobile_controller.js diff --git a/app/assets/controllers/header-mobile_controller.js b/app/assets/controllers/header-mobile_controller.js new file mode 100644 index 0000000..36d901a --- /dev/null +++ b/app/assets/controllers/header-mobile_controller.js @@ -0,0 +1,16 @@ +import { Controller } from '@hotwired/stimulus'; + +export default class extends Controller { + static targets = ['menu']; + + toggle() { + this.menuTarget.classList.toggle('open'); + this.element.querySelector('.hamburger').classList.toggle('open'); + } + + // Fermer le menu quand on clique sur un lien + close() { + this.menuTarget.classList.remove('open'); + this.element.querySelector('.hamburger').classList.remove('open'); + } +} diff --git a/app/assets/styles/partials/header.css b/app/assets/styles/partials/header.css index 1fe432f..8d96b33 100644 --- a/app/assets/styles/partials/header.css +++ b/app/assets/styles/partials/header.css @@ -348,11 +348,97 @@ header .header-dropdown .dropdown-link::after { display: none !important; } border-color: rgba(255, 255, 255, 0.5); } -/* ── MOBILE ────────────────────────────────────────────────────── */ +/* ── HAMBURGER (MOBILE) ────────────────────────────────────────── */ +.hamburger { + display: none; + flex-direction: column; + gap: 5px; + background: none; + border: none; + cursor: pointer; + padding: 0; + width: 28px; + height: 24px; + margin: 0 0.5rem; +} + +.hamburger span { + display: block; + width: 100%; + height: 2.5px; + background: var(--text-light); + border-radius: 2px; + transition: all var(--duration-normal) ease; +} +[data-theme="dark"] .hamburger span { + background: var(--text-dark); +} + +/* Animation : croix quand ouvert */ +.hamburger.open span:nth-child(1) { + transform: rotate(45deg) translate(4px, 4px); +} +.hamburger.open span:nth-child(2) { + opacity: 0; +} +.hamburger.open span:nth-child(3) { + transform: rotate(-45deg) translate(7px, -7px); +} + +/* ── MOBILE : transformer nav en panneau ────────────────────────── */ @media (max-width: 640px) { - header nav { display: none !important; } - header { padding: 0 1rem !important; } - .header-left { gap: 0; } + .hamburger { + display: flex; + } + + header nav { + position: fixed; + top: 72px; + left: -100%; + width: 100%; + height: calc(100vh - 72px); + background: rgba(255, 255, 255, 0.75); + backdrop-filter: blur(var(--blur-md)); + -webkit-backdrop-filter: blur(var(--blur-md)); + border-top: 1px solid var(--border-light); + + flex-direction: column !important; + gap: 0.5rem !important; + padding: 2rem 1.5rem !important; + z-index: 99; + transition: left var(--duration-normal) ease; + overflow-y: auto; + } + [data-theme="dark"] header nav { + background: rgba(12, 10, 18, 0.95); + border-top-color: var(--border-dark); + } + + header nav.open { + left: 0; + } + + header { padding: 0 1rem !important; } + .header-left { gap: 0.5rem; } + + /* Adapter les liens pour mobile */ + header nav .nav-link { + padding: 0.75rem 1rem !important; + border-radius: 10px !important; + border: 1px solid var(--border-light) !important; + background: transparent !important; + font-size: 0.95rem !important; + display: block; + } + [data-theme="dark"] header nav .nav-link { + border-color: var(--border-dark) !important; + } + header nav .nav-link:hover { + background: rgba(0, 0, 0, 0.05) !important; + } + [data-theme="dark"] header nav .nav-link:hover { + background: rgba(255, 255, 255, 0.07) !important; + } } /* ── MESSAGE D'ERREUR DANS LE DROPDOWN ─────────────────────────── */ diff --git a/app/templates/partials/_header.html.twig b/app/templates/partials/_header.html.twig index 3d9bd38..bc00366 100644 --- a/app/templates/partials/_header.html.twig +++ b/app/templates/partials/_header.html.twig @@ -5,35 +5,50 @@ {% set current_route = app.request.attributes.get('_route') %} -
+
{# ── Gauche : Logo + Navigation ───────────────────────────── #}