Commit d35c1995 by PLN (Algolia)

les-femmes: peaufinage — clavier de fiche (flèches prev/next, Home/Échap…

les-femmes: peaufinage — clavier de fiche (flèches prev/next, Home/Échap accueil, Entrée lightbox portrait), deep-links ?zoom=<quote> et ?detail=<femme> avec fuzzy match (préfixe et sous-chaîne prioritaires sur Levenshtein, mieux qu'un 404 via redirect client depuis le void), migration aux tokens du site donc dark mode complet, text-wrap pretty/balance pour les césures, crédits Commons sans underscores
parent b9ababb7
"use client";
import { useEffect, useState } from "react";
import { useTransitionNav } from "./useTransitionNav";
import style from "./style.module.css";
/**
* Clavier de fiche : ← / → passent à la femme précédente/suivante,
* Home et Échap ramènent au landing, Entrée zoome le portrait (Échap ou
* Entrée le referme d'abord). Rend null sans portrait (Entrée n'a rien à
* zoomer) — le reste est actif sur toutes les fiches.
*/
export default function FemmeKeys({ prev, next, imgSrc, imgAlt }) {
const go = useTransitionNav();
const [zoom, setZoom] = useState(false);
useEffect(() => {
const onKey = (e) => {
const t = e.target;
if (t instanceof HTMLElement && /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)) return;
if (e.metaKey || e.ctrlKey || e.altKey) return;
if (zoom) {
if (e.key === "Escape" || e.key === "Enter") {
e.preventDefault();
setZoom(false);
}
return;
}
if (e.key === "ArrowRight" && next) {
e.preventDefault();
go(`/les-femmes/${next}`);
} else if (e.key === "ArrowLeft" && prev) {
e.preventDefault();
go(`/les-femmes/${prev}`);
} else if (e.key === "Escape" || e.key === "Home") {
e.preventDefault();
go("/les-femmes/");
} else if (e.key === "Enter" && imgSrc) {
e.preventDefault();
setZoom(true);
}
};
window.addEventListener("keydown", onKey);
return () => window.removeEventListener("keydown", onKey);
}, [zoom, prev, next, imgSrc, go]);
if (!zoom || !imgSrc) return null;
return (
<div
className={style.lightbox}
onClick={() => setZoom(false)}
role="dialog"
aria-modal="true"
aria-label={`Portrait : ${imgAlt}`}
>
<img src={imgSrc} alt={imgAlt} />
</div>
);
}
"use client";
import { useEffect } from "react";
import { bestFemmeForQuery } from "./data";
/**
* Fuzzy redirect pour les URLs /les-femmes/<slug> inconnues : mieux qu'un
* 404, on tombe sur la fiche la plus proche du slug demandé. Rendu null
* partout ailleurs — le void hydra reste la 404 du site.
*
* window.location.replace et pas router.replace : depuis la route 404 le
* routeur client n'a pas d'arbre connu et navigue en silence dans le vide ;
* un chemin de rattrapage peut se payer un plein reload.
*/
export default function LesFemmesRedirect() {
useEffect(() => {
const m = window.location.pathname.match(/^\/les-femmes\/([^/?#]+)/);
if (!m) return;
const query = decodeURIComponent(m[1]);
const femme = bestFemmeForQuery(query);
if (femme) window.location.replace(`/les-femmes/${femme.slug}`);
}, []);
return null;
}
......@@ -4,13 +4,14 @@
max-width: 72rem;
margin: 0 auto;
padding: 2.5rem 1.25rem 5rem;
color: #2d2a32;
color: var(--text-primary);
}
.heroTitle {
font-size: clamp(1.9rem, 5vw, 3rem);
line-height: 1.15;
margin: 0 0 0.75rem;
text-wrap: balance;
}
.heroTitle a {
......@@ -20,13 +21,15 @@
.heroSub {
font-size: 1.05rem;
color: #5f5a66;
color: var(--text-muted);
margin: 0 0 1.5rem;
max-width: 46rem;
}
.enBref {
background: #f7f3f8;
text-wrap: pretty;
background: var(--surface-raised);
border-left: 3px solid #7b3f8c;
border-radius: 0 8px 8px 0;
padding: 1rem 1.25rem;
......@@ -37,15 +40,17 @@
}
.legend {
text-wrap: pretty;
font-size: 0.85rem;
color: #5f5a66;
color: var(--text-muted);
line-height: 1.6;
margin: 0 0 2.5rem;
max-width: 60rem;
}
.legend strong {
color: #2d2a32;
color: var(--text-primary);
}
.filters {
......@@ -56,25 +61,25 @@
}
.chip {
border: 1px solid #d9d2e0;
border: 1px solid var(--border);
background: transparent;
border-radius: 999px;
padding: 0.3rem 0.8rem;
font-size: 0.82rem;
cursor: pointer;
color: #5f5a66;
color: var(--text-muted);
transition: all 120ms ease;
}
.chip:hover {
border-color: #7b3f8c;
color: #2d2a32;
color: var(--text-primary);
}
.chipOn {
background: #2d2a32;
border-color: #2d2a32;
color: #fff;
background: var(--text-primary);
border-color: var(--text-primary);
color: var(--surface);
}
.grid {
......@@ -88,10 +93,10 @@
display: flex;
flex-direction: column;
gap: 0.6rem;
border: 1px solid #e4dee8;
border: 1px solid var(--border);
border-radius: 12px;
padding: 1.1rem 1.1rem 1rem;
background: #fff;
background: var(--surface);
text-decoration: none;
color: inherit;
transition: border-color 120ms ease, transform 120ms ease;
......@@ -119,19 +124,19 @@
font-size: 0.95rem;
line-height: 1.45;
margin: 0;
color: #2d2a32;
color: var(--text-primary);
font-style: italic;
}
.punchlineMissing {
font-size: 0.85rem;
color: #a0a0a8;
color: var(--text-muted);
font-style: normal;
}
.femmes {
font-size: 0.85rem;
color: #5f5a66;
color: var(--text-muted);
margin: auto 0 0;
padding-top: 0.4rem;
}
......@@ -155,7 +160,7 @@
.count {
font-size: 0.8rem;
color: #a0a0a8;
color: var(--text-muted);
margin: 0 0 1rem;
}
......@@ -202,16 +207,17 @@
object-fit: cover;
object-position: top;
display: block;
view-transition-name: femme-portrait;
}
.credit {
font-size: 0.75rem;
color: #a0a0a8;
color: var(--text-muted);
margin: 0 0 1.25rem;
}
.credit a {
color: #a0a0a8;
color: var(--text-muted);
}
/* Fiche : article à gauche, aside (portrait + liens) à droite, en panneaux. */
......@@ -235,8 +241,8 @@
}
.panel {
background: #fff;
border: 1px solid #e4dee8;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 14px;
padding: 1.4rem 1.5rem;
margin: 0 0 1.25rem;
......@@ -266,7 +272,7 @@
font-size: 0.75rem;
text-transform: uppercase;
letter-spacing: 0.06em;
color: #a0a0a8;
color: var(--text-muted);
margin: 1.1rem 0 0.4rem;
}
......@@ -286,14 +292,21 @@
color: #7b3f8c;
}
/* Landing à deux états. Par défaut (sans JS) les deux vues s'empilent ;
le JS ajoute jsOn + punchOn/femmesOn pour ne montrer qu'une vue. */
/* Landing à trois états. Par défaut (sans JS) les vues s'empilent ;
le JS ajoute jsOn + punchOn/femmesOn/celebresOn pour n'en montrer qu'une. */
.jsOn.punchOn .femmesView {
.jsOn.punchOn .femmesView,
.jsOn.punchOn .celebresView {
display: none;
}
.jsOn.femmesOn .punchView {
.jsOn.femmesOn .punchView,
.jsOn.femmesOn .celebresView {
display: none;
}
.jsOn.celebresOn .punchView,
.jsOn.celebresOn .femmesView {
display: none;
}
......@@ -328,14 +341,14 @@
.prowFocused {
opacity: 1;
transform: scale(1.04);
background: #fff;
background: var(--surface);
box-shadow: 0 14px 40px rgba(45, 42, 50, 0.09);
z-index: 2;
}
.prowMissing .pquote {
font-style: normal;
color: #a0a0a8;
color: var(--text-muted);
font-size: 1rem;
}
......@@ -343,7 +356,7 @@
display: block;
font-size: 0.68rem;
letter-spacing: 0.14em;
color: #a0a0a8;
color: var(--text-muted);
font-variant-numeric: tabular-nums;
margin: 0 0 0.25rem;
}
......@@ -361,6 +374,7 @@
font-size: 1.4rem;
line-height: 1.3;
display: block;
text-wrap: balance;
}
.pquoteMissing {
......@@ -422,9 +436,9 @@
}
.ctaGhost {
border: 1px solid #d9d2e0;
border: 1px solid var(--border);
background: transparent;
color: #5f5a66;
color: var(--text-muted);
font-size: 0.9rem;
border-radius: 999px;
padding: 0.5rem 1.2rem;
......@@ -433,7 +447,7 @@
.ctaGhost:hover {
border-color: #7b3f8c;
color: #2d2a32;
color: var(--text-primary);
}
/* Barre sticky et footer. */
......@@ -448,16 +462,16 @@
gap: 1rem;
margin: -2.5rem -1.25rem 2rem;
padding: 0.9rem 1.25rem;
background: rgba(255, 255, 255, 0.86);
background: color-mix(in srgb, var(--surface) 88%, transparent);
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
border-bottom: 1px solid #e4dee8;
border-bottom: 1px solid var(--border);
}
.topbarHome {
font-size: 0.85rem;
font-weight: 600;
color: #2d2a32;
color: var(--text-primary);
text-decoration: none;
white-space: nowrap;
overflow: hidden;
......@@ -478,9 +492,9 @@
.footer {
margin-top: 4rem;
padding-top: 1.25rem;
border-top: 1px solid #e4dee8;
border-top: 1px solid var(--border);
font-size: 0.8rem;
color: #a0a0a8;
color: var(--text-muted);
}
.footer a {
......@@ -509,6 +523,35 @@
text-align: right;
}
/* Lightbox portrait (Entrée pour ouvrir, Échap/clic pour fermer). */
.lightbox {
position: fixed;
inset: 0;
z-index: 100;
display: flex;
align-items: center;
justify-content: center;
background: rgba(20, 17, 24, 0.92);
cursor: zoom-out;
padding: 2rem;
}
.lightbox img {
max-width: 100%;
max-height: 100%;
object-fit: contain;
border-radius: 8px;
box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.kbdHint {
font-size: 0.72rem;
color: var(--text-muted);
margin: 1.4rem 0 0;
line-height: 1.6;
}
/* Femme page */
.femmeHeader {
......@@ -518,11 +561,13 @@
.femmeName {
font-size: clamp(1.7rem, 4vw, 2.5rem);
margin: 0 0 0.5rem;
text-wrap: balance;
view-transition-name: femme-name;
}
.personnageRef {
font-size: 0.95rem;
color: #5f5a66;
color: var(--text-muted);
margin: 0 0 0.75rem;
}
......@@ -542,12 +587,13 @@
line-height: 1.7;
margin: 0;
white-space: pre-line;
text-wrap: pretty;
}
.links {
margin: 2.5rem 0 0;
padding-top: 1.25rem;
border-top: 1px solid #e4dee8;
border-top: 1px solid var(--border);
font-size: 0.9rem;
max-width: 44rem;
}
......@@ -556,7 +602,7 @@
font-size: 0.8rem;
text-transform: uppercase;
letter-spacing: 0.05em;
color: #a0a0a8;
color: var(--text-muted);
margin: 0 0 0.5rem;
}
......@@ -578,10 +624,10 @@
display: inline-block;
margin-top: 2.5rem;
font-size: 0.9rem;
color: #5f5a66;
color: var(--text-muted);
text-decoration: none;
}
.back:hover {
color: #2d2a32;
color: var(--text-primary);
}
......@@ -2,6 +2,7 @@ import fs from 'fs';
import path from 'path';
import matter from 'gray-matter';
import NotFoundHydra from '@/components/not-found-hydra';
import LesFemmesRedirect from '@/app/les-femmes/LesFemmesRedirect';
import { resolveHydraSketch, withLocalAssets } from '@/lib/hydra-sketch';
export const metadata = {
......@@ -56,6 +57,7 @@ export default async function NotFound() {
const sketches = await loadSketches();
return (
<div className="block relative min-h-[100dvh] cursor-pointer">
<LesFemmesRedirect />
<NotFoundHydra sketches={sketches} />
{/* No z-index here: a stacking context on <main> would seal the
children's mix-blend-mode away from the canvas behind — plain
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment