Files
nav-carte/components/entree/SchemaEchelles.vue
T
Jules NenyandClaude Opus 5.5 d3d96155f4 feat(entree): mouvement CSS, reduced motion, aep_entree_vue (B13-M6)
- Apparition, première vue du schéma seulement : anneaux XL, M, S du
  dehors vers le dedans (opacité, échelle 0,9 → 1, transform-box
  fill-box, origine au centre), puis lettres, noms et arcs : 900 ms en
  tout (utils/figures.ts). La clé localStorage `aep_entree_vue` (dans un
  try) est posée quand le grand schéma est à l'écran ; un script de tête
  pose `html.entree-vue` avant le premier rendu si elle existe, l'animation
  ne se rejoue donc ni au rechargement ni après une navigation interne.
- Ouverture 220 ms : grand schéma retiré d'un coup, mini-schéma en fondu
  150 ms, section qui monte de 16 px. Latéral 280 ms : sections en ±24 %,
  safran qui passe d'un anneau à l'autre en 200 ms ; débordement rogné
  par `overflow-x: clip` (le mini-schéma reste collant).
- prefers-reduced-motion : `animation: none` et transitions coupées, état
  final au premier rendu, échange immédiat, focus sur le titre.
  Rien ne boucle ; rien ne bouge sans geste hors l'apparition unique.

Vérifié dans Chromium : XL anime seul à 120 ms, tout posé à 1,2 s,
rechargement sans animation ; sous reduce, 0 animation et focus posé ;
latéral à 360 px sans défilement horizontal (360/360).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JRiXG2Re6g7mF9c85FemTB
2026-10-12 02:22:57 +02:00

544 lines
17 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!--
SchemaEchelles — B13-M2
Le schéma des trois échelles (deck v3.3, slide 16, `drawEchelles`), porté en SVG
déclaratif : rendu côté serveur, présent au premier affichage (CONCEPTION §7).
Géométrie : utils/figures.ts ; textes : utils/echelles.ts (source unique).
taille="grand" (état 0 de l'entrée) : la figure + les trois portes en liens HTML
(lettre, titre, accroche de la slide 16). Noms et arcs « ce qui sort / ce qui revient »
gardés dans le SVG à partir de 1 024 px seulement (16 px environ) ; en dessous ils
seraient à 9 px, les portes HTML les remplacent. Ouvrir une porte = `push`.
taille="mini" (porte ouverte) : barre collante au téléphone (retour au schéma + S M XL),
colonne à partir de 1 024 px (retour, figure réduite, portes titrées). Passer d'une
porte à l'autre = `replace` (une seule entrée d'historique par visite).
Survol ou focus d'un anneau allume sa porte, et l'inverse. Les anneaux sont des
cibles de pointeur ; au clavier, ce sont les liens qui portent l'action (le SVG est
une image décrite en `grand`, décoratif en `mini`).
-->
<template>
<component
:is="taille === 'mini' ? 'nav' : 'div'"
class="schema"
:class="[`schema--${taille}`, { 'schema--apparition': joueApparition }]"
:aria-label="taille === 'mini' ? 'Portes S, M, XL' : undefined"
@mouseleave="survol = null"
>
<div v-if="$slots.avant" class="schema__avant"><slot name="avant" /></div>
<a
v-if="taille === 'mini'"
:href="hrefSchema"
class="schema__fermer"
@click.prevent="emit('fermer')"
>
<svg class="schema__fermer-icone" viewBox="0 0 40 40" aria-hidden="true" focusable="false">
<circle
v-for="(r, id) in ICONE"
:key="id"
cx="20"
cy="20"
:r="r"
:class="{ 'schema__fermer-actif': actif === id }"
/>
</svg>
<span class="schema__fermer-texte">Revenir au schéma</span>
</a>
<svg
class="schema__figure"
:viewBox="`0 0 ${SCHEMA_L} ${SCHEMA_H}`"
:role="taille === 'grand' ? 'img' : undefined"
:aria-label="taille === 'grand' ? description : undefined"
:aria-hidden="taille === 'mini' ? 'true' : undefined"
focusable="false"
>
<g
v-for="a in anneaux"
:key="a.id"
class="schema__anneau"
:class="[
`schema__anneau--${a.id}`,
{ 'schema__anneau--survol': survol === a.id, 'schema__anneau--actif': actif === a.id },
]"
:style="styleAnneau(a.rang)"
@mouseenter="survol = a.id"
@click="choisir(a.id)"
>
<path class="schema__zone" :d="a.zone" fill-rule="evenodd" />
<circle class="schema__trait" :cx="a.cx" :cy="a.cy" :r="a.r" />
</g>
<text
v-for="a in anneaux"
:key="`lettre-${a.id}`"
class="schema__lettre"
:x="a.cx"
:y="a.yLettre"
:font-size="a.tailleLettre"
text-anchor="middle"
:style="styleLettre(a.rang)"
>{{ a.id }}</text>
<template v-if="taille === 'grand'">
<text
v-for="a in anneaux"
:key="`nom-${a.id}`"
class="schema__nom"
:x="a.cx"
:y="a.yNom"
font-size="22"
text-anchor="middle"
:style="styleLettre(a.rang)"
>{{ nomAnneau(a.id) }}</text>
<defs>
<path v-for="arc in arcs" :id="idArc(arc)" :key="idArc(arc)" :d="arc.d" />
</defs>
<text
v-for="arc in arcs"
:key="`flux-${idArc(arc)}`"
class="schema__flux"
font-size="22"
><textPath :href="`#${idArc(arc)}`" startOffset="50%" text-anchor="middle">{{ FLECHE[arc.sens] }} {{ ECHELLES_FLUX[arc.frontiere][arc.sens] }}</textPath></text>
<text class="schema__legende" :x="legende.x" :y="legende.ySort" :font-size="legende.taille" text-anchor="end">{{ FLECHE.sort }} {{ ECHELLES_FLUX_LEGENDE.sort }}</text>
<text class="schema__legende" :x="legende.x" :y="legende.yRevient" :font-size="legende.taille" text-anchor="end">{{ FLECHE.revient }} {{ ECHELLES_FLUX_LEGENDE.revient }}</text>
</template>
</svg>
<ul class="schema__portes">
<li v-for="id in ORDRE_ECHELLES" :key="id">
<NuxtLink
:to="lienPorte(id)"
:replace="taille === 'mini'"
class="schema__porte"
:class="{ 'schema__porte--survol': survol === id, 'schema__porte--actif': actif === id }"
:aria-current="actif === id ? 'true' : undefined"
:data-porte="id"
@mouseenter="survol = id"
@focus="survol = id"
@blur="survol = null"
>
<span class="schema__porte-lettre">{{ id }}</span>
<span class="schema__porte-texte">
<span class="schema__porte-titre">{{ ECHELLES[id].titre }}</span>
<span v-if="taille === 'grand'" class="schema__porte-accroche">{{ ECHELLES[id].accroche }}</span>
</span>
<span v-if="taille === 'grand'" class="schema__porte-fleche" aria-hidden="true">›</span>
</NuxtLink>
</li>
</ul>
<div v-if="$slots.apres" class="schema__apres"><slot name="apres" /></div>
</component>
</template>
<script setup lang="ts">
import { useId } from 'vue'
import {
ECHELLES, ORDRE_ECHELLES, ECHELLES_FLUX, ECHELLES_FLUX_LEGENDE, PARAM_PORTE,
type EchelleId,
} from '~/utils/echelles'
import {
SCHEMA_L, SCHEMA_H, anneauxEchelles, arcsFlux, legendeFlux, delaisApparition,
type ArcFlux, type SensFlux,
} from '~/utils/figures'
const props = withDefaults(defineProps<{
taille: 'grand' | 'mini'
/** Porte ouverte (mini) : son anneau et son lien en safran. */
actif?: EchelleId | null
/**
* Première vue du schéma (grand) : les anneaux apparaissent du dehors vers le dedans
* (XL, M, S), puis les lettres, en 900 ms au plus, une fois (B13-M6). CSS seul ;
* sans effet sous `prefers-reduced-motion` ou si `html.entree-vue` est posé.
*/
apparition?: boolean
}>(), { actif: null, apparition: false })
const emit = defineEmits<{ fermer: [] }>()
const route = useRoute()
const router = useRouter()
const uid = useId()
const anneaux = anneauxEchelles()
const arcs = arcsFlux()
const legende = legendeFlux()
const FLECHE: Record<SensFlux, string> = { sort: '↓', revient: '↑' }
/** Icône du retour au schéma (téléphone) : trois cercles, rayons dans l'ordre XL, M, S. */
const ICONE: Record<EchelleId, number> = { XL: 18, M: 12, S: 6 }
const survol = ref<EchelleId | null>(null)
/** Le nom écrit dans l'anneau, comme sur la slide 16 : le titre de l'échelle, initiale en minuscule. */
const nomAnneau = (id: EchelleId) => {
const t = ECHELLES[id].titre
return t.charAt(0).toLowerCase() + t.slice(1)
}
const idArc = (arc: ArcFlux) => `${uid}-arc-${arc.frontiere}-${arc.sens}`
/** Description de la figure, sur le modèle de l'aria-label du deck. */
const description = (() => {
const anneauxTxt = ORDRE_ECHELLES.map((id) => `${id}, ${nomAnneau(id)}`).join(' ; ')
const flux = (f: 'S' | 'M', entre: string) =>
`Entre ${entre}, ${ECHELLES_FLUX_LEGENDE.sort} : ${ECHELLES_FLUX[f].sort} ; ${ECHELLES_FLUX_LEGENDE.revient} : ${ECHELLES_FLUX[f].revient}.`
return `Trois anneaux imbriqués, S au centre : ${anneauxTxt}. ${flux('S', 'S et M')} ${flux('M', 'M et XL')}`
})()
function queryPorte(id: EchelleId | null) {
const q: Record<string, unknown> = { ...route.query }
if (id) q[PARAM_PORTE] = id
else delete q[PARAM_PORTE]
return q as Record<string, string>
}
const lienPorte = (id: EchelleId) => ({ path: route.path, query: queryPorte(id) })
/** Adresse du schéma : le retour reste un vrai lien (nouvel onglet, sans JavaScript). */
const hrefSchema = computed(() => router.resolve({ path: route.path, query: queryPorte(null) }).href)
function choisir(id: EchelleId) {
if (props.taille === 'mini' && props.actif === id) return
navigateTo(lienPorte(id), { replace: props.taille === 'mini' })
}
// Apparition (B13-M6) : délais par rang, du dehors vers le dedans (utils/figures.ts).
const joueApparition = computed(() => props.apparition && props.taille === 'grand')
const styleAnneau = (rang: number) =>
joueApparition.value ? { animationDelay: `${delaisApparition(rang).anneau}ms` } : undefined
const styleLettre = (rang: number) =>
joueApparition.value ? { animationDelay: `${delaisApparition(rang).lettre}ms` } : undefined
</script>
<style scoped>
/* ── Commun ────────────────────────────────────────────────────────────── */
.schema__figure {
display: block;
height: auto;
overflow: visible;
}
.schema__zone {
fill: color-mix(in srgb, var(--nav-primary-solid) 5%, transparent);
cursor: pointer;
transition: fill 200ms var(--ease-out);
}
.schema__anneau--M .schema__zone { fill: color-mix(in srgb, var(--nav-primary-solid) 8%, transparent); }
.schema__anneau--S .schema__zone { fill: color-mix(in srgb, var(--nav-primary-solid) 12%, transparent); }
.schema__trait {
fill: none;
stroke: color-mix(in srgb, var(--nav-primary-solid) 60%, transparent);
stroke-width: 2px;
vector-effect: non-scaling-stroke;
pointer-events: none;
transition: stroke 200ms var(--ease-out);
}
.schema__anneau--survol .schema__zone { fill: color-mix(in srgb, var(--accent) 20%, transparent); }
.schema__anneau--actif .schema__zone { fill: color-mix(in srgb, var(--accent) 32%, transparent); }
.schema__anneau--survol .schema__trait,
.schema__anneau--actif .schema__trait {
stroke: var(--accent);
stroke-width: 3px;
}
.schema__lettre,
.schema__nom,
.schema__flux,
.schema__legende {
pointer-events: none;
font-family: var(--font-body);
}
.schema__lettre {
fill: var(--text);
font-weight: var(--fw-bold);
}
.schema__nom,
.schema__flux,
.schema__legende {
display: none;
fill: color-mix(in srgb, var(--text) 78%, transparent);
}
.schema__flux { font-style: italic; }
.schema__legende { font-family: var(--font-mono); }
.schema__portes {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
gap: var(--space-xs);
}
.schema__porte {
display: flex;
align-items: center;
gap: var(--space-sm);
min-height: 44px;
padding: var(--space-xs) var(--space-sm);
border: 1px solid var(--border);
border-radius: var(--radius-md);
background: var(--surface);
color: var(--text);
text-decoration: none;
transition: background-color 200ms var(--ease-out), border-color 200ms var(--ease-out);
}
.schema__porte:focus-visible {
outline: 2px solid var(--focus-ring);
outline-offset: 2px;
}
.schema__porte-lettre {
flex: 0 0 auto;
min-width: 2.25rem;
padding: 0.15rem 0.4rem;
border-radius: var(--radius-sm);
background: color-mix(in srgb, var(--nav-primary-solid) 10%, transparent);
color: var(--text);
font-weight: var(--fw-bold);
font-size: var(--fs-sm);
text-align: center;
letter-spacing: 0.04em;
transition: background-color 200ms var(--ease-out);
}
.schema__porte-texte {
display: flex;
flex-direction: column;
min-width: 0;
}
.schema__porte-titre {
font-weight: var(--fw-semibold);
font-size: var(--fs-base);
line-height: var(--lh-tight);
}
.schema__porte-accroche {
margin-top: 0.15rem;
font-size: var(--fs-sm);
line-height: 1.35;
color: color-mix(in srgb, var(--text) 78%, transparent);
}
.schema__porte-fleche {
margin-left: auto;
font-size: var(--fs-xl);
line-height: 1;
color: color-mix(in srgb, var(--text) 78%, transparent);
}
.schema__porte:hover,
.schema__porte--survol {
border-color: var(--accent);
background: color-mix(in srgb, var(--accent) 14%, var(--surface));
}
.schema__porte:hover .schema__porte-lettre,
.schema__porte--survol .schema__porte-lettre,
.schema__porte--actif .schema__porte-lettre {
background: var(--accent);
color: var(--on-accent);
}
.schema__porte--actif {
border-color: var(--accent);
}
/* ── Grand : l'état 0 ──────────────────────────────────────────────────── */
.schema--grand {
display: grid;
grid-template-columns: minmax(0, 1fr);
grid-template-areas: "avant" "figure" "portes" "apres";
gap: var(--space-sm);
width: 100%;
max-width: 30rem;
margin-inline: auto;
}
.schema--grand .schema__avant { grid-area: avant; }
.schema--grand .schema__figure {
grid-area: figure;
justify-self: center;
width: 100%;
max-width: 27.5rem;
}
.schema--grand .schema__portes { grid-area: portes; }
.schema--grand .schema__apres { grid-area: apres; }
@media (min-width: 1024px) {
.schema--grand {
max-width: 68rem;
grid-template-columns: minmax(0, 604px) minmax(0, 26rem);
grid-template-rows: 1fr auto 1fr;
grid-template-areas: "figure avant" "figure portes" "figure apres";
column-gap: var(--space-2xl);
row-gap: var(--space-md);
align-items: center;
justify-content: center;
}
.schema--grand .schema__avant { align-self: end; }
.schema--grand .schema__apres { align-self: start; }
.schema--grand .schema__figure { max-width: 604px; }
.schema--grand .schema__nom,
.schema--grand .schema__flux,
.schema--grand .schema__legende { display: inline; }
}
/* ── Mini : la porte ouverte ───────────────────────────────────────────── */
.schema--mini {
display: flex;
align-items: center;
gap: var(--space-xs);
}
.schema--mini .schema__figure { display: none; }
.schema--mini .schema__portes {
flex-direction: row;
gap: 4px;
}
.schema--mini .schema__porte {
justify-content: center;
min-width: 44px;
padding: 0 var(--space-xs);
}
.schema--mini .schema__porte-lettre {
min-width: 2rem;
}
/* Au téléphone, la lettre seule ; le titre reste lu par les lecteurs d'écran. */
.schema--mini .schema__porte-titre,
.schema__fermer-texte {
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
overflow: hidden;
clip: rect(0 0 0 0);
white-space: nowrap;
border: 0;
}
.schema__fermer {
display: inline-flex;
align-items: center;
justify-content: center;
gap: var(--space-xs);
min-width: 44px;
min-height: 44px;
border-radius: var(--radius-md);
color: var(--text);
font-size: var(--fs-sm);
font-weight: var(--fw-semibold);
text-decoration: none;
}
.schema__fermer:hover { background: var(--bg-alt); }
.schema__fermer:focus-visible {
outline: 2px solid var(--focus-ring);
outline-offset: 2px;
}
.schema__fermer-icone {
width: 32px;
height: 32px;
overflow: visible;
}
.schema__fermer-icone circle {
fill: color-mix(in srgb, var(--nav-primary-solid) 6%, transparent);
stroke: color-mix(in srgb, var(--nav-primary-solid) 60%, transparent);
stroke-width: 1.5px;
transition: fill 200ms var(--ease-out), stroke 200ms var(--ease-out);
}
.schema__fermer-icone .schema__fermer-actif {
fill: color-mix(in srgb, var(--accent) 35%, transparent);
stroke: var(--accent);
stroke-width: 2px;
}
@media (min-width: 1024px) {
.schema--mini {
flex-direction: column;
align-items: stretch;
gap: var(--space-md);
}
.schema--mini .schema__fermer {
justify-content: flex-start;
padding: 0 var(--space-xs);
}
.schema--mini .schema__fermer-icone { display: none; }
.schema--mini .schema__fermer-texte,
.schema--mini .schema__porte-titre {
position: static;
width: auto;
height: auto;
margin: 0;
overflow: visible;
clip: auto;
white-space: normal;
}
.schema--mini .schema__fermer-texte::before {
content: "← " / "";
}
.schema--mini .schema__figure {
display: block;
width: 100%;
max-width: 15rem;
align-self: center;
}
.schema--mini .schema__portes { flex-direction: column; }
.schema--mini .schema__porte {
justify-content: flex-start;
padding: var(--space-xs) var(--space-sm);
}
}
@media (prefers-reduced-motion: reduce) {
.schema__zone,
.schema__trait,
.schema__porte,
.schema__porte-lettre,
.schema__fermer-icone circle { transition: none; }
}
</style>
<!--
Apparition (B13-M6), hors du bloc scoped : les @keyframes gardent leur nom et
`html.entree-vue` (posé avant le premier rendu par la page si l'apparition a
déjà été vue) doit pouvoir l'éteindre. Délais en style en ligne (rang).
Reduced motion = état final au premier rendu : `animation: none`, pas une durée
raccourcie (le deck gardait les délais et cachait des éléments près d'une seconde).
-->
<style>
.schema--apparition .schema__anneau {
animation: aep-schema-anneau 450ms var(--ease-out) backwards;
transform-box: fill-box;
transform-origin: center;
}
.schema--apparition .schema__lettre,
.schema--apparition .schema__nom {
animation: aep-schema-texte 250ms var(--ease-out) backwards;
}
.schema--apparition .schema__flux,
.schema--apparition .schema__legende {
animation: aep-schema-texte 250ms var(--ease-out) 650ms backwards;
}
@keyframes aep-schema-anneau {
from { opacity: 0; transform: scale(0.9); }
to { opacity: 1; transform: none; }
}
@keyframes aep-schema-texte {
from { opacity: 0; }
to { opacity: 1; }
}
html.entree-vue .schema--apparition .schema__anneau,
html.entree-vue .schema--apparition .schema__lettre,
html.entree-vue .schema--apparition .schema__nom,
html.entree-vue .schema--apparition .schema__flux,
html.entree-vue .schema--apparition .schema__legende {
animation: none;
}
@media (prefers-reduced-motion: reduce) {
.schema--apparition .schema__anneau,
.schema--apparition .schema__lettre,
.schema--apparition .schema__nom,
.schema--apparition .schema__flux,
.schema--apparition .schema__legende {
animation: none;
}
}
</style>