Repository Public
1// Brand & Motion Lab — page interne (hors navigation publique, non indexée).2// On y valide le symbole, ses déclinaisons, les états de la porte, les icônes3// et la transition « Ouvrir la porte » avec de vrais logements.45import { useEffect, useMemo, useRef, useState, type CSSProperties, type ReactNode } from "react";6import { useQuery } from "@tanstack/react-query";7import { fetchSearch } from "@/lib/api";8import { useTitle } from "@/lib/hooks";9import { setTheme, useTheme } from "@/lib/store";10import { LoukaAnimatedDoor, LoukaDoor, LoukaExploreButton, LoukaLoadingIndicator, useDoorEngine } from "@/brand/Door";11import { LoukaEmptyState } from "@/brand/EmptyState";12import { ANGLE, DOOR_TIMINGS, getMotionPref, setMotionPref, totalDuration, type DoorState, type MotionLevel, type MotionPref } from "@/brand/engine";13import { BRAND } from "@/brand/geometry";14import { LOUKA_ICONS } from "@/brand/icons";15import { LoukaLogo, LoukaSymbol, LoukaWordmark } from "@/brand/Symbol";16import { openListing } from "@/brand/transition";17import { ListingCard } from "@/components/ListingCard";1819function Block({ title, note, children }: { title: string; note?: string; children: ReactNode }) {20 return (21 <section className="border-t border-line py-10">22 <div className="mb-6 flex flex-wrap items-baseline justify-between gap-2">23 <h2 className="text-[1.5rem]">{title}</h2>24 {note && <p className="max-w-xl text-sm text-ink-3">{note}</p>}25 </div>26 {children}27 </section>28 );29}3031const PROPOSALS = [32 ["1-seuil", "Seuil", "retenue"],33 ["2-arche", "Arche", ""],34 ["3-plein", "Plein", ""],35 ["4-trait", "Trait", ""],36 ["5-lumiere", "Lumière", ""],37] as const;3839const LEVELS: MotionLevel[] = ["signature", "standard", "compact", "reduced", "none"];40const STATES: DoorState[] = ["closed", "idle", "hover", "ajar", "opening", "open", "revealing", "navigating", "closing", "completed", "interrupted", "error"];4142function Playground() {43 const engine = useDoorEngine(ANGLE.closed);44 const [state, setState] = useState<DoorState>(engine.state);45 const [angle, setAngle] = useState(0);46 const [duration, setDuration] = useState(230);47 const [persp, setPersp] = useState(4.2);48 const [shade, setShade] = useState(1);49 const [log, setLog] = useState<string[]>([]);50 useEffect(51 () =>52 engine.subscribe((s, a) => {53 setState(s);54 setAngle(Math.round(a));55 setLog((l) => [`${s} · ${Math.round(a)}°`, ...l].slice(0, 8));56 }),57 [engine],58 );59 const btn = "h-9 rounded-[8px] border border-line-2 px-3 text-[0.82rem] font-medium hover:border-ink-3";60 return (61 <div className="grid gap-8 lg:grid-cols-[auto_1fr]">62 <div className="grid place-items-center rounded-xl border border-line bg-surface p-10">63 <LoukaDoor64 size={170}65 engine={engine}66 style={{ perspective: `${170 * persp}px`, filter: undefined, ["--shade" as string]: shade } as CSSProperties}67 interior={<div className="lk-door__fill bg-[linear-gradient(180deg,#f3d9c2,#e9b890)]" />}68 />69 </div>70 <div className="space-y-5">71 <div className="flex flex-wrap gap-2">72 <button type="button" className={btn} onClick={() => void engine.hover()}>Survol</button>73 <button type="button" className={btn} onClick={() => void engine.rest("ajar")}>Entrouverte</button>74 <button type="button" className={btn} onClick={() => void engine.open(duration)}>Ouvrir</button>75 <button type="button" className={btn} onClick={() => void engine.close(duration)}>Fermer</button>76 <button type="button" className={btn} onClick={() => engine.interrupt()}>Interrompre</button>77 <button type="button" className={btn} onClick={() => engine.fail()}>Erreur</button>78 <button type="button" className={btn} onClick={() => engine.reset()}>Remise à zéro</button>79 </div>80 <div className="grid gap-4 sm:grid-cols-2">81 <label className="text-sm">82 <span className="mb-1 block text-ink-3">Angle imposé : {angle}°</span>83 <input type="range" min={0} max={110} value={angle} onChange={(e) => engine.reset(Number(e.target.value), "idle")} className="w-full accent-[var(--brand)]" />84 </label>85 <label className="text-sm">86 <span className="mb-1 block text-ink-3">Durée d'ouverture : {duration} ms</span>87 <input type="range" min={80} max={900} step={10} value={duration} onChange={(e) => setDuration(Number(e.target.value))} className="w-full accent-[var(--brand)]" />88 </label>89 <label className="text-sm">90 <span className="mb-1 block text-ink-3">Perspective : {persp.toFixed(1)} × la largeur</span>91 <input type="range" min={1.5} max={10} step={0.1} value={persp} onChange={(e) => setPersp(Number(e.target.value))} className="w-full accent-[var(--brand)]" />92 </label>93 <label className="text-sm">94 <span className="mb-1 block text-ink-3">Intensité des ombres : {shade.toFixed(2)}</span>95 <input type="range" min={0} max={1} step={0.05} value={shade} onChange={(e) => setShade(Number(e.target.value))} className="w-full accent-[var(--brand)]" />96 </label>97 </div>98 <div className="flex flex-wrap gap-1.5">99 {STATES.map((s) => (100 <span key={s} className={`rounded-[6px] border px-2 py-1 text-xs ${s === state ? "border-brand bg-brand-soft text-brand" : "border-line text-ink-3"}`}>101 {s}102 </span>103 ))}104 </div>105 <pre className="num rounded-lg bg-surface-2 p-3 text-xs leading-relaxed text-ink-2">{log.join("\n") || "journal des états"}</pre>106 </div>107 </div>108 );109}110111function TransitionDemo() {112 const q = useQuery({ queryKey: ["lab-listings"], queryFn: () => fetchSearch({ sort: "recent", page_size: 12, include: "liste", city: "Montréal" }) });113 const [level, setLevel] = useState<MotionLevel>("signature");114 const [pref, setPref] = useState<MotionPref>(getMotionPref());115 const refs = useRef<Record<string, HTMLDivElement | null>>({});116 const listings = useMemo(() => q.data?.listings.filter((l) => l.images.length).slice(0, 4) ?? [], [q.data]);117 return (118 <div>119 <div className="mb-5 flex flex-wrap items-center gap-2">120 <span className="text-sm text-ink-3">Niveau joué par les boutons :</span>121 {LEVELS.map((l) => (122 <button key={l} type="button" onClick={() => setLevel(l)} className={`h-8 rounded-[8px] border px-3 text-[0.8rem] ${l === level ? "border-brand bg-brand-soft text-brand" : "border-line-2 text-ink-2"}`}>123 {l} · {totalDuration(DOOR_TIMINGS[l])} ms124 </button>125 ))}126 </div>127 <div className="grid gap-5 sm:grid-cols-2 lg:grid-cols-4">128 {listings.map((l) => (129 <div key={l.uid} ref={(el) => { refs.current[l.uid] = el; }}>130 <ListingCard listing={l} />131 <button132 type="button"133 className="mt-2 h-9 w-full rounded-[8px] border border-line-2 text-[0.82rem] font-medium hover:border-ink-3"134 onClick={() => openListing({ uid: l.uid, image: l.images[0] ?? null, from: refs.current[l.uid]?.querySelector("[data-door-source]") ?? null, level })}135 >136 Ouvrir en « {level} »137 </button>138 </div>139 ))}140 </div>141 <div className="mt-6 flex flex-wrap items-center gap-2 text-sm">142 <span className="text-ink-3">Préférence de l'utilisateur (cartes ci-dessus, clic direct) :</span>143 {(["auto", ...LEVELS] as MotionPref[]).map((p) => (144 <button key={p} type="button" onClick={() => { setMotionPref(p); setPref(p); }} className={`h-8 rounded-[8px] border px-3 text-[0.8rem] ${p === pref ? "border-brand bg-brand-soft text-brand" : "border-line-2 text-ink-2"}`}>145 {p}146 </button>147 ))}148 </div>149 </div>150 );151}152153export default function Lab() {154 useTitle("Brand & Motion Lab");155 const theme = useTheme();156 const [hover, setHover] = useState(false);157 useEffect(() => {158 const m = document.createElement("meta");159 m.name = "robots";160 m.content = "noindex";161 document.head.appendChild(m);162 return () => m.remove();163 }, []);164 return (165 <div className="container-x pb-24 pt-10">166 <div className="flex flex-wrap items-end justify-between gap-4 pb-8">167 <div>168 <div className="eyebrow">Interne</div>169 <h1 className="mt-2 text-[2.4rem]">Brand & Motion Lab</h1>170 <p className="mt-2 max-w-xl text-ink-2">Le symbole, ses déclinaisons, le moteur de la porte et la transition « Ouvrir la porte ».</p>171 </div>172 <button type="button" onClick={() => setTheme(theme === "dark" ? "light" : "dark")} className="h-10 rounded-[10px] border border-line-2 px-4 text-sm font-medium">173 Thème : {theme === "dark" ? "nuit" : "jour"}174 </button>175 </div>176177 <Block title="Cinq propositions" note="Toutes partent du logo d'origine : une porte entrouverte, charnières à gauche, dans un encadrement orange.">178 <div className="grid grid-cols-2 gap-4 sm:grid-cols-5">179 {PROPOSALS.map(([file, name, tag]) => (180 <figure key={file} className={`rounded-xl border bg-[#F7F6F0] p-5 text-center ${tag ? "border-brand" : "border-line"}`}>181 <img src={`/brand/proposals/${file}.svg`} alt={`Proposition ${name}`} className="mx-auto size-24" />182 <figcaption className="mt-3 text-sm font-medium text-[#181C1A]">183 {name} {tag && <span className="ml-1 text-xs font-normal text-[#245B48]">· {tag}</span>}184 </figcaption>185 </figure>186 ))}187 </div>188 </Block>189190 <Block title="Logo final" note="Seuil : deux montants, un linteau, le panneau entrouvert, la poignée, le seuil.">191 <div className="grid gap-4 lg:grid-cols-3">192 <div className="flex h-36 items-center justify-center rounded-xl border border-line bg-surface"><LoukaLogo size={44} className="text-[2rem]" /></div>193 <div className="flex h-36 items-center justify-center rounded-xl" style={{ background: BRAND.night }}>194 <LoukaLogo size={44} tone="inverse" className="text-[2rem]" />195 </div>196 <div className="flex h-36 items-center justify-center rounded-xl" style={{ background: BRAND.forest, color: BRAND.ivory }}>197 <span className="inline-flex items-center gap-3 text-[2rem]"><LoukaSymbol size={44} tone="mono" /><LoukaWordmark tone="mono" /></span>198 </div>199 </div>200 <div className="mt-6 flex flex-wrap items-end gap-7">201 {[16, 20, 24, 32, 48, 64, 96, 160].map((s) => (202 <div key={s} className="text-center"><LoukaSymbol size={s} /><div className="num mt-2 text-xs text-ink-3">{s}</div></div>203 ))}204 </div>205 <div className="mt-6 flex flex-wrap items-center gap-8">206 {(["brand", "mono", "orange"] as const).map((t) => (207 <div key={t} className="text-center"><LoukaSymbol size={56} tone={t} /><div className="mt-2 text-xs text-ink-3">{t}</div></div>208 ))}209 <div className="rounded-lg p-3 text-center" style={{ background: BRAND.night }}><LoukaSymbol size={56} tone="inverse" /><div className="mt-2 text-xs" style={{ color: "#8a948d" }}>inverse</div></div>210 <LoukaLogo size={26} className="text-[1.25rem]" />211 <LoukaLogo size={26} compact />212 </div>213 </Block>214215 <Block title="Door Engine" note="Machine à états explicite ; l'angle est une propriété animée, interruptible à tout moment.">216 <Playground />217 <div className="mt-8 flex flex-wrap items-end gap-8">218 {[0, 16, 40, 60, 80, 96].map((a) => (219 <div key={a} className="text-center"><LoukaDoor size={56} angle={a} /><div className="num mt-3 text-xs text-ink-3">{a}°</div></div>220 ))}221 </div>222 </Block>223224 <Block title="Usages" note="Avec retenue : la porte n'apparaît que là où elle veut dire quelque chose.">225 <div className="flex flex-wrap items-center gap-8">226 <LoukaExploreButton to="/recherche">Explorer</LoukaExploreButton>227 <LoukaExploreButton to="/recherche" variant="outline">Voir les logements</LoukaExploreButton>228 <div className="flex items-center gap-3 text-sm text-ink-2" onMouseEnter={() => setHover(true)} onMouseLeave={() => setHover(false)}>229 <LoukaAnimatedDoor size={26} active={hover} /> Survolez-moi230 </div>231 <div className="flex items-center gap-3 text-sm text-ink-2"><LoukaLoadingIndicator /> Chargement réel</div>232 </div>233 </Block>234235 <Block title="Icônes architecturales" note="Grille 24, trait 1,6, mêmes montants et même seuil que le symbole.">236 <div className="grid grid-cols-2 gap-3 sm:grid-cols-4 lg:grid-cols-7">237 {Object.entries(LOUKA_ICONS).map(([name, Icon]) => (238 <div key={name} className="rounded-lg border border-line bg-surface p-4 text-center">239 <Icon size={28} className="mx-auto text-ink" />240 <div className="mt-2 text-xs text-ink-3">{name}</div>241 </div>242 ))}243 </div>244 </Block>245246 <Block title="États vides">247 <div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">248 <div className="rounded-xl border border-line bg-surface"><LoukaEmptyState kind="closed" title="Aucun logement ici" text="Élargissez la zone ou retirez un filtre." /></div>249 <div className="rounded-xl border border-line bg-surface"><LoukaEmptyState kind="ajar" title="Par où commencer ?" text="Choisissez une ville ou explorez la carte." /></div>250 <div className="rounded-xl border border-line bg-surface"><LoukaEmptyState kind="many" title="Comparez vos options" text="Ajoutez jusqu'à quatre logements." /></div>251 <div className="rounded-xl border border-line bg-surface"><LoukaEmptyState kind="heart" title="Aucun favori" text="Touchez le cœur d'une annonce pour la garder." /></div>252 </div>253 </Block>254255 <Block title="Ouvrir la porte" note="Transition signature avec de vrais logements : cliquez une carte, ou forcez un niveau.">256 <TransitionDemo />257 </Block>258 </div>259 );260}261