refactor(site): extract shared utilities and centralise dialogue IDs

- new src/hooks/ui/useIsMobile.ts (matchMedia + useSyncExternalStore)
  replacing the resize-handler hook inlined inside pages/site/page.tsx
- new src/hooks/ui/usePrefersReducedMotion.ts
- new src/data/site/dialogueIds.ts so site and intro components stop
  carrying hard-coded narrator IDs
- siteConfig: add SITE_BACKGROUND_STYLE shared by SiteLayout and
  SiteMobileBlocker, rename forcedName to presetPlayerName, fix the
  swapped id/label pairing on situation cards
- useSiteStore: rename selectedExperience/Situation to *Index so the
  stored value (an array index) is obvious in callers
- audioConfig: drop dead AUDIO_PATHS placeholders
- propagate the renames and SITE_BACKGROUND_STYLE through SiteLayout,
  SiteWelcomeScreen, SiteSituationScreen and pages/site/page.tsx
This commit is contained in:
Tom Boullay
2026-05-30 18:43:35 +02:00
parent 6ae21a2427
commit 0f6860f1ae
10 changed files with 116 additions and 72 deletions
+9
View File
@@ -0,0 +1,9 @@
/**
* Dialogue manifest IDs used by the /site flow and the intro sequence.
* Defined once here so components don't hold magic strings.
*/
export const SITE_DIALOGUE_IDS = {
naming: "narrateur_intro_prenom",
transition: "narrateur_intro_apresprenom",
introOrder: "narrateur_ordreebike",
} as const;
+19 -4
View File
@@ -1,8 +1,23 @@
import type { CSSProperties } from "react";
const BACKGROUND_IMAGE = "/assets/bg-site.png";
export const SITE_CONFIG = {
backgroundImage: "/assets/bg-site.png",
forcedName: "Danyl",
backgroundImage: BACKGROUND_IMAGE,
presetPlayerName: "Danyl",
} as const;
/**
* Shared background style used by SiteLayout and SiteMobileBlocker.
*/
export const SITE_BACKGROUND_STYLE: CSSProperties = {
backgroundColor: "#87CEEB",
backgroundImage: `url(${BACKGROUND_IMAGE})`,
backgroundSize: "cover",
backgroundPosition: "center",
backgroundRepeat: "no-repeat",
};
export interface SiteCardConfig {
id: string;
label: string;
@@ -24,10 +39,10 @@ export const EXPERIENCE_CARDS: readonly SiteCardConfig[] = [
* Cards for screen 2: "Quelle est votre situation ?"
*/
export const SITUATION_CARDS: readonly SiteCardConfig[] = [
{ id: "sit-refugie-climat", label: "Sans domicile fixe", disabled: true },
{ id: "sit-sans-domicile", label: "Sans domicile fixe", disabled: true },
{ id: "sit-refugie-guerre", label: "Réfugié.e de guerre", disabled: true },
{
id: "sit-sans-domicile",
id: "sit-refugie-climat",
label: "Réfugié.e climatique",
disabled: false,
},