From d1a1f412d363b1900471b9a1ebccc3e9da0db89a Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 10:27:25 +0100 Subject: [PATCH] tt-2026-11-079 : bouton masquer/afficher la barre laterale (portable, iPad) et tiroir sur telephone a la place de la barre du bas --- app/static/app.css | 47 ++++++++++++++++------ app/static/app.js | 90 ++++++++++++++++++++++++++++++++++++------- app/static/index.html | 19 +++++++-- tests/test_ui.py | 14 +++++++ 4 files changed, 141 insertions(+), 29 deletions(-) diff --git a/app/static/app.css b/app/static/app.css index c701f35..7759e58 100644 --- a/app/static/app.css +++ b/app/static/app.css @@ -7,12 +7,11 @@ button:disabled { cursor: default; } h1, h2, h3, p { margin: 0; } .coque { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; } -.nav-bureau { background: var(--ny-carte); border-right: 1px solid var(--ny-trait); padding: var(--ny-e6) var(--ny-e4); display: flex; flex-direction: column; gap: var(--ny-e6); position: sticky; top: 0; height: 100vh; } +.nav-bureau { background: var(--ny-carte); border-right: 1px solid var(--ny-trait); padding: var(--ny-e6) var(--ny-e4); display: flex; flex-direction: column; gap: var(--ny-e6); position: sticky; top: 0; height: 100vh; overflow-y: auto; overflow-x: hidden; } .marque { padding: 0 var(--ny-e2); display: flex; flex-direction: column; gap: 2px; } .marque b { font: var(--ny-t2); } .marque span { font: var(--ny-t4); color: var(--ny-encre-3); } .nav-liste { display: flex; flex-direction: column; gap: var(--ny-e1); } -.nav-mobile .nav-sep { display: none; } .nav-sep { font: var(--ny-t4); color: var(--ny-encre-3); padding: var(--ny-e2) var(--ny-e3) 0; } .nav-btn { min-height: var(--ny-cible); display: flex; align-items: center; gap: var(--ny-e3); padding: 0 var(--ny-e3); border: none; border-radius: var(--ny-r-s); background: transparent; color: var(--ny-encre-2); font: 500 15px/20px var(--ny-police); text-align: left; transition: background var(--ny-duree) var(--ny-courbe); } .nav-btn:hover { background: var(--ny-accent-teinte); } @@ -184,18 +183,12 @@ h1, h2, h3, p { margin: 0; } .bientot-ecran { padding: var(--ny-e8) var(--ny-e6); display: flex; flex-direction: column; gap: var(--ny-e2); align-items: flex-start; } .badge-bientot { display: inline-flex; padding: 0 10px; min-height: 24px; align-items: center; border: 1px dashed var(--ny-trait-controle); border-radius: var(--ny-r-pastille); font: 600 13px/18px var(--ny-police); color: var(--ny-encre-2); } -.nav-mobile { display: none; } @media (max-width: 760px) { - .coque { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; height: 100dvh; min-height: 0; } - .nav-bureau { display: none; } - .principal { padding: var(--ny-e4); gap: var(--ny-e3); overflow-y: auto; } + .coque { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); height: 100dvh; min-height: 0; } + .principal { padding: var(--ny-e4) var(--ny-e4) calc(var(--ny-e4) + env(safe-area-inset-bottom, 0px)); gap: var(--ny-e3); overflow-y: auto; } .principal > * { flex-shrink: 0; } .entete h1 { font: var(--ny-t2); } - .nav-mobile { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--ny-carte); border-top: 1px solid var(--ny-trait); padding: 4px 8px 16px; } - .nav-mobile .nav-btn { min-height: 56px; flex-direction: column; justify-content: center; gap: 4px; padding: 0; text-align: center; font: 500 13px/18px var(--ny-police); } - .nav-mobile .nav-btn[aria-current="page"] { font-weight: 600; } - .nav-mobile .nav-btn svg { width: 22px; height: 22px; } .jour { width: 100%; } .jour-carte { flex: 1; justify-content: center; } .liste-entete { display: none; } @@ -332,8 +325,6 @@ h1, h2, h3, p { margin: 0; } .lect-suivre + .lect-course { margin-left: 0; } .nav-n { margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: var(--ny-r-pastille); background: var(--ny-accent); color: var(--ny-encre-inverse); font: 600 12px/20px var(--ny-police-chiffres); text-align: center; } @media (max-width: 760px) { - .nav-mobile .nav-btn { position: relative; } - .nav-mobile .nav-n { position: absolute; top: 2px; left: calc(50% + 8px); margin: 0; } .groupe-suivi { border-left-width: 6px; } /* Le marque-page se range sous la case « traité » : la largeur du texte des lignes ne change pas. */ .ligne { row-gap: 0; } @@ -345,3 +336,35 @@ h1, h2, h3, p { margin: 0; } /* Suppression définitive dans « Terminés » : rouge discret, en contour */ .btn-petit.btn-danger, .btn-ligne.btn-danger { background: transparent; color: var(--ny-erreur); border: 1px solid var(--ny-erreur); } .btn-petit.btn-danger:hover, .btn-ligne.btn-danger:hover { background: var(--ny-erreur); color: var(--ny-encre-inverse); } + +/* ---------- Barre latérale réductible (portable, tablette) et tiroir (téléphone), tt-2026-11-079 ---------- */ +.barre-mobile, .nav-voile { display: none; } +.nav-tete { display: flex; align-items: center; justify-content: space-between; gap: var(--ny-e2); min-height: var(--ny-cible); } +.nav-tete .marque { min-width: 0; } +.btn-panneau { position: relative; flex: none; width: var(--ny-cible); height: var(--ny-cible); display: inline-flex; align-items: center; justify-content: center; border: none; border-radius: var(--ny-r-m); background: transparent; color: var(--ny-encre-2); transition: background var(--ny-duree) var(--ny-courbe), color var(--ny-duree) var(--ny-courbe); } +.btn-panneau:hover { background: var(--ny-accent-teinte); color: var(--ny-accent); } +.btn-panneau:active { background: var(--ny-accent-teinte-2); } +.btn-panneau svg { width: 22px; height: 22px; } +.nav-btn { position: relative; } +.nav-txt { white-space: nowrap; } +.nav-point { position: absolute; top: 8px; right: 8px; width: 10px; height: 10px; border: 2px solid var(--ny-carte); border-radius: var(--ny-r-pastille); background: var(--ny-accent); box-sizing: content-box; } +.nav-point[hidden] { display: none; } +.coque.nav-anim { transition: grid-template-columns var(--ny-duree) var(--ny-courbe); } + +@media (min-width: 761px) { + .coque.nav-reduite { grid-template-columns: 72px minmax(0, 1fr); } + .nav-reduite .nav-bureau { padding-left: var(--ny-e3); padding-right: var(--ny-e3); } + .nav-reduite .nav-tete { justify-content: center; } + .nav-reduite .marque, .nav-reduite .pied-nyora { display: none; } + .nav-reduite .nav-btn { justify-content: center; padding: 0; } + .nav-reduite .nav-txt { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); } + .nav-reduite .nav-n { position: absolute; top: 0; right: 0; margin: 0; } +} + +@media (max-width: 760px) { + .barre-mobile { display: flex; align-items: center; gap: var(--ny-e2); min-height: 56px; padding: 0 var(--ny-e2); background: var(--ny-carte); border-bottom: 1px solid var(--ny-trait); } + .barre-titre { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: var(--ny-t2); color: var(--ny-encre); } + .nav-bureau { position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; width: min(86vw, 320px); height: 100dvh; padding: var(--ny-e3) var(--ny-e4) calc(var(--ny-e4) + env(safe-area-inset-bottom, 0px)); box-shadow: var(--ny-ombre-2); transform: translateX(-100%); visibility: hidden; transition: transform var(--ny-duree) var(--ny-courbe), visibility 0s linear var(--ny-duree); } + .nav-ouverte .nav-bureau { transform: none; visibility: visible; transition: transform var(--ny-duree) var(--ny-courbe); } + .nav-voile:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 39; background: color-mix(in srgb, var(--ny-encre) 45%, transparent); } +} diff --git a/app/static/app.js b/app/static/app.js index 4e8e830..4390c6b 100644 --- a/app/static/app.js +++ b/app/static/app.js @@ -15,7 +15,8 @@ asuivre: 'm19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z', pj: 'm21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48', groupes: 'M3 7h7v7H3z|M14 7h7v7h-7z|M3 17h18', - telecharger: 'M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4|m7 10 5 5 5-5|M12 15V3', fermer: 'M18 6 6 18|m6 6 12 12', gauche: 'm15 18-6-6 6-6', droite: 'm9 18 6-6-6-6', bas: 'm6 9 6 6 6-6', fleche: 'M5 12h14|m12 5 7 7-7 7' + telecharger: 'M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4|m7 10 5 5 5-5|M12 15V3', fermer: 'M18 6 6 18|m6 6 12 12', gauche: 'm15 18-6-6 6-6', droite: 'm9 18 6-6-6-6', bas: 'm6 9 6 6 6-6', fleche: 'M5 12h14|m12 5 7 7-7 7', + panneau: 'M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z|M9 3v18' }; var NAV = [ ['tri', 'Tri du jour', true], ['asuivre', 'À suivre', true], ['categories', 'Catégories', true], ['groupes', 'Groupes', true], ['recherche', 'Recherche', true], ['courses', 'Courses pour Tunis', true], ['suivi', 'Suivi des demandes', true], ['regles', 'Règles', true] @@ -278,20 +279,58 @@ } /* ---------- Rendu ---------- */ - function rendreNav() { - var bureau = document.getElementById('nav-bureau'), mobile = document.getElementById('nav-mobile'); - bureau.textContent = ''; mobile.textContent = ''; - function bouton(n) { - return h('button', { type: 'button', class: 'nav-btn', 'aria-current': S.vue === n[0] ? 'page' : null, onclick: function () { allerA(n[0]); } }, icone(n[0]), h('span', null, n[1]), n[0] === 'asuivre' && S.asuivre.compte.actif > 0 ? h('span', { class: 'nav-n', text: String(S.asuivre.compte.actif) }) : null); + /* ---------- Barre latérale : réduite (portable, tablette) ou tiroir (téléphone) ---------- */ + var CLE_NAV = 'courrier.nav'; + var MQ_TEL = window.matchMedia('(max-width: 760px)'); + var NAVETAT = { tel: MQ_TEL.matches, reduite: false, ouvert: false }; + function lireChoixNav() { try { var v = localStorage.getItem(CLE_NAV); return v === 'reduite' || v === 'ouverte' ? v : null; } catch (e) { return null; } } + function ecrireChoixNav(v) { try { localStorage.setItem(CLE_NAV, v); } catch (e) { /* stockage indisponible : le choix vaut pour cette visite */ } } + function reduiteParDefaut() { var c = lireChoixNav(); return c ? c === 'reduite' : window.innerWidth < 1024; } + function appliquerNav() { + var app = document.getElementById('app'), bas = document.getElementById('nav-bascule'), ouv = document.getElementById('nav-ouvrir'); + var tel = NAVETAT.tel, reduite = !tel && NAVETAT.reduite, ouvert = tel && NAVETAT.ouvert; + app.classList.toggle('nav-reduite', reduite); + app.classList.toggle('nav-ouverte', ouvert); + document.getElementById('nav-voile').hidden = !ouvert; + document.getElementById('principal').toggleAttribute('inert', ouvert); + document.getElementById('barre-mobile').toggleAttribute('inert', ouvert); + ouv.setAttribute('aria-expanded', ouvert ? 'true' : 'false'); + if (tel) { + bas.setAttribute('aria-expanded', ouvert ? 'true' : 'false'); bas.setAttribute('aria-label', 'Fermer le menu'); bas.removeAttribute('title'); + } else { + var t = reduite ? 'Ouvrir la barre latérale' : 'Réduire la barre latérale'; + bas.setAttribute('aria-expanded', reduite ? 'false' : 'true'); bas.setAttribute('aria-label', t); bas.setAttribute('title', t); } - var liste = h('div', { class: 'nav-liste' }); - NAV.forEach(function (n, i) { - liste.appendChild(bouton(n)); - if (n[2]) mobile.appendChild(bouton(n)); + rendreNav(); + } + function basculerNav() { + if (NAVETAT.tel) { fermerMenu(true); return; } + NAVETAT.reduite = !NAVETAT.reduite; + ecrireChoixNav(NAVETAT.reduite ? 'reduite' : 'ouverte'); + appliquerNav(); + } + function ouvrirMenu() { + NAVETAT.ouvert = true; appliquerNav(); + var a = document.querySelector('#nav-corps .nav-btn[aria-current="page"]') || document.querySelector('#nav-corps .nav-btn'); + if (a) a.focus(); + } + function fermerMenu(rendreFocus) { + if (!NAVETAT.ouvert) return; + NAVETAT.ouvert = false; appliquerNav(); + if (rendreFocus) document.getElementById('nav-ouvrir').focus(); + } + function rendreNav() { + var corps = document.getElementById('nav-corps'); + corps.textContent = ''; + var reduite = !NAVETAT.tel && NAVETAT.reduite; + var nb = S.asuivre.compte.actif; + NAV.forEach(function (n) { + corps.appendChild(h('button', { type: 'button', class: 'nav-btn', title: reduite ? n[1] : null, 'aria-current': S.vue === n[0] ? 'page' : null, onclick: function () { fermerMenu(false); allerA(n[0]); } }, + icone(n[0]), h('span', { class: 'nav-txt' }, n[1]), + n[0] === 'asuivre' && nb > 0 ? h('span', { class: 'nav-n', text: String(nb) }) : null)); }); - bureau.appendChild(h('div', { class: 'marque' }, h('b', null, 'Courrier'), h('span', null, 'Lecture seule'))); - bureau.appendChild(liste); - bureau.appendChild(h('div', { class: 'pied-nyora' }, 'Nyora')); + var pt = document.getElementById('nav-point'); + if (pt) pt.hidden = !(nb > 0); } function enteteJour() { var estAuj = S.jour === auj(); @@ -1000,9 +1039,34 @@ p.appendChild(v); p.scrollTop = pos; var titre = S.vue === 'tri' ? 'Tri du jour' : S.vue === 'categories' ? 'Catégories' : S.vue === 'regles' ? 'Règles' : S.vue === 'groupes' ? 'Groupes' : S.vue === 'courses' ? 'Courses pour Tunis' : S.vue === 'suivi' ? 'Suivi des demandes' : S.vue === 'asuivre' ? 'À suivre' : S.vue === 'recherche' ? 'Recherche' : BIENTOT[S.vue][0]; document.title = titre + ' · Courrier'; + document.getElementById('barre-titre').textContent = titre; if (ancre && !dialogue) { var r = p.querySelector('[aria-label="' + ancre.replace(/"/g, '\\"') + '"]'); if (r && document.activeElement === document.body) r.focus(); } } + /* Barre latérale : branchement des boutons (hors du rendu pour que le focus ne se perde pas). */ + (function () { + var bas = document.getElementById('nav-bascule'), ouv = document.getElementById('nav-ouvrir'); + bas.appendChild(icone('panneau')); + ouv.appendChild(icone('panneau')); + ouv.appendChild(h('span', { class: 'nav-point', id: 'nav-point', hidden: true, 'aria-hidden': 'true' })); + ouv.addEventListener('click', ouvrirMenu); + bas.addEventListener('click', basculerNav); + document.getElementById('nav-voile').addEventListener('click', function () { fermerMenu(true); }); + document.getElementById('nav-bureau').addEventListener('keydown', function (e) { + if (!NAVETAT.ouvert) return; + if (e.key === 'Escape') { e.preventDefault(); fermerMenu(true); return; } + if (e.key !== 'Tab') return; + var f = this.querySelectorAll('button'), p = f[0], d = f[f.length - 1]; + if (e.shiftKey && document.activeElement === p) { e.preventDefault(); d.focus(); } + else if (!e.shiftKey && document.activeElement === d) { e.preventDefault(); p.focus(); } + }); + var change = function () { NAVETAT.tel = MQ_TEL.matches; NAVETAT.ouvert = false; appliquerNav(); }; + if (MQ_TEL.addEventListener) MQ_TEL.addEventListener('change', change); else MQ_TEL.addListener(change); + NAVETAT.reduite = reduiteParDefaut(); + appliquerNav(); + window.requestAnimationFrame(function () { window.requestAnimationFrame(function () { document.getElementById('app').classList.add('nav-anim'); }); }); + })(); + rendre(); chargerMails(); chargerASuivre(true); diff --git a/app/static/index.html b/app/static/index.html index 02b99a3..fbf0f18 100644 --- a/app/static/index.html +++ b/app/static/index.html @@ -10,16 +10,27 @@ - +
- +
+ + Courrier +
+ +
-
- + diff --git a/tests/test_ui.py b/tests/test_ui.py index 8c0f478..a176c55 100644 --- a/tests/test_ui.py +++ b/tests/test_ui.py @@ -67,3 +67,17 @@ def test_renommage_et_suppression_en_cascade(client): def test_renommage_doublon_refuse(client): cid = client.post("/api/v1/categories", json={"name": "Zeta"}).json()["id"] assert client.put(f"/api/v1/categories/{cid}", json={"name": "Tunis"}).status_code == 400 + + +def test_barre_laterale_reductible_et_tiroir(): + """tt-2026-11-079 : bouton masquer/afficher la barre latérale (portable, tablette) et tiroir sur téléphone.""" + html = (STATIC / "index.html").read_text(encoding="utf-8") + css = (STATIC / "app.css").read_text(encoding="utf-8") + js = (STATIC / "app.js").read_text(encoding="utf-8") + assert html.count("