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 @@ ...@@ -4,13 +4,14 @@
max-width: 72rem; max-width: 72rem;
margin: 0 auto; margin: 0 auto;
padding: 2.5rem 1.25rem 5rem; padding: 2.5rem 1.25rem 5rem;
color: #2d2a32; color: var(--text-primary);
} }
.heroTitle { .heroTitle {
font-size: clamp(1.9rem, 5vw, 3rem); font-size: clamp(1.9rem, 5vw, 3rem);
line-height: 1.15; line-height: 1.15;
margin: 0 0 0.75rem; margin: 0 0 0.75rem;
text-wrap: balance;
} }
.heroTitle a { .heroTitle a {
...@@ -20,13 +21,15 @@ ...@@ -20,13 +21,15 @@
.heroSub { .heroSub {
font-size: 1.05rem; font-size: 1.05rem;
color: #5f5a66; color: var(--text-muted);
margin: 0 0 1.5rem; margin: 0 0 1.5rem;
max-width: 46rem; max-width: 46rem;
} }
.enBref { .enBref {
background: #f7f3f8; text-wrap: pretty;
background: var(--surface-raised);
border-left: 3px solid #7b3f8c; border-left: 3px solid #7b3f8c;
border-radius: 0 8px 8px 0; border-radius: 0 8px 8px 0;
padding: 1rem 1.25rem; padding: 1rem 1.25rem;
...@@ -37,15 +40,17 @@ ...@@ -37,15 +40,17 @@
} }
.legend { .legend {
text-wrap: pretty;
font-size: 0.85rem; font-size: 0.85rem;
color: #5f5a66; color: var(--text-muted);
line-height: 1.6; line-height: 1.6;
margin: 0 0 2.5rem; margin: 0 0 2.5rem;
max-width: 60rem; max-width: 60rem;
} }
.legend strong { .legend strong {
color: #2d2a32; color: var(--text-primary);
} }
.filters { .filters {
...@@ -56,25 +61,25 @@ ...@@ -56,25 +61,25 @@
} }
.chip { .chip {
border: 1px solid #d9d2e0; border: 1px solid var(--border);
background: transparent; background: transparent;
border-radius: 999px; border-radius: 999px;
padding: 0.3rem 0.8rem; padding: 0.3rem 0.8rem;
font-size: 0.82rem; font-size: 0.82rem;
cursor: pointer; cursor: pointer;
color: #5f5a66; color: var(--text-muted);
transition: all 120ms ease; transition: all 120ms ease;
} }
.chip:hover { .chip:hover {
border-color: #7b3f8c; border-color: #7b3f8c;
color: #2d2a32; color: var(--text-primary);
} }
.chipOn { .chipOn {
background: #2d2a32; background: var(--text-primary);
border-color: #2d2a32; border-color: var(--text-primary);
color: #fff; color: var(--surface);
} }
.grid { .grid {
...@@ -88,10 +93,10 @@ ...@@ -88,10 +93,10 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 0.6rem; gap: 0.6rem;
border: 1px solid #e4dee8; border: 1px solid var(--border);
border-radius: 12px; border-radius: 12px;
padding: 1.1rem 1.1rem 1rem; padding: 1.1rem 1.1rem 1rem;
background: #fff; background: var(--surface);
text-decoration: none; text-decoration: none;
color: inherit; color: inherit;
transition: border-color 120ms ease, transform 120ms ease; transition: border-color 120ms ease, transform 120ms ease;
...@@ -119,19 +124,19 @@ ...@@ -119,19 +124,19 @@
font-size: 0.95rem; font-size: 0.95rem;
line-height: 1.45; line-height: 1.45;
margin: 0; margin: 0;
color: #2d2a32; color: var(--text-primary);
font-style: italic; font-style: italic;
} }
.punchlineMissing { .punchlineMissing {
font-size: 0.85rem; font-size: 0.85rem;
color: #a0a0a8; color: var(--text-muted);
font-style: normal; font-style: normal;
} }
.femmes { .femmes {
font-size: 0.85rem; font-size: 0.85rem;
color: #5f5a66; color: var(--text-muted);
margin: auto 0 0; margin: auto 0 0;
padding-top: 0.4rem; padding-top: 0.4rem;
} }
...@@ -155,7 +160,7 @@ ...@@ -155,7 +160,7 @@
.count { .count {
font-size: 0.8rem; font-size: 0.8rem;
color: #a0a0a8; color: var(--text-muted);
margin: 0 0 1rem; margin: 0 0 1rem;
} }
...@@ -202,16 +207,17 @@ ...@@ -202,16 +207,17 @@
object-fit: cover; object-fit: cover;
object-position: top; object-position: top;
display: block; display: block;
view-transition-name: femme-portrait;
} }
.credit { .credit {
font-size: 0.75rem; font-size: 0.75rem;
color: #a0a0a8; color: var(--text-muted);
margin: 0 0 1.25rem; margin: 0 0 1.25rem;
} }
.credit a { .credit a {
color: #a0a0a8; color: var(--text-muted);
} }
/* Fiche : article à gauche, aside (portrait + liens) à droite, en panneaux. */ /* Fiche : article à gauche, aside (portrait + liens) à droite, en panneaux. */
...@@ -235,8 +241,8 @@ ...@@ -235,8 +241,8 @@
} }
.panel { .panel {
background: #fff; background: var(--surface);
border: 1px solid #e4dee8; border: 1px solid var(--border);
border-radius: 14px; border-radius: 14px;
padding: 1.4rem 1.5rem; padding: 1.4rem 1.5rem;
margin: 0 0 1.25rem; margin: 0 0 1.25rem;
...@@ -266,7 +272,7 @@ ...@@ -266,7 +272,7 @@
font-size: 0.75rem; font-size: 0.75rem;
text-transform: uppercase; text-transform: uppercase;
letter-spacing: 0.06em; letter-spacing: 0.06em;
color: #a0a0a8; color: var(--text-muted);
margin: 1.1rem 0 0.4rem; margin: 1.1rem 0 0.4rem;
} }
...@@ -286,14 +292,21 @@ ...@@ -286,14 +292,21 @@
color: #7b3f8c; color: #7b3f8c;
} }
/* Landing à deux états. Par défaut (sans JS) les deux vues s'empilent ; /* Landing à trois états. Par défaut (sans JS) les vues s'empilent ;
le JS ajoute jsOn + punchOn/femmesOn pour ne montrer qu'une vue. */ le JS ajoute jsOn + punchOn/femmesOn/celebresOn pour n'en montrer qu'une. */
.jsOn.punchOn .femmesView { .jsOn.punchOn .femmesView,
.jsOn.punchOn .celebresView {
display: none; display: none;
} }
.jsOn.femmesOn .punchView { .jsOn.femmesOn .punchView,
.jsOn.femmesOn .celebresView {
display: none;
}
.jsOn.celebresOn .punchView,
.jsOn.celebresOn .femmesView {
display: none; display: none;
} }
...@@ -328,14 +341,14 @@ ...@@ -328,14 +341,14 @@
.prowFocused { .prowFocused {
opacity: 1; opacity: 1;
transform: scale(1.04); transform: scale(1.04);
background: #fff; background: var(--surface);
box-shadow: 0 14px 40px rgba(45, 42, 50, 0.09); box-shadow: 0 14px 40px rgba(45, 42, 50, 0.09);
z-index: 2; z-index: 2;
} }
.prowMissing .pquote { .prowMissing .pquote {
font-style: normal; font-style: normal;
color: #a0a0a8; color: var(--text-muted);
font-size: 1rem; font-size: 1rem;
} }
...@@ -343,7 +356,7 @@ ...@@ -343,7 +356,7 @@
display: block; display: block;
font-size: 0.68rem; font-size: 0.68rem;
letter-spacing: 0.14em; letter-spacing: 0.14em;
color: #a0a0a8; color: var(--text-muted);
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
margin: 0 0 0.25rem; margin: 0 0 0.25rem;
} }
...@@ -361,6 +374,7 @@ ...@@ -361,6 +374,7 @@
font-size: 1.4rem; font-size: 1.4rem;
line-height: 1.3; line-height: 1.3;
display: block; display: block;
text-wrap: balance;
} }
.pquoteMissing { .pquoteMissing {
...@@ -422,9 +436,9 @@ ...@@ -422,9 +436,9 @@
} }
.ctaGhost { .ctaGhost {
border: 1px solid #d9d2e0; border: 1px solid var(--border);
background: transparent; background: transparent;
color: #5f5a66; color: var(--text-muted);
font-size: 0.9rem; font-size: 0.9rem;
border-radius: 999px; border-radius: 999px;
padding: 0.5rem 1.2rem; padding: 0.5rem 1.2rem;
...@@ -433,7 +447,7 @@ ...@@ -433,7 +447,7 @@
.ctaGhost:hover { .ctaGhost:hover {
border-color: #7b3f8c; border-color: #7b3f8c;
color: #2d2a32; color: var(--text-primary);
} }
/* Barre sticky et footer. */ /* Barre sticky et footer. */
...@@ -448,16 +462,16 @@ ...@@ -448,16 +462,16 @@
gap: 1rem; gap: 1rem;
margin: -2.5rem -1.25rem 2rem; margin: -2.5rem -1.25rem 2rem;
padding: 0.9rem 1.25rem; 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); backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
border-bottom: 1px solid #e4dee8; border-bottom: 1px solid var(--border);
} }
.topbarHome { .topbarHome {
font-size: 0.85rem; font-size: 0.85rem;
font-weight: 600; font-weight: 600;
color: #2d2a32; color: var(--text-primary);
text-decoration: none; text-decoration: none;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
...@@ -478,9 +492,9 @@ ...@@ -478,9 +492,9 @@
.footer { .footer {
margin-top: 4rem; margin-top: 4rem;
padding-top: 1.25rem; padding-top: 1.25rem;
border-top: 1px solid #e4dee8; border-top: 1px solid var(--border);
font-size: 0.8rem; font-size: 0.8rem;
color: #a0a0a8; color: var(--text-muted);
} }
.footer a { .footer a {
...@@ -509,6 +523,35 @@ ...@@ -509,6 +523,35 @@
text-align: right; 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 */ /* Femme page */
.femmeHeader { .femmeHeader {
...@@ -518,11 +561,13 @@ ...@@ -518,11 +561,13 @@
.femmeName { .femmeName {
font-size: clamp(1.7rem, 4vw, 2.5rem); font-size: clamp(1.7rem, 4vw, 2.5rem);
margin: 0 0 0.5rem; margin: 0 0 0.5rem;
text-wrap: balance;
view-transition-name: femme-name;
} }
.personnageRef { .personnageRef {
font-size: 0.95rem; font-size: 0.95rem;
color: #5f5a66; color: var(--text-muted);
margin: 0 0 0.75rem; margin: 0 0 0.75rem;
} }
...@@ -542,12 +587,13 @@ ...@@ -542,12 +587,13 @@
line-height: 1.7; line-height: 1.7;
margin: 0; margin: 0;
white-space: pre-line; white-space: pre-line;
text-wrap: pretty;
} }
.links { .links {
margin: 2.5rem 0 0; margin: 2.5rem 0 0;
padding-top: 1.25rem; padding-top: 1.25rem;
border-top: 1px solid #e4dee8; border-top: 1px solid var(--border);
font-size: 0.9rem; font-size: 0.9rem;
max-width: 44rem; max-width: 44rem;
} }
...@@ -556,7 +602,7 @@ ...@@ -556,7 +602,7 @@
font-size: 0.8rem; font-size: 0.8rem;
text-transform: uppercase; text-transform: uppercase;
letter-spacing: 0.05em; letter-spacing: 0.05em;
color: #a0a0a8; color: var(--text-muted);
margin: 0 0 0.5rem; margin: 0 0 0.5rem;
} }
...@@ -578,10 +624,10 @@ ...@@ -578,10 +624,10 @@
display: inline-block; display: inline-block;
margin-top: 2.5rem; margin-top: 2.5rem;
font-size: 0.9rem; font-size: 0.9rem;
color: #5f5a66; color: var(--text-muted);
text-decoration: none; text-decoration: none;
} }
.back:hover { .back:hover {
color: #2d2a32; color: var(--text-primary);
} }
...@@ -2,6 +2,7 @@ import fs from 'fs'; ...@@ -2,6 +2,7 @@ import fs from 'fs';
import path from 'path'; import path from 'path';
import matter from 'gray-matter'; import matter from 'gray-matter';
import NotFoundHydra from '@/components/not-found-hydra'; import NotFoundHydra from '@/components/not-found-hydra';
import LesFemmesRedirect from '@/app/les-femmes/LesFemmesRedirect';
import { resolveHydraSketch, withLocalAssets } from '@/lib/hydra-sketch'; import { resolveHydraSketch, withLocalAssets } from '@/lib/hydra-sketch';
export const metadata = { export const metadata = {
...@@ -56,6 +57,7 @@ export default async function NotFound() { ...@@ -56,6 +57,7 @@ export default async function NotFound() {
const sketches = await loadSketches(); const sketches = await loadSketches();
return ( return (
<div className="block relative min-h-[100dvh] cursor-pointer"> <div className="block relative min-h-[100dvh] cursor-pointer">
<LesFemmesRedirect />
<NotFoundHydra sketches={sketches} /> <NotFoundHydra sketches={sketches} />
{/* No z-index here: a stacking context on <main> would seal the {/* No z-index here: a stacking context on <main> would seal the
children's mix-blend-mode away from the canvas behind — plain 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