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:
@@ -3,14 +3,14 @@ import type { SiteStep } from "@/types/game";
|
||||
|
||||
interface SiteState {
|
||||
currentStep: SiteStep;
|
||||
selectedExperience: number | null;
|
||||
selectedSituation: number | null;
|
||||
selectedExperienceIndex: number | null;
|
||||
selectedSituationIndex: number | null;
|
||||
}
|
||||
|
||||
interface SiteActions {
|
||||
setStep: (step: SiteStep) => void;
|
||||
setSelectedExperience: (index: number) => void;
|
||||
setSelectedSituation: (index: number) => void;
|
||||
setSelectedExperienceIndex: (index: number) => void;
|
||||
setSelectedSituationIndex: (index: number) => void;
|
||||
reset: () => void;
|
||||
}
|
||||
|
||||
@@ -18,14 +18,15 @@ type SiteStore = SiteState & SiteActions;
|
||||
|
||||
const initialState: SiteState = {
|
||||
currentStep: "disclaimer",
|
||||
selectedExperience: null,
|
||||
selectedSituation: null,
|
||||
selectedExperienceIndex: null,
|
||||
selectedSituationIndex: null,
|
||||
};
|
||||
|
||||
export const useSiteStore = create<SiteStore>()((set) => ({
|
||||
...initialState,
|
||||
setStep: (step) => set({ currentStep: step }),
|
||||
setSelectedExperience: (index) => set({ selectedExperience: index }),
|
||||
setSelectedSituation: (index) => set({ selectedSituation: index }),
|
||||
setSelectedExperienceIndex: (index) =>
|
||||
set({ selectedExperienceIndex: index }),
|
||||
setSelectedSituationIndex: (index) => set({ selectedSituationIndex: index }),
|
||||
reset: () => set(initialState),
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user