diff --git a/maquette/style.css b/maquette/style.css index 24896ac..2cec8d9 100644 --- a/maquette/style.css +++ b/maquette/style.css @@ -352,67 +352,6 @@ body.etape-ouverte #fiches { display: none; } /* « Voir le vrai territoire » / « Voir le système » : au zoom arrière maximal de chaque vue, au milieu en bas */ .vers-vue { position: fixed; z-index: 7; left: 50%; transform: translateX(-50%); bottom: calc(var(--h-fiches, 60px) + env(safe-area-inset-bottom, 0px) + 14px); min-height: 44px; padding: 0 18px; border: 0; border-radius: 999px; background: var(--quartier-encre); color: #fff; font: 600 15px/1 Barlow, sans-serif; box-shadow: var(--ombre); white-space: nowrap; } -#territoire .vers-vue { position: absolute; bottom: calc(var(--bas-t) + 14px); z-index: 1000; } @media (min-width: 900px) { .vers-vue { bottom: 24px; } } -/* la vue territoire : la carte couvre la page sous le sticky ; la maquette se tait dessous */ -#territoire { --bas-t: calc(64px + env(safe-area-inset-bottom, 0px)); position: fixed; inset: 0; z-index: 3; background: var(--papier); } -#territoire .t-carte { position: absolute; inset: 0 0 var(--bas-t) 0; background: #e8e6dc; font: 13px/1.4 Barlow, system-ui, sans-serif; } -#territoire .t-etat { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); margin: 0; z-index: 1001; background: var(--papier-2); border: 1px solid var(--trait); border-radius: 12px; padding: 10px 14px; box-shadow: var(--ombre); } -#territoire .t-etat:empty { display: none; } body.sur-territoire :is(#fiches, #etape-carte, #b-tourner, #b-vers-territoire) { display: none !important; } -/* les contrôles natifs de Leaflet, au trait du site : 44 px au doigt, sous le sélecteur */ -#territoire .leaflet-top { top: calc(env(safe-area-inset-top, 0px) + 112px); } -#territoire .leaflet-control-zoom { border: 1px solid var(--trait); border-radius: 12px; box-shadow: var(--ombre); overflow: hidden; } -#territoire .leaflet-control-zoom a { width: 44px; height: 44px; line-height: 44px; font: 600 22px/44px Barlow, sans-serif; color: var(--encre); background: var(--papier-2); } -#territoire .leaflet-control-attribution { font: 12px/1.35 Barlow, sans-serif; background: rgba(255, 253, 246, .92); color: var(--encre-2); padding: 2px 7px; max-width: calc(100vw - 16px); } -#territoire .leaflet-control-attribution a { color: var(--eau-encre); } -#territoire .leaflet-container:focus-visible { outline: 3px solid var(--eau-encre); outline-offset: -3px; } -@media (min-width: 900px) { #territoire .leaflet-top { top: 120px; } } -#territoire .t-barre { position: absolute; left: 0; right: 0; bottom: 0; height: var(--bas-t); box-sizing: border-box; padding: 0 12px env(safe-area-inset-bottom, 0px); display: flex; align-items: center; gap: 10px; - background: var(--papier-2); border-top: 1px solid var(--trait); box-shadow: 0 -8px 28px rgba(16, 42, 58, .12); z-index: 1000; } -#territoire .t-titre { flex: 1; min-width: 0; font: 600 15px/1.15 "Barlow Condensed", Barlow, sans-serif; color: var(--encre-2); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; } -/* la légende, au bas de la carte */ -#territoire .t-b-legende { flex: none; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px 0 8px; border: 1px solid var(--trait); border-radius: 999px; background: #fff; box-shadow: var(--ombre); font: 600 15px/1 Barlow, sans-serif; color: var(--encre); } -#territoire .t-b-legende[aria-expanded="true"] { background: var(--encre); color: var(--papier-2); border-color: var(--encre); } -#territoire .t-pictos { display: flex; } -#territoire .t-pictos svg { width: 26px; height: 26px; margin-right: -7px; } -#territoire .t-pictos svg:last-child { margin-right: 2px; } -/* les lieux : un pictogramme de 36 px dans une cible de 44 */ -#territoire .t-ep-icone { background: none; border: 0; } -#territoire .t-ep { width: 44px; height: 44px; padding: 4px; border: 0; background: none; border-radius: 50%; cursor: pointer; transition: opacity .25s, transform .2s; } -#territoire .t-ep svg { display: block; width: 36px; height: 36px; filter: drop-shadow(0 2px 4px rgba(16, 42, 58, .35)); } -#territoire .t-ep.actif { transform: scale(1.18); } -#territoire .t-ep.estompe { opacity: .28; } -#territoire .t-ep:focus-visible { outline: 3px solid var(--eau-encre); outline-offset: 0; } -/* les panneaux du bas : la légende, un lieu */ -#territoire .t-panneau { position: absolute; z-index: 1002; left: 0; right: 0; bottom: 0; max-height: min(62vh, 520px); overflow: auto; box-sizing: border-box; padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px)); - background: var(--papier-2); border-top: 1px solid var(--trait); border-radius: 16px 16px 0 0; box-shadow: 0 -8px 28px rgba(16, 42, 58, .16); } -#territoire .t-tete { display: flex; gap: 10px; align-items: flex-start; } -#territoire .t-tete h2 { margin: 2px 0 0; font: 600 20px/1.15 "Barlow Condensed", Barlow, sans-serif; } -#territoire .t-fermer { order: 9; margin-left: auto; flex: none; width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--trait); border-radius: 50%; background: #fff; } -#territoire .t-fermer svg { width: 20px; height: 20px; } -#territoire .t-icone svg { width: 48px; height: 48px; display: block; } -#territoire .t-type { font: 600 13px/1.2 Barlow, sans-serif; text-transform: uppercase; letter-spacing: .04em; } -#territoire .t-panneau p { margin: 10px 0 0; } -#territoire .t-statut, #territoire .t-position, #territoire .t-aide { font-size: 13.5px; color: var(--encre-2); } -#territoire .t-lien { display: inline-block; margin-top: 10px; color: var(--eau-encre); font-weight: 600; min-height: 44px; line-height: 44px; } -#territoire .t-types { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 2px; } -#territoire .t-types button { width: 100%; display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px; min-height: 44px; padding: 2px 8px; border: 1px solid transparent; border-radius: 10px; background: none; text-align: left; } -#territoire .t-types button svg { width: 34px; height: 34px; } -#territoire .t-types button[aria-pressed="true"] { border-color: var(--encre); background: #fff; } -#territoire .t-types button:disabled { cursor: default; opacity: .5; } -#territoire .t-types .t-lib { font-weight: 600; } -#territoire .t-types .t-n { font-size: 13px; color: var(--encre-2); white-space: nowrap; } -#territoire.panneau-ouvert .vers-vue { display: none; } -@media (min-width: 900px) { #territoire .t-panneau { left: 16px; right: auto; bottom: calc(var(--bas-t) + 12px); width: 400px; border: 1px solid var(--trait); border-radius: 16px; } } -@media (prefers-reduced-motion: reduce) { #territoire .t-ep { transition: none; } } -/* le « + » : ajouter un lieu, rond, en bas à droite, au-dessus de l'attribution */ -#territoire .t-plus { position: absolute; z-index: 1001; right: 12px; bottom: calc(var(--bas-t) + 34px); width: 52px; height: 52px; padding: 0; display: grid; place-items: center; - border: 0; border-radius: 50%; background: var(--quartier-encre); color: #fff; box-shadow: var(--ombre); } -#territoire .t-plus svg { width: 26px; height: 26px; } -#territoire .t-plus[aria-expanded="true"] { background: var(--encre); } -#territoire.panneau-ouvert .t-plus { display: none; } -#territoire .t-fonction { font-weight: 600; } -#territoire .t-adresse { padding: 8px 10px; border-left: 3px solid var(--quartier); background: var(--quartier-fond); border-radius: 0 8px 8px 0; } -#territoire .t-proposer { display: inline-flex; align-items: center; margin-top: 14px; min-height: 44px; padding: 0 16px; border-radius: 10px; background: var(--quartier-encre); color: #fff; font-weight: 600; text-decoration: none; } diff --git a/maquette/territoire.css b/maquette/territoire.css new file mode 100644 index 0000000..b7d3506 --- /dev/null +++ b/maquette/territoire.css @@ -0,0 +1,64 @@ +/* La vue « Le territoire » (lot ⑥b, 11/11) : chargée avec elle (maquette/territoire.js), la démo n'en paie rien. */ +/* « Voir le système » : en haut, sous le sélecteur (en bas, il couvrirait l'attribution d'OSM, que la politique des tuiles interdit de cacher) */ +#territoire .vers-vue { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 116px); bottom: auto; z-index: 1000; } +@media (min-width: 900px) { #territoire .vers-vue { top: 120px; bottom: auto; } } +/* la vue territoire : la carte couvre la page sous le sticky ; la maquette se tait dessous */ +#territoire { --bas-t: calc(64px + env(safe-area-inset-bottom, 0px)); position: fixed; inset: 0; z-index: 3; background: var(--papier); } +#territoire .t-carte { position: absolute; inset: 0 0 var(--bas-t) 0; background: #e8e6dc; font: 13px/1.4 Barlow, system-ui, sans-serif; } +#territoire .t-etat { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); margin: 0; z-index: 1001; background: var(--papier-2); border: 1px solid var(--trait); border-radius: 12px; padding: 10px 14px; box-shadow: var(--ombre); } +#territoire .t-etat:empty { display: none; } +/* les contrôles natifs de Leaflet, au trait du site : 44 px au doigt, sous le sélecteur */ +#territoire .leaflet-top { top: calc(env(safe-area-inset-top, 0px) + 112px); } +#territoire .leaflet-control-zoom { border: 1px solid var(--trait); border-radius: 12px; box-shadow: var(--ombre); overflow: hidden; } +#territoire .leaflet-control-zoom a { width: 44px; height: 44px; line-height: 44px; font: 600 22px/44px Barlow, sans-serif; color: var(--encre); background: var(--papier-2); } +#territoire .leaflet-control-attribution { font: 12px/1.35 Barlow, sans-serif; background: rgba(255, 253, 246, .92); color: var(--encre-2); padding: 2px 7px; max-width: calc(100vw - 16px); } +#territoire .leaflet-control-attribution a { color: var(--eau-encre); } +#territoire .leaflet-container:focus-visible { outline: 3px solid var(--eau-encre); outline-offset: -3px; } +@media (min-width: 900px) { #territoire .leaflet-top { top: 120px; } } +#territoire .t-barre { position: absolute; left: 0; right: 0; bottom: 0; height: var(--bas-t); box-sizing: border-box; padding: 0 12px env(safe-area-inset-bottom, 0px); display: flex; align-items: center; gap: 10px; + background: var(--papier-2); border-top: 1px solid var(--trait); box-shadow: 0 -8px 28px rgba(16, 42, 58, .12); z-index: 1000; } +#territoire .t-titre { flex: 1; min-width: 0; font: 600 15px/1.15 "Barlow Condensed", Barlow, sans-serif; color: var(--encre-2); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; } +/* la légende, au bas de la carte */ +#territoire .t-b-legende { flex: none; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px 0 8px; border: 1px solid var(--trait); border-radius: 999px; background: #fff; box-shadow: var(--ombre); font: 600 15px/1 Barlow, sans-serif; color: var(--encre); } +#territoire .t-b-legende[aria-expanded="true"] { background: var(--encre); color: var(--papier-2); border-color: var(--encre); } +#territoire .t-pictos { display: flex; } +#territoire .t-pictos svg { width: 26px; height: 26px; margin-right: -7px; } +#territoire .t-pictos svg:last-child { margin-right: 2px; } +/* les lieux : un pictogramme de 36 px dans une cible de 44 */ +#territoire .t-ep-icone { background: none; border: 0; } +#territoire .t-ep { width: 44px; height: 44px; padding: 4px; border: 0; background: none; border-radius: 50%; cursor: pointer; transition: opacity .25s, transform .2s; } +#territoire .t-ep svg { display: block; width: 36px; height: 36px; filter: drop-shadow(0 2px 4px rgba(16, 42, 58, .35)); } +#territoire .t-ep.actif { transform: scale(1.18); } +#territoire .t-ep.estompe { opacity: .28; } +#territoire .t-ep:focus-visible { outline: 3px solid var(--eau-encre); outline-offset: 0; } +/* les panneaux du bas : la légende, un lieu */ +#territoire .t-panneau { position: absolute; z-index: 1002; left: 0; right: 0; bottom: 0; max-height: min(62vh, 520px); overflow: auto; box-sizing: border-box; padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px)); + background: var(--papier-2); border-top: 1px solid var(--trait); border-radius: 16px 16px 0 0; box-shadow: 0 -8px 28px rgba(16, 42, 58, .16); } +#territoire .t-tete { display: flex; gap: 10px; align-items: flex-start; } +#territoire .t-tete h2 { margin: 2px 0 0; font: 600 20px/1.15 "Barlow Condensed", Barlow, sans-serif; } +#territoire .t-fermer { order: 9; margin-left: auto; flex: none; width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--trait); border-radius: 50%; background: #fff; } +#territoire .t-fermer svg { width: 20px; height: 20px; } +#territoire .t-icone svg { width: 48px; height: 48px; display: block; } +#territoire .t-type { font: 600 13px/1.2 Barlow, sans-serif; text-transform: uppercase; letter-spacing: .04em; } +#territoire .t-panneau p { margin: 10px 0 0; } +#territoire .t-statut, #territoire .t-position, #territoire .t-aide { font-size: 13.5px; color: var(--encre-2); } +#territoire .t-lien { display: inline-block; margin-top: 10px; color: var(--eau-encre); font-weight: 600; min-height: 44px; line-height: 44px; } +#territoire .t-types { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 2px; } +#territoire .t-types button { width: 100%; display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px; min-height: 44px; padding: 2px 8px; border: 1px solid transparent; border-radius: 10px; background: none; text-align: left; } +#territoire .t-types button svg { width: 34px; height: 34px; } +#territoire .t-types button[aria-pressed="true"] { border-color: var(--encre); background: #fff; } +#territoire .t-types button:disabled { cursor: default; opacity: .5; } +#territoire .t-types .t-lib { font-weight: 600; } +#territoire .t-types .t-n { font-size: 13px; color: var(--encre-2); white-space: nowrap; } +#territoire.panneau-ouvert .vers-vue { display: none; } +@media (min-width: 900px) { #territoire .t-panneau { left: 16px; right: auto; bottom: calc(var(--bas-t) + 12px); width: 400px; border: 1px solid var(--trait); border-radius: 16px; } } +@media (prefers-reduced-motion: reduce) { #territoire .t-ep { transition: none; } } +/* le « + » : ajouter un lieu, rond, en bas à droite, au-dessus de l'attribution */ +#territoire .t-plus { position: absolute; z-index: 1001; right: 12px; bottom: calc(var(--bas-t) + 64px); width: 52px; height: 52px; padding: 0; display: grid; place-items: center; + border: 0; border-radius: 50%; background: var(--quartier-encre); color: #fff; box-shadow: var(--ombre); } +#territoire .t-plus svg { width: 26px; height: 26px; } +#territoire .t-plus[aria-expanded="true"] { background: var(--encre); } +#territoire.panneau-ouvert .t-plus { display: none; } +#territoire .t-fonction { font-weight: 600; } +#territoire .t-adresse { padding: 8px 10px; border-left: 3px solid var(--quartier); background: var(--quartier-fond); border-radius: 0 8px 8px 0; } +#territoire .t-proposer { display: inline-flex; align-items: center; margin-top: 14px; min-height: 44px; padding: 0 16px; border-radius: 10px; background: var(--quartier-encre); color: #fff; font-weight: 600; text-decoration: none; } diff --git a/maquette/territoire.js b/maquette/territoire.js index 5c51bf6..b9956a0 100644 --- a/maquette/territoire.js +++ b/maquette/territoire.js @@ -6,6 +6,7 @@ // Dessus : les lieux (content/xl-epingles.md), un pictogramme par type (content/xl-types.md, maquette/pictos-xl.ts), une // légende qui met un type en avant, un panneau par lieu. Une seule couche de lieux, filtrable par type (Jules, 07/11). import 'leaflet/dist/leaflet.css'; +import './territoire.css'; import { Map as Carte, TileLayer, Control, LatLngBounds, Marker, DivIcon } from 'leaflet'; import { EPINGLES, TYPES, TEXTES, RECTANGLE } from 'virtual:territoire'; import { FOND, ZOOM_MIN, ZOOM_MAX } from './fond-carte.ts'; @@ -28,7 +29,7 @@ export function creerTerritoire({ $, reduit, vues, couleurs, onSysteme }) { zoomControl: false, attributionControl: false, // les gestes natifs : un doigt déplace, deux doigts zooment ; molette au bureau ; flèches et +/− au clavier dragging: true, touchZoom: true, scrollWheelZoom: true, doubleClickZoom: true, boxZoom: false, keyboard: true, - zoomAnimation: !reduit, fadeAnimation: !reduit, markerZoomAnimation: !reduit, inertia: !reduit, + zoomAnimation: !reduit, fadeAnimation: false, markerZoomAnimation: !reduit, inertia: !reduit, }); // les tuiles : rien hors du rectangle élargi, pas de tuiles « retina » (4 fois plus d'images au téléphone), aucun // préchargement : Leaflet ne demande que les tuiles de la vue (keepBuffer garde, il ne charge pas) @@ -169,7 +170,7 @@ export function creerTerritoire({ $, reduit, vues, couleurs, onSysteme }) { }, cacher() { fermer(false); }, /** Les tuiles de la vue sont arrivées (ou `ms` ont passé) : la démo peut se construire derrière (main.js). */ - // (la démo attend encore le fondu des tuiles, 260 ms : elle occupe le processeur une seconde en se construisant) - tuiles: (ms) => new Promise((ok) => { const t = setTimeout(ok, ms); couche.once('load', () => { clearTimeout(t); setTimeout(ok, reduit ? 0 : 260); }); }), + // (sans fondu : une tuile arrivée se montre tout de suite ; la démo attend une image, puis occupe le processeur une seconde) + tuiles: (ms) => new Promise((ok) => { const t = setTimeout(ok, ms); couche.once('load', () => { clearTimeout(t); requestAnimationFrame(() => setTimeout(ok, 0)); }); }), }; } diff --git a/tests/xl-v1.test.ts b/tests/xl-v1.test.ts index 36604d6..debeac9 100644 --- a/tests/xl-v1.test.ts +++ b/tests/xl-v1.test.ts @@ -142,3 +142,39 @@ test('le « + » est un lien vers /proposer d’AEP (aucun formulaire) ; ses tex assert.match(page, /Fond de carte du territoire : tuiles des serveurs publics d'OpenStreetMap \(licence ODbL\)/); assert.doesNotMatch(page, / { + const { build } = await import('vite'); + const sortie = mkdtempSync(join(tmpdir(), 'quartier-xl-v1-')); + try { + await build({ configFile: fileURLToPath(new URL('../vite.config.ts', import.meta.url)), root: fileURLToPath(new URL('..', import.meta.url)), logLevel: 'silent', build: { outDir: sortie, emptyOutDir: true } }); + const fichiers = readdirSync(join(sortie, 'assets')); + const lire = (f: string) => readFileSync(join(sortie, 'assets', f), 'utf8'); + const js = fichiers.filter((f) => f.endsWith('.js')), css = fichiers.filter((f) => f.endsWith('.css')); + const index = js.filter((f) => f.startsWith('index-')), ter = js.filter((f) => f.startsWith('territoire-')); + assert.equal(index.length, 1); assert.equal(ter.length, 1); + // la démo ne contient pas Leaflet ; la vue territoire, si + assert.doesNotMatch(lire(index[0]!), /Leaflet 1\.9|leaflet-container|leaflet-tile/); + assert.match(lire(ter[0]!), /Leaflet 1\.9\.4/); + for (const f of css.filter((x) => x.startsWith('index-'))) assert.doesNotMatch(lire(f), /leaflet-|.t-ep|.t-panneau/); + // ni maplibre ni pmtiles, nulle part (noms de fichiers et contenus) + const tout = (d: string): string[] => readdirSync(d).flatMap((n) => (statSync(join(d, n)).isDirectory() ? tout(join(d, n)) : [join(d, n)])); + for (const f of tout(sortie)) { + assert.doesNotMatch(f, /maplibre|pmtiles|xl-proto/i, f); + if (/\.(js|css|html|json|txt)$/.test(f)) assert.doesNotMatch(readFileSync(f, 'utf8'), /maplibre|pmtiles/i, f); + } + // un seul hôte de tuiles dans le code servi (le repli IGN reste hors du paquet) + const code = js.map(lire).join('\n'); + assert.match(code, /tile\.openstreetmap\.org\/\{z\}\/\{x\}\/\{y\}\.png/); + assert.doesNotMatch(code, /geopf|basemaps|cartocdn|\{s\}\.tile/); + // la feuille de Leaflet est groupée, mais ses images par défaut ne sont demandées que par un marqueur par défaut ou + // le contrôle des couches, que la page n'emploie pas (mesuré au RECAP : 0 requête d'image Leaflet) + assert.doesNotMatch(lire(ter[0]!), /new \w+\.Icon\.Default|Control\.Layers/); + } finally { rmSync(sortie, { recursive: true, force: true }); } +});