diff --git a/public/llms.txt b/public/llms.txt new file mode 100644 index 00000000..c9aafeae --- /dev/null +++ b/public/llms.txt @@ -0,0 +1,12 @@ +# Runestone + +Runestone is a playable statechart explainer for software engineers. It maps a +five-room 3D dungeon to an executable XState machine and displays the active +state, transitions, guards, context, and actors while the user plays. + +## Primary pages + +- [Runestone](https://runestone.teeldinho.com/): Product explanation, concepts, + controls, and entry to the run. +- [Source](https://github.com/Teeldinho/runestone): Implementation and project + documentation. diff --git a/public/manifest.json b/public/manifest.json index 0b481e49..061552fd 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -1,24 +1,16 @@ { - "short_name": "TanStack App", - "name": "Create TanStack App Sample", + "short_name": "Runestone", + "name": "Runestone — A Playable Statechart Dungeon", + "description": "A five-room 3D dungeon that makes statechart execution visible while you play.", "icons": [ { - "src": "favicon.ico", - "sizes": "64x64 32x32 24x24 16x16", - "type": "image/x-icon" - }, - { - "src": "logo192.png", - "type": "image/png", - "sizes": "192x192" - }, - { - "src": "logo512.png", - "type": "image/png", - "sizes": "512x512" + "src": "/runestone-mark.svg", + "type": "image/svg+xml", + "sizes": "any", + "purpose": "any" } ], - "start_url": ".", + "start_url": "/", "display": "standalone", "theme_color": "#020308", "background_color": "#06080f" diff --git a/public/marketing/game-running-bg.png b/public/marketing/game-running-bg.png deleted file mode 100644 index 9cb8d141..00000000 Binary files a/public/marketing/game-running-bg.png and /dev/null differ diff --git a/public/marketing/game-running-bg.webp b/public/marketing/game-running-bg.webp new file mode 100644 index 00000000..13d51246 Binary files /dev/null and b/public/marketing/game-running-bg.webp differ diff --git a/public/robots.txt b/public/robots.txt index e9e57dc4..22612d06 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1,3 +1,4 @@ # https://www.robotstxt.org/robotstxt.html User-agent: * Disallow: +Sitemap: https://runestone.teeldinho.com/sitemap.xml diff --git a/public/runestone-mark.svg b/public/runestone-mark.svg new file mode 100644 index 00000000..d2a408d9 --- /dev/null +++ b/public/runestone-mark.svg @@ -0,0 +1,6 @@ + + Runestone + + + + diff --git a/public/sitemap.xml b/public/sitemap.xml new file mode 100644 index 00000000..4aa7518e --- /dev/null +++ b/public/sitemap.xml @@ -0,0 +1,6 @@ + + + + https://runestone.teeldinho.com/ + + diff --git a/src/app/providers/index.tsx b/src/app/providers/index.tsx index 5c0b332c..18cf6296 100644 --- a/src/app/providers/index.tsx +++ b/src/app/providers/index.tsx @@ -3,9 +3,7 @@ import type { ReactNode } from "react"; import { AuthProvider } from "@/features/auth"; import { TooltipProvider } from "@/shared/ui"; -import { AudioProvider } from "./AudioProvider"; import { ConvexProvider } from "./ConvexProvider"; -import { GameMachineProvider } from "./GameMachineProvider"; type AppProvidersProps = { children: ReactNode; @@ -15,14 +13,8 @@ export function AppProviders({ children }: AppProvidersProps) { return ( - - - {children} - - + {children} ); } - -export { AudioProvider, ConvexProvider, GameMachineProvider }; diff --git a/src/app/routes/-GameRouteContent.tsx b/src/app/routes/-GameRouteContent.tsx new file mode 100644 index 00000000..abe725f7 --- /dev/null +++ b/src/app/routes/-GameRouteContent.tsx @@ -0,0 +1,13 @@ +import { AudioProvider } from "@/app/providers/AudioProvider"; +import { GameMachineProvider } from "@/app/providers/GameMachineProvider"; +import { GamePage } from "@/pages/game"; + +export function GameRouteContent() { + return ( + + + + + + ); +} diff --git a/src/app/routes/__root.tsx b/src/app/routes/__root.tsx index e5556427..b29162a1 100644 --- a/src/app/routes/__root.tsx +++ b/src/app/routes/__root.tsx @@ -40,10 +40,36 @@ export const Route = createRootRoute({ content: "width=device-width, initial-scale=1", }, { - title: "Runestone", + title: "Runestone — A Playable Statechart Dungeon", }, + { + name: "description", + content: + "Explore a five-room 3D dungeon where rooms are states, corridors are transitions, and locked doors are guards. Watch the live statechart update as you play.", + }, + { + property: "og:title", + content: "Runestone — A Playable Statechart Dungeon", + }, + { + property: "og:description", + content: + "Walk through executable logic and inspect the statechart that defines the dungeon.", + }, + { + property: "og:type", + content: "website", + }, + { + name: "twitter:card", + content: "summary", + }, + ], + links: [ + { rel: "stylesheet", href: appCss }, + { rel: "manifest", href: "/manifest.json" }, + { rel: "icon", href: "/runestone-mark.svg", type: "image/svg+xml" }, ], - links: [{ rel: "stylesheet", href: appCss }], }), notFoundComponent: NotFoundPage, shellComponent: RootShell, diff --git a/src/app/routes/_marketing.concepts.tsx b/src/app/routes/_marketing.concepts.tsx index a461d3de..57e48c22 100644 --- a/src/app/routes/_marketing.concepts.tsx +++ b/src/app/routes/_marketing.concepts.tsx @@ -1,7 +1,11 @@ -import { createFileRoute } from "@tanstack/react-router"; - -import { ConceptsPage } from "@/pages/concepts"; +import { createFileRoute, redirect } from "@tanstack/react-router"; export const Route = createFileRoute("/_marketing/concepts")({ - component: ConceptsPage, + beforeLoad: () => { + throw redirect({ + to: "/", + hash: "machine", + statusCode: 301, + }); + }, }); diff --git a/src/app/routes/_marketing.tutorial.tsx b/src/app/routes/_marketing.tutorial.tsx index 6cdcdd9f..650a2047 100644 --- a/src/app/routes/_marketing.tutorial.tsx +++ b/src/app/routes/_marketing.tutorial.tsx @@ -1,7 +1,11 @@ -import { createFileRoute } from "@tanstack/react-router"; - -import { TutorialPage } from "@/pages/tutorial"; +import { createFileRoute, redirect } from "@tanstack/react-router"; export const Route = createFileRoute("/_marketing/tutorial")({ - component: TutorialPage, + beforeLoad: () => { + throw redirect({ + to: "/", + hash: "controls", + statusCode: 301, + }); + }, }); diff --git a/src/app/routes/game.tsx b/src/app/routes/game.tsx index 1e8361f5..779f3f93 100644 --- a/src/app/routes/game.tsx +++ b/src/app/routes/game.tsx @@ -5,8 +5,10 @@ import { APP_CONFIG } from "../../../app.config"; import { requirePersistedAuthSession } from "./-requirePersistedAuthSession"; -const GamePage = lazy(() => - import("@/pages/game").then((m) => ({ default: m.GamePage })), +const GameRouteContent = lazy(() => + import("./-GameRouteContent").then((module) => ({ + default: module.GameRouteContent, + })), ); export const Route = createFileRoute("/game")({ @@ -18,7 +20,7 @@ export const Route = createFileRoute("/game")({ function LazyGamePage() { return ( - + ); } diff --git a/src/app/styles/globals.css b/src/app/styles/globals.css index e408777e..af336339 100644 --- a/src/app/styles/globals.css +++ b/src/app/styles/globals.css @@ -1,4 +1,4 @@ -@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap"); +@import "@fontsource-variable/geist"; @import "tailwindcss"; @import "tw-animate-css"; @@ -9,7 +9,7 @@ :root { color-scheme: dark; - font-family: "Space Grotesk", "JetBrains Mono", sans-serif; + font-family: "Geist Variable", sans-serif; --radius: 0.5rem; --background: #06080f; --foreground: #f5f1e6; @@ -56,6 +56,16 @@ --dungeon-doorway-gate-emissive: #2f3a45; } +.marketing-theme { + color-scheme: dark; + --radius: 0.875rem; + --primary: var(--dungeon-gold); + --primary-foreground: var(--base-black); + --accent: var(--dungeon-rune); + --accent-foreground: var(--base-black); + --ring: var(--dungeon-rune); +} + @theme inline { --radius-sm: max(2px, calc(var(--radius) - 4px)); --radius-md: calc(var(--radius) - 2px); @@ -104,6 +114,8 @@ --color-dungeon-corridor-base: var(--dungeon-corridor-base); --color-dungeon-doorway-gate: var(--dungeon-doorway-gate); --color-dungeon-doorway-gate-emissive: var(--dungeon-doorway-gate-emissive); + --font-sans: "Geist Variable", sans-serif; + --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Code", monospace; } * { @@ -113,11 +125,64 @@ html, body { min-height: 100%; - overflow-x: hidden; + overflow-x: clip; +} + +.observatory-backdrop { + background-color: var(--background); + background-image: + radial-gradient( + circle at 82% 8%, + color-mix(in srgb, var(--dungeon-gold) 16%, transparent), + transparent 30rem + ), + radial-gradient( + circle at 8% 38%, + color-mix(in srgb, var(--dungeon-rune) 7%, transparent), + transparent 34rem + ), + linear-gradient( + 180deg, + color-mix(in srgb, var(--card) 38%, transparent), + transparent 26rem + ); +} + +.observatory-panel::after { + position: absolute; + inset: 0; + pointer-events: none; + content: ""; + background: linear-gradient( + 115deg, + transparent 0%, + color-mix(in srgb, var(--dungeon-rune) 7%, transparent) 48%, + transparent 70% + ); +} + +.observatory-active-room { + animation: observatory-trace 2.8s ease-in-out infinite; +} + +@keyframes observatory-trace { + 0%, + 100% { + box-shadow: + inset 0.2rem 0 0 var(--dungeon-rune), + 0 0 0 transparent; + } + 50% { + box-shadow: + inset 0.3rem 0 0 var(--dungeon-rune), + 0 0 1.5rem color-mix(in srgb, var(--dungeon-rune) 10%, transparent); + } } html { scrollbar-gutter: stable; + scroll-behavior: smooth; + scroll-padding-top: 6rem; } body { @@ -147,7 +212,7 @@ body { } .rune-text { - font-family: "Space Grotesk", sans-serif; + font-family: "Geist Variable", sans-serif; letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.65rem; @@ -156,7 +221,7 @@ body { } .rune-value { - font-family: "JetBrains Mono", monospace; + font-family: ui-monospace, "SFMono-Regular", "Cascadia Code", monospace; font-size: 0.85rem; color: var(--foreground); } @@ -167,7 +232,7 @@ body { gap: 0.5rem; padding: 0.375rem 0.75rem; font-size: 0.8rem; - font-family: "Space Grotesk", sans-serif; + font-family: "Geist Variable", sans-serif; font-weight: 500; border-radius: var(--radius-sm); border: 1px solid var(--panel-border); diff --git a/src/features/auth/config/authConfig.ts b/src/features/auth/config/authConfig.ts index 0ea5affb..d9907a1f 100644 --- a/src/features/auth/config/authConfig.ts +++ b/src/features/auth/config/authConfig.ts @@ -26,18 +26,18 @@ export const AUTH_ERROR_MESSAGES = { export const AUTH_BOOTSTRAP_TIMEOUT_MS = 10_000; export const AUTH_COPY = { - MODAL_TITLE: "Enter the dungeon", + MODAL_TITLE: "Name this run", MODAL_DESCRIPTION: - "Use the suggested name or edit it before saving your progress and leaderboard entry.", - MODAL_KEEP_READING_LABEL: "Keep reading", - USERNAME_LABEL: "Name", - USERNAME_PLACEHOLDER: "Your name", - USERNAME_SUBMIT_LABEL: "Enter the dungeon", - USERNAME_SUBMITTING_LABEL: "Opening the gate...", + "This name is stored in this browser and attached to completed runs on the leaderboard.", + MODAL_KEEP_READING_LABEL: "Return to the machine reference", + USERNAME_LABEL: "Run name", + USERNAME_PLACEHOLDER: "Display name", + USERNAME_SUBMIT_LABEL: "Enter Floor I", + USERNAME_SUBMITTING_LABEL: "Opening Floor I...", USERNAME_HELP_TEXT: "A suggested name is ready. 3-20 letters, numbers, or underscores.", USERNAME_VALIDATION_ERROR: "Use 3-20 letters, numbers, or underscores.", - READY_STATUS_PREFIX: "Signed in as", + READY_STATUS_PREFIX: "Playing as", } as const; export const AUTH_ROUTE_PATHS = { diff --git a/src/features/auth/lib/createAuthContextValue.test.ts b/src/features/auth/lib/createAuthContextValue.test.ts index 2e0e9b84..944aa462 100644 --- a/src/features/auth/lib/createAuthContextValue.test.ts +++ b/src/features/auth/lib/createAuthContextValue.test.ts @@ -80,7 +80,7 @@ describe("createAuthContextValue", () => { ); }); - it("opens username modal for requires-username and submitting states", () => { + it("keeps username entry closed until it is explicitly requested", () => { const requiresUsernameContext = createAuthContextValue({ snapshot: createAuthSnapshot({ value: AUTH_STATUS.REQUIRES_USERNAME, @@ -95,10 +95,34 @@ describe("createAuthContextValue", () => { handleUsernameEntryDismiss: vi.fn(), }); - expect(requiresUsernameContext.isUsernameModalOpen).toBe(true); + expect(requiresUsernameContext.isUsernameModalOpen).toBe(false); expect(requiresUsernameContext.readyStatusLabel).toBeNull(); expect(requiresUsernameContext.errorMessage).toBe("Missing username"); + const requestedContext = createAuthContextValue({ + snapshot: { + ...createAuthSnapshot({ + value: AUTH_STATUS.REQUIRES_USERNAME, + profile: null, + errorMessage: null, + matchedStates: [AUTH_STATUS.REQUIRES_USERNAME], + }), + context: { + profile: null, + errorMessage: null, + isUsernameEntryRequested: true, + isUsernameEntryDeferred: false, + }, + }, + suggestedUsername: "Rune_AshBearAAAA", + handleUsernameFormSubmit: vi.fn(), + handleSessionBootstrapRetry: vi.fn(), + handleUsernameEntryRequest: vi.fn(), + handleUsernameEntryDismiss: vi.fn(), + }); + + expect(requestedContext.isUsernameModalOpen).toBe(true); + const submittingContext = createAuthContextValue({ snapshot: createAuthSnapshot({ value: AUTH_STATUS.SUBMITTING_USERNAME, diff --git a/src/features/auth/lib/createAuthContextValue.ts b/src/features/auth/lib/createAuthContextValue.ts index 81485f3f..f10bc0cf 100644 --- a/src/features/auth/lib/createAuthContextValue.ts +++ b/src/features/auth/lib/createAuthContextValue.ts @@ -51,6 +51,7 @@ const createAuthContextValue = ({ snapshot.context.isUsernameEntryRequested && !snapshot.context.isUsernameEntryDeferred) || (snapshot.matches(AUTH_STATUS.REQUIRES_USERNAME) && + snapshot.context.isUsernameEntryRequested && !snapshot.context.isUsernameEntryDeferred) || isUsernameSubmitting, isUsernameSubmitting, diff --git a/src/features/auth/ui/UsernameForm.tsx b/src/features/auth/ui/UsernameForm.tsx index 72b4af62..5a509736 100644 --- a/src/features/auth/ui/UsernameForm.tsx +++ b/src/features/auth/ui/UsernameForm.tsx @@ -78,6 +78,7 @@ export function UsernameForm({ pattern={USERNAME_PATTERN.source} autoComplete="username" placeholder={AUTH_COPY.USERNAME_PLACEHOLDER} + className="min-h-11 rounded-xl" value={field.state.value} onBlur={field.handleBlur} onChange={(event) => @@ -116,7 +117,8 @@ export function UsernameForm({ {(state) => ( - {isAuthenticated ? ( - - ) : ( - - )} - - - - ); -} diff --git a/src/pages/concepts/ui/ConceptsHero.tsx b/src/pages/concepts/ui/ConceptsHero.tsx deleted file mode 100644 index b402c325..00000000 --- a/src/pages/concepts/ui/ConceptsHero.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { CONCEPTS_COPY } from "../config"; - -export function ConceptsHero() { - return ( -
-

- {CONCEPTS_COPY.HEADING} -

-

- {CONCEPTS_COPY.HERO_SUBTITLE} -

-
- ); -} diff --git a/src/pages/concepts/ui/ConceptsMappingSection.tsx b/src/pages/concepts/ui/ConceptsMappingSection.tsx deleted file mode 100644 index b8e2124f..00000000 --- a/src/pages/concepts/ui/ConceptsMappingSection.tsx +++ /dev/null @@ -1,76 +0,0 @@ -import { cn } from "@/shared/lib"; -import { Badge } from "@/shared/ui"; - -import type { ConceptsMappingSectionViewModel } from "../lib"; - -type ConceptsMappingSectionProps = { - heading: string; - sections: readonly ConceptsMappingSectionViewModel[]; -}; - -export function ConceptsMappingSection({ - heading, - sections, -}: ConceptsMappingSectionProps) { - return ( -
-
- {sections.map((section) => { - const SectionIcon = section.icon; - - return ( -
-
-
- - {section.badge} - - -
-
-
- -
-

- {section.title} -

- -

- {section.detail} -

-
-
-
-
- ); - })} -
- -

- {heading} -

-
- ); -} diff --git a/src/pages/concepts/ui/ConceptsPage.test.tsx b/src/pages/concepts/ui/ConceptsPage.test.tsx deleted file mode 100644 index e842db18..00000000 --- a/src/pages/concepts/ui/ConceptsPage.test.tsx +++ /dev/null @@ -1,70 +0,0 @@ -// @vitest-environment happy-dom - -import { cleanup, render, screen } from "@testing-library/react"; -import type { ReactNode } from "react"; -import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - -import { ConceptsPage } from "./ConceptsPage"; - -const mockUseAuthContext = vi.hoisted(() => vi.fn()); - -vi.mock("@/features/auth", async () => { - const actual = - await vi.importActual("@/features/auth"); - - return { - ...actual, - useAuthContext: mockUseAuthContext, - }; -}); - -vi.mock("@tanstack/react-router", () => ({ - Link: ({ children, to, ...props }: { children: ReactNode; to: string }) => ( - - {children} - - ), -})); - -afterEach(cleanup); - -beforeEach(() => { - mockUseAuthContext.mockReturnValue({ - handleUsernameEntryRequest: vi.fn(), - isAuthenticated: true, - }); -}); - -describe("ConceptsPage", () => { - it("renders the standalone concepts page without tabs", () => { - render(); - - expect(screen.getByText("System concepts.")).not.toBeNull(); - expect(screen.getByText("Room")).not.toBeNull(); - expect(screen.getByText("Corridor")).not.toBeNull(); - expect(screen.getByText("Input or prompt")).not.toBeNull(); - expect(screen.getByText("Locked door")).not.toBeNull(); - expect(screen.getByText("Inventory, HP, current room")).not.toBeNull(); - expect(screen.getByText("Independent loop")).not.toBeNull(); - expect(screen.getByText("Ready to inspect the dungeon?")).not.toBeNull(); - expect( - screen.getByText( - "Use the guide as a map, then inspect the concepts in motion.", - ), - ).not.toBeNull(); - expect( - screen.getByText( - "Runestone maps statechart ideas to dungeon objects so software behavior can be explored spatially.", - ), - ).not.toBeNull(); - expect(screen.queryByRole("tab", { name: "Controls" })).toBeNull(); - expect(screen.queryByRole("tab", { name: "First Run" })).toBeNull(); - expect(screen.queryByRole("tab", { name: "Concepts" })).toBeNull(); - }); - - it("includes the guide link from the concepts CTA", () => { - render(); - - expect(screen.getByRole("link", { name: "Read the Guide" })).not.toBeNull(); - }); -}); diff --git a/src/pages/concepts/ui/ConceptsPage.tsx b/src/pages/concepts/ui/ConceptsPage.tsx deleted file mode 100644 index 613cd9c9..00000000 --- a/src/pages/concepts/ui/ConceptsPage.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { useConceptsPage } from "../model"; -import { ConceptsCtaSection } from "./ConceptsCtaSection"; -import { ConceptsHero } from "./ConceptsHero"; -import { ConceptsMappingSection } from "./ConceptsMappingSection"; - -export function ConceptsPage() { - const { ctaProps, mappingSectionProps } = useConceptsPage(); - - return ( - <> - - - - - - - ); -} diff --git a/src/pages/concepts/ui/index.ts b/src/pages/concepts/ui/index.ts deleted file mode 100644 index e1ff9c26..00000000 --- a/src/pages/concepts/ui/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { ConceptsPage } from "./ConceptsPage"; diff --git a/src/pages/home/config/homeCopy.ts b/src/pages/home/config/homeCopy.ts index 6b4da5a0..3c3a98bb 100644 --- a/src/pages/home/config/homeCopy.ts +++ b/src/pages/home/config/homeCopy.ts @@ -1,56 +1,33 @@ export const HOME_COPY = { - BADGE: "Playable architecture", - CTA_LABEL: "Enter Dungeon", + BADGE: "XState runtime · Floor I", + CTA_LABEL: "Enter Floor I", + FINAL_CTA_LABEL: "Enter the dungeon", + FINAL_HEADING: "Trace the machine from inside.", + FINAL_SUBTITLE: + "Execute the five-room statechart, inspect every transition, and see guard conditions change with the run context.", + FIELD_GUIDE_HEADING: "Machine reference", + FIELD_GUIDE_SUBTITLE: + "The runtime model and input map for Floor I, kept beside the machine it describes.", FEATURES_HEADING: "What the dungeon teaches", - HEADING: "Walk through executable logic.", + HEADING: "A statechart, rendered as a dungeon.", + HERO_META: "Five rooms · one guarded route · live machine trace", MANIFEST_PATH_HEADING: "Manifest Map", MANIFEST_PATH_SUBTITLE: "Watch the current run resolve into rooms, corridors, guards, and context.", MOBILE_ORIENTATION_NOTICE: "Landscape mode is recommended for gameplay and full logic visualization.", + PROOF_HEADING: "Dungeon and machine, synchronized.", + PROOF_SUBTITLE: + "The 3D floor and its XState runtime execute together. Movement changes state; combat and inventory change context; the inspector records both.", + RETRY_LABEL: "Retry entry", + RUN_HEADING: "Execution path", + RUN_SUBTITLE: + "Traverse the machine from Entrance to Exit. The Treasury transition remains blocked until the guardian is defeated and the Treasure Key exists in context.", RUNTIME_HEADING: "Read the system while you play.", RUNTIME_SUBTITLE: "Gameplay, state, and context are shown together so the dungeon can be read as a running statechart.", SUBTITLE: - "Runestone turns statecharts into a 3D dungeon: rooms are states, corridors are transitions, and every action is driven by explicit events.", - TUTORIAL_LABEL: "Read the Guide", -} as const; - -export const HOME_STATUS_COPY = { - CHECKING_SESSION: { - badge: "Getting ready", - description: "We’re checking your session and loading your profile.", - detail: "You can keep reading while the gate is being prepared.", - iconLabel: "Loading", - title: "Preparing your run", - }, - BOOTSTRAP_FAILED: { - badge: "Session unavailable", - description: "Try again in a moment.", - detail: "The dungeon is still here once the backend is reachable.", - actionLabel: "Try again", - iconLabel: "Unavailable", - title: "We couldn’t load your profile", - }, - REQUIRES_USERNAME: { - badge: "Choose a name", - description: "This name will be used to save your progress.", - detail: "The dungeon stays sealed until your name is set.", - iconLabel: "Choose a name", - title: "Pick a rune name to begin", - }, - SUBMITTING_USERNAME: { - badge: "Saving name", - description: "We’re writing your profile now.", - detail: "Keep going, the gate will open as soon as it’s ready.", - iconLabel: "Summoning", - title: "Saving your name...", - }, - AUTHENTICATED: { - badge: "Ready", - description: "Your profile is ready and you can enter now.", - detail: "Use the blue primary button to enter the dungeon.", - iconLabel: "Ready", - title: "The gate is open", - }, + "Runestone maps states to rooms, transitions to corridors, and guards to locked doors. Execute Floor I while the live inspector exposes the machine beside you.", + TRACE_LABEL: "Inspect the runtime", + TUTORIAL_LABEL: "Open the field guide", } as const; diff --git a/src/pages/home/config/homeExperienceConfig.ts b/src/pages/home/config/homeExperienceConfig.ts new file mode 100644 index 00000000..3fd93fe6 --- /dev/null +++ b/src/pages/home/config/homeExperienceConfig.ts @@ -0,0 +1,191 @@ +export const HOME_SECTION_IDS = { + HOW_IT_WORKS: "how-it-works", + MACHINE: "machine", + CONTROLS: "controls", +} as const; + +export const HOME_FIELD_GUIDE_VALUES = { + MACHINE: "machine", + CONTROLS: "controls", +} as const; + +export type HomeFieldGuideValue = + (typeof HOME_FIELD_GUIDE_VALUES)[keyof typeof HOME_FIELD_GUIDE_VALUES]; + +export const HOME_RUNTIME_ROOMS = [ + { + id: "entrance", + machineState: "entrance", + room: "Entrance", + status: "active", + }, + { + id: "library", + machineState: "library", + room: "Library", + status: "available", + }, + { + id: "guard-room", + machineState: "guardRoom", + room: "Guard Room", + status: "available", + }, + { + id: "treasury", + machineState: "treasury", + room: "Treasury", + status: "guarded", + }, + { + id: "exit", + machineState: "exit", + room: "Exit", + status: "pending", + }, +] as const; + +export const HOME_SYSTEM_VIEWS = [ + { + label: "Viewport", + description: "Move through the machine as a physical dungeon.", + }, + { + label: "Live statechart", + description: "See the active state and available transitions change.", + }, + { + label: "Run context", + description: "Inspect HP, inventory, guards, and the current room.", + }, +] as const; + +export const HOME_RUN_STEPS = [ + { + index: "01", + title: "Enter the machine", + description: + "Walk from Entrance into the Library. Each chamber is one explicit state.", + }, + { + index: "02", + title: "Change the context", + description: + "Defeat the guardian and collect the Treasure Key in the Guard Room.", + }, + { + index: "03", + title: "Satisfy the guard", + description: + "Use both conditions to unlock the Treasury, then continue to Exit.", + }, +] as const; + +export const HOME_CONCEPT_MAPPINGS = [ + { + construct: "State", + manifestation: "Room", + description: "The one place the machine currently occupies.", + }, + { + construct: "Transition", + manifestation: "Corridor", + description: "An explicit route from one state to another.", + }, + { + construct: "Event", + manifestation: "Player action", + description: "Input that asks the machine to change state.", + }, + { + construct: "Guard", + manifestation: "Locked door", + description: "A condition that must pass before traversal.", + }, + { + construct: "Context", + manifestation: "Key, HP, room", + description: "Data that changes which paths are valid.", + }, + { + construct: "Actor", + manifestation: "Independent loop", + description: "A player, guardian, camera, or audio machine.", + }, +] as const; + +export const HOME_CONTROL_GROUPS = [ + { + label: "Move", + keys: "WASD / arrows", + }, + { + label: "Run", + keys: "Shift", + }, + { + label: "Jump", + keys: "Space", + }, + { + label: "Interact", + keys: "E", + }, + { + label: "Attack", + keys: "F", + }, +] as const; + +export const HOME_TOUCH_CONTROL_GROUPS = [ + { + label: "Move", + control: "Left joystick", + }, + { + label: "Look", + control: "Drag the viewport", + }, + { + label: "Run", + control: "Run toggle", + }, + { + label: "Jump", + control: "Jump button", + }, + { + label: "Interact / attack", + control: "Context buttons", + }, + { + label: "Statechart / HUD", + control: "Panels button", + }, +] as const; + +export const HOME_CAMERA_MODES = [ + "1 Third person", + "2 Top down", + "3 First person", + "4 Free orbit", +] as const; + +export const HOME_TOUCH_CAMERA_MODES = [ + { + abbreviation: "3P", + label: "Third person", + }, + { + abbreviation: "TD", + label: "Top down", + }, + { + abbreviation: "1P", + label: "First person", + }, + { + abbreviation: "FO", + label: "Free orbit", + }, +] as const; diff --git a/src/pages/home/config/homeManifestConfig.ts b/src/pages/home/config/homeManifestConfig.ts deleted file mode 100644 index 9b0f3276..00000000 --- a/src/pages/home/config/homeManifestConfig.ts +++ /dev/null @@ -1,49 +0,0 @@ -export const HOME_MANIFEST_TONES = { - ACTIVE: "active", - AVAILABLE: "available", - SEALED: "sealed", -} as const; - -export type HomeManifestTone = - (typeof HOME_MANIFEST_TONES)[keyof typeof HOME_MANIFEST_TONES]; - -export const HOME_MANIFEST_TONE_CLASS_NAMES = { - [HOME_MANIFEST_TONES.ACTIVE]: "text-dungeon-gold", - [HOME_MANIFEST_TONES.AVAILABLE]: "text-dungeon-gold", - [HOME_MANIFEST_TONES.SEALED]: "text-dungeon-rune-sealed", -} as const; - -export const HOME_MANIFEST_FOCUS_ITEM = { - badge: "Guard Condition", - description: - "Evaluates context before allowing passage. If the key is missing, the path stays blocked.", - title: "Locked Door", - tone: HOME_MANIFEST_TONES.SEALED, -} as const; - -export const HOME_MANIFEST_NODES = [ - { - description: "Initialize run", - id: "entrance", - title: "Entrance", - tone: HOME_MANIFEST_TONES.ACTIVE, - }, - { - description: "Transition", - id: "corridor", - title: "Corridor", - tone: HOME_MANIFEST_TONES.AVAILABLE, - }, - { - description: "Guard condition", - id: "locked-door", - title: "Locked Door", - tone: HOME_MANIFEST_TONES.SEALED, - }, - { - description: "Use context", - id: "inventory", - title: "Inventory", - tone: HOME_MANIFEST_TONES.AVAILABLE, - }, -] as const; diff --git a/src/pages/home/config/homeRuntimeConfig.ts b/src/pages/home/config/homeRuntimeConfig.ts deleted file mode 100644 index 744d02ac..00000000 --- a/src/pages/home/config/homeRuntimeConfig.ts +++ /dev/null @@ -1,17 +0,0 @@ -export const HOME_RUNTIME_PANELS = [ - { - description: "The playable dungeon frame anchors the learning experience.", - id: "viewport", - title: "Viewport", - }, - { - description: "The active room maps to the current state.", - id: "statechart", - title: "Statechart", - }, - { - description: "Context explains why paths open or remain locked.", - id: "inspector", - title: "Inspector", - }, -] as const; diff --git a/src/pages/home/config/homeTeachingConfig.ts b/src/pages/home/config/homeTeachingConfig.ts deleted file mode 100644 index 94fb3638..00000000 --- a/src/pages/home/config/homeTeachingConfig.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { HOME_TEACHING_ICON_KEYS } from "./homeTeachingIconConfig"; - -export const HOME_TEACHING_TONES = { - ACCENT: "accent", - PRIMARY: "primary", - SEALED: "sealed", -} as const; - -export type HomeTeachingTone = - (typeof HOME_TEACHING_TONES)[keyof typeof HOME_TEACHING_TONES]; - -export const HOME_TEACHING_TONE_CLASS_NAMES = { - [HOME_TEACHING_TONES.ACCENT]: "text-dungeon-gold", - [HOME_TEACHING_TONES.PRIMARY]: "text-dungeon-gold", - [HOME_TEACHING_TONES.SEALED]: "text-dungeon-rune-sealed", -} as const; - -export const HOME_TEACHING_FEATURES = [ - { - description: - "Each state becomes a distinct room with one clear point of occupancy.", - iconKey: HOME_TEACHING_ICON_KEYS.DOOR_OPEN, - id: "states-become-rooms", - isFeatured: true, - title: "States become rooms", - tone: HOME_TEACHING_TONES.PRIMARY, - }, - { - description: - "Events are actions that open the next corridor when they resolve.", - iconKey: HOME_TEACHING_ICON_KEYS.ZAP, - id: "events-move-system", - isFeatured: false, - title: "Events move the system", - tone: HOME_TEACHING_TONES.ACCENT, - }, - { - description: - "Guards stop traversal until the required state or inventory is present.", - iconKey: HOME_TEACHING_ICON_KEYS.LOCK, - id: "guards-control-progression", - isFeatured: false, - title: "Guards control progression", - tone: HOME_TEACHING_TONES.SEALED, - }, - { - description: - "Actors run their own loops and stay isolated from the main machine.", - iconKey: HOME_TEACHING_ICON_KEYS.WORKFLOW, - id: "actors-stay-isolated", - isFeatured: false, - title: "Actors stay isolated", - tone: HOME_TEACHING_TONES.PRIMARY, - }, - { - description: - "Inventory, HP, and current room data shape which paths remain valid.", - iconKey: HOME_TEACHING_ICON_KEYS.PACKAGE, - id: "context-changes-paths", - isFeatured: false, - title: "Context changes paths", - tone: HOME_TEACHING_TONES.PRIMARY, - }, -] as const; diff --git a/src/pages/home/config/homeTeachingIconConfig.ts b/src/pages/home/config/homeTeachingIconConfig.ts deleted file mode 100644 index 4aa4301b..00000000 --- a/src/pages/home/config/homeTeachingIconConfig.ts +++ /dev/null @@ -1,10 +0,0 @@ -export const HOME_TEACHING_ICON_KEYS = { - DOOR_OPEN: "door-open", - LOCK: "lock", - PACKAGE: "package", - WORKFLOW: "workflow", - ZAP: "zap", -} as const; - -export type HomeTeachingIconKey = - (typeof HOME_TEACHING_ICON_KEYS)[keyof typeof HOME_TEACHING_ICON_KEYS]; diff --git a/src/pages/home/config/homeTranslationConfig.ts b/src/pages/home/config/homeTranslationConfig.ts deleted file mode 100644 index e709dd28..00000000 --- a/src/pages/home/config/homeTranslationConfig.ts +++ /dev/null @@ -1,44 +0,0 @@ -export const HOME_TRANSLATION_TONES = { - ACCENT: "accent", - PRIMARY: "primary", - SEALED: "sealed", -} as const; - -export type HomeTranslationTone = - (typeof HOME_TRANSLATION_TONES)[keyof typeof HOME_TRANSLATION_TONES]; - -export const HOME_TRANSLATION_TONE_CLASS_NAMES = { - [HOME_TRANSLATION_TONES.ACCENT]: "text-dungeon-gold", - [HOME_TRANSLATION_TONES.PRIMARY]: "text-panel-title", - [HOME_TRANSLATION_TONES.SEALED]: "text-dungeon-rune-sealed", -} as const; - -export const HOME_TRANSLATION_ARROW_CLASS_NAME = "text-dungeon-gold" as const; - -export const HOME_TRANSLATION_RAIL = [ - { - label: "State", - target: "Room", - tone: HOME_TRANSLATION_TONES.PRIMARY, - }, - { - label: "Transition", - target: "Corridor", - tone: HOME_TRANSLATION_TONES.PRIMARY, - }, - { - label: "Guard", - target: "Locked Door", - tone: HOME_TRANSLATION_TONES.ACCENT, - }, - { - label: "Context", - target: "Inventory", - tone: HOME_TRANSLATION_TONES.PRIMARY, - }, - { - label: "Actor", - target: "Loop", - tone: HOME_TRANSLATION_TONES.PRIMARY, - }, -] as const; diff --git a/src/pages/home/config/index.ts b/src/pages/home/config/index.ts index 41a9eea3..0ade3dda 100644 --- a/src/pages/home/config/index.ts +++ b/src/pages/home/config/index.ts @@ -1,29 +1,14 @@ -export { - HOME_COPY, - HOME_STATUS_COPY, -} from "./homeCopy"; -export { - HOME_MANIFEST_FOCUS_ITEM, - HOME_MANIFEST_NODES, - HOME_MANIFEST_TONE_CLASS_NAMES, - HOME_MANIFEST_TONES, - type HomeManifestTone, -} from "./homeManifestConfig"; -export { HOME_RUNTIME_PANELS } from "./homeRuntimeConfig"; -export { - HOME_TEACHING_FEATURES, - HOME_TEACHING_TONE_CLASS_NAMES, - HOME_TEACHING_TONES, - type HomeTeachingTone, -} from "./homeTeachingConfig"; -export { - HOME_TEACHING_ICON_KEYS, - type HomeTeachingIconKey, -} from "./homeTeachingIconConfig"; -export { - HOME_TRANSLATION_ARROW_CLASS_NAME, - HOME_TRANSLATION_RAIL, - HOME_TRANSLATION_TONE_CLASS_NAMES, - HOME_TRANSLATION_TONES, - type HomeTranslationTone, -} from "./homeTranslationConfig"; +export { HOME_COPY } from "./homeCopy"; +export { + HOME_CAMERA_MODES, + HOME_CONCEPT_MAPPINGS, + HOME_CONTROL_GROUPS, + HOME_FIELD_GUIDE_VALUES, + HOME_RUN_STEPS, + HOME_RUNTIME_ROOMS, + HOME_SECTION_IDS, + HOME_SYSTEM_VIEWS, + HOME_TOUCH_CAMERA_MODES, + HOME_TOUCH_CONTROL_GROUPS, + type HomeFieldGuideValue, +} from "./homeExperienceConfig"; diff --git a/src/pages/home/lib/createHomePageViewModel.test.ts b/src/pages/home/lib/createHomePageViewModel.test.ts index f42ed3dc..13006f1b 100644 --- a/src/pages/home/lib/createHomePageViewModel.test.ts +++ b/src/pages/home/lib/createHomePageViewModel.test.ts @@ -1,4 +1,3 @@ -import { DoorOpen } from "lucide-react"; import { describe, expect, it, vi } from "vitest"; import { AUTH_STATUS } from "@/features/auth"; @@ -19,18 +18,13 @@ describe("createHomePageViewModel", () => { readyStatusLabel: "Rune_AshBearAAAA", }); - expect(viewModel.heroProps.authStatus).toBe(AUTH_STATUS.AUTHENTICATED); - expect(viewModel.heroProps.errorMessage).toBeNull(); - expect(viewModel.heroProps.isAuthenticated).toBe(true); - expect(viewModel.heroProps.onEntryRequest).toBe(handleUsernameEntryRequest); - expect(viewModel.heroProps.onRetry).toBe(handleSessionBootstrapRetry); - expect(viewModel.heroProps.readyStatusLabel).toBe("Rune_AshBearAAAA"); - expect(viewModel.manifestSectionProps.nodes[0]?.indexLabel).toBe("1"); - expect(viewModel.manifestSectionProps.nodes.at(-1)?.isLast).toBe(true); - expect(viewModel.teachingSectionProps.features[0]).toMatchObject({ - isFeatured: true, - }); - expect(viewModel.teachingSectionProps.features[0]?.Icon).toBe(DoorOpen); - expect(viewModel.translationRailItems.at(-1)?.isLast).toBe(true); + expect(viewModel.entryProps.authStatus).toBe(AUTH_STATUS.AUTHENTICATED); + expect(viewModel.entryProps.errorMessage).toBeNull(); + expect(viewModel.entryProps.isAuthenticated).toBe(true); + expect(viewModel.entryProps.onEntryRequest).toBe( + handleUsernameEntryRequest, + ); + expect(viewModel.entryProps.onRetry).toBe(handleSessionBootstrapRetry); + expect(viewModel.entryProps.readyStatusLabel).toBe("Rune_AshBearAAAA"); }); }); diff --git a/src/pages/home/lib/createHomePageViewModel.ts b/src/pages/home/lib/createHomePageViewModel.ts index 5c03a6d5..11346ad7 100644 --- a/src/pages/home/lib/createHomePageViewModel.ts +++ b/src/pages/home/lib/createHomePageViewModel.ts @@ -1,20 +1,5 @@ -import type { LucideIcon } from "lucide-react"; import type { AuthContextValue } from "@/features/auth"; -import { - HOME_COPY, - HOME_MANIFEST_FOCUS_ITEM, - HOME_MANIFEST_NODES, - HOME_TEACHING_FEATURES, - HOME_TEACHING_TONE_CLASS_NAMES, - HOME_TEACHING_TONES, - HOME_TRANSLATION_RAIL, - HOME_TRANSLATION_TONE_CLASS_NAMES, -} from "../config"; - -import { resolveHomeManifestToneClassName } from "./resolveHomeManifestToneClassName"; -import { resolveHomeTeachingIcon } from "./resolveHomeTeachingIcon"; - type CreateHomePageViewModelInput = Pick< AuthContextValue, | "authStatus" @@ -25,35 +10,8 @@ type CreateHomePageViewModelInput = Pick< | "readyStatusLabel" >; -export type HomeManifestNodeViewModel = { - description: string; - id: string; - indexLabel: string; - isLast: boolean; - title: string; - toneClassName: string; -}; - -export type HomeTeachingFeatureViewModel = { - description: string; - id: string; - Icon: LucideIcon; - iconClassName: string; - isFeatured: boolean; - isSealed: boolean; - className: string; - title: string; -}; - -export type HomeTranslationItemViewModel = { - label: string; - target: string; - isLast: boolean; - toneClassName: string; -}; - type HomePageViewModel = { - heroProps: { + entryProps: { authStatus: AuthContextValue["authStatus"]; errorMessage: string | null; isAuthenticated: boolean; @@ -61,22 +19,6 @@ type HomePageViewModel = { onRetry: () => void; readyStatusLabel: string | null; }; - manifestSectionProps: { - heading: string; - focusItem: { - badge: string; - description: string; - title: string; - toneClassName: string; - }; - nodes: readonly HomeManifestNodeViewModel[]; - subtitle: string; - }; - teachingSectionProps: { - features: readonly HomeTeachingFeatureViewModel[]; - heading: string; - }; - translationRailItems: readonly HomeTranslationItemViewModel[]; }; export const createHomePageViewModel = ({ @@ -87,45 +29,8 @@ export const createHomePageViewModel = ({ isAuthenticated, readyStatusLabel, }: CreateHomePageViewModelInput): HomePageViewModel => { - const manifestSectionProps: HomePageViewModel["manifestSectionProps"] = { - focusItem: { - ...HOME_MANIFEST_FOCUS_ITEM, - toneClassName: resolveHomeManifestToneClassName( - HOME_MANIFEST_FOCUS_ITEM.tone, - ), - }, - heading: HOME_COPY.MANIFEST_PATH_HEADING, - nodes: HOME_MANIFEST_NODES.map((node, index) => ({ - description: node.description, - id: node.id, - indexLabel: String(index + 1), - isLast: index === HOME_MANIFEST_NODES.length - 1, - title: node.title, - toneClassName: resolveHomeManifestToneClassName(node.tone), - })), - subtitle: HOME_COPY.MANIFEST_PATH_SUBTITLE, - }; - - const teachingSectionProps: HomePageViewModel["teachingSectionProps"] = { - features: HOME_TEACHING_FEATURES.map((feature) => { - const Icon = resolveHomeTeachingIcon(feature.iconKey); - return { - className: - feature.isFeatured === true ? "h-full lg:col-span-2" : "h-full", - description: feature.description, - id: feature.id, - Icon, - iconClassName: HOME_TEACHING_TONE_CLASS_NAMES[feature.tone], - isFeatured: feature.isFeatured === true, - isSealed: feature.tone === HOME_TEACHING_TONES.SEALED, - title: feature.title, - }; - }), - heading: HOME_COPY.FEATURES_HEADING, - }; - return { - heroProps: { + entryProps: { authStatus, errorMessage, isAuthenticated, @@ -133,14 +38,6 @@ export const createHomePageViewModel = ({ onRetry: handleSessionBootstrapRetry, readyStatusLabel, }, - manifestSectionProps, - teachingSectionProps, - translationRailItems: HOME_TRANSLATION_RAIL.map((item, index) => ({ - label: item.label, - isLast: index === HOME_TRANSLATION_RAIL.length - 1, - target: item.target, - toneClassName: HOME_TRANSLATION_TONE_CLASS_NAMES[item.tone], - })), }; }; diff --git a/src/pages/home/lib/index.ts b/src/pages/home/lib/index.ts index be92c5c7..1c66bbff 100644 --- a/src/pages/home/lib/index.ts +++ b/src/pages/home/lib/index.ts @@ -1,10 +1,5 @@ export { type CreateHomePageViewModelInput, createHomePageViewModel, - type HomeManifestNodeViewModel, type HomePageViewModel, - type HomeTeachingFeatureViewModel, - type HomeTranslationItemViewModel, } from "./createHomePageViewModel"; -export { resolveHomeManifestToneClassName } from "./resolveHomeManifestToneClassName"; -export { resolveHomeTeachingIcon } from "./resolveHomeTeachingIcon"; diff --git a/src/pages/home/lib/resolveHomeManifestToneClassName.test.ts b/src/pages/home/lib/resolveHomeManifestToneClassName.test.ts deleted file mode 100644 index 248eba99..00000000 --- a/src/pages/home/lib/resolveHomeManifestToneClassName.test.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { describe, expect, it } from "vitest"; - -import { HOME_MANIFEST_TONES } from "../config"; -import { resolveHomeManifestToneClassName } from "./resolveHomeManifestToneClassName"; - -describe("resolveHomeManifestToneClassName", () => { - it("returns active classes", () => { - expect( - resolveHomeManifestToneClassName(HOME_MANIFEST_TONES.ACTIVE), - ).toContain("text-dungeon-gold"); - }); - - it("returns available classes", () => { - expect( - resolveHomeManifestToneClassName(HOME_MANIFEST_TONES.AVAILABLE), - ).toContain("text-dungeon-gold"); - }); - - it("returns sealed classes", () => { - expect( - resolveHomeManifestToneClassName(HOME_MANIFEST_TONES.SEALED), - ).toContain("text-dungeon-rune-sealed"); - }); -}); diff --git a/src/pages/home/lib/resolveHomeManifestToneClassName.ts b/src/pages/home/lib/resolveHomeManifestToneClassName.ts deleted file mode 100644 index d8218a77..00000000 --- a/src/pages/home/lib/resolveHomeManifestToneClassName.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { - HOME_MANIFEST_TONE_CLASS_NAMES, - HOME_MANIFEST_TONES, - type HomeManifestTone, -} from "../config"; - -export const resolveHomeManifestToneClassName = ( - tone: HomeManifestTone, -): string => { - switch (tone) { - case HOME_MANIFEST_TONES.ACTIVE: - case HOME_MANIFEST_TONES.AVAILABLE: - case HOME_MANIFEST_TONES.SEALED: - return HOME_MANIFEST_TONE_CLASS_NAMES[tone]; - } -}; diff --git a/src/pages/home/lib/resolveHomeTeachingIcon.test.ts b/src/pages/home/lib/resolveHomeTeachingIcon.test.ts deleted file mode 100644 index cf502092..00000000 --- a/src/pages/home/lib/resolveHomeTeachingIcon.test.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { DoorOpen, Lock, Package, Workflow } from "lucide-react"; -import { describe, expect, it } from "vitest"; -import { HOME_TEACHING_ICON_KEYS } from "../config"; -import { resolveHomeTeachingIcon } from "./resolveHomeTeachingIcon"; - -describe("resolveHomeTeachingIcon", () => { - it("resolves configured teaching icons", () => { - expect(resolveHomeTeachingIcon(HOME_TEACHING_ICON_KEYS.DOOR_OPEN)).toBe( - DoorOpen, - ); - expect(resolveHomeTeachingIcon(HOME_TEACHING_ICON_KEYS.LOCK)).toBe(Lock); - expect(resolveHomeTeachingIcon(HOME_TEACHING_ICON_KEYS.PACKAGE)).toBe( - Package, - ); - expect(resolveHomeTeachingIcon(HOME_TEACHING_ICON_KEYS.WORKFLOW)).toBe( - Workflow, - ); - }); -}); diff --git a/src/pages/home/lib/resolveHomeTeachingIcon.ts b/src/pages/home/lib/resolveHomeTeachingIcon.ts deleted file mode 100644 index b4c1a6ae..00000000 --- a/src/pages/home/lib/resolveHomeTeachingIcon.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { - DoorOpen, - Lock, - type LucideIcon, - Package, - Workflow, - Zap, -} from "lucide-react"; - -import { HOME_TEACHING_ICON_KEYS, type HomeTeachingIconKey } from "../config"; - -export const resolveHomeTeachingIcon = ( - iconKey: HomeTeachingIconKey, -): LucideIcon => { - switch (iconKey) { - case HOME_TEACHING_ICON_KEYS.DOOR_OPEN: - return DoorOpen; - case HOME_TEACHING_ICON_KEYS.LOCK: - return Lock; - case HOME_TEACHING_ICON_KEYS.PACKAGE: - return Package; - case HOME_TEACHING_ICON_KEYS.WORKFLOW: - return Workflow; - case HOME_TEACHING_ICON_KEYS.ZAP: - return Zap; - } -}; diff --git a/src/pages/home/model/index.ts b/src/pages/home/model/index.ts index 4c00a62c..a6d818a1 100644 --- a/src/pages/home/model/index.ts +++ b/src/pages/home/model/index.ts @@ -1 +1,2 @@ +export { useHomeFieldGuide } from "./useHomeFieldGuide"; export { useHomePage } from "./useHomePage"; diff --git a/src/pages/home/model/useHomeFieldGuide.test.tsx b/src/pages/home/model/useHomeFieldGuide.test.tsx new file mode 100644 index 00000000..9d6cbcec --- /dev/null +++ b/src/pages/home/model/useHomeFieldGuide.test.tsx @@ -0,0 +1,32 @@ +// @vitest-environment happy-dom + +import { act, renderHook } from "@testing-library/react"; +import { beforeEach, describe, expect, it } from "vitest"; + +import { HOME_FIELD_GUIDE_VALUES } from "../config"; +import { useHomeFieldGuide } from "./useHomeFieldGuide"; + +describe("useHomeFieldGuide", () => { + beforeEach(() => { + window.history.replaceState(null, "", "/"); + }); + + it("opens the controls panel from its legacy deep link", () => { + window.history.replaceState(null, "", "/#controls"); + + const { result } = renderHook(() => useHomeFieldGuide()); + + expect(result.current.activeValue).toBe(HOME_FIELD_GUIDE_VALUES.CONTROLS); + }); + + it("updates the URL hash when the selected guide changes", () => { + const { result } = renderHook(() => useHomeFieldGuide()); + + act(() => { + result.current.handleValueChange(HOME_FIELD_GUIDE_VALUES.CONTROLS); + }); + + expect(result.current.activeValue).toBe(HOME_FIELD_GUIDE_VALUES.CONTROLS); + expect(window.location.hash).toBe("#controls"); + }); +}); diff --git a/src/pages/home/model/useHomeFieldGuide.ts b/src/pages/home/model/useHomeFieldGuide.ts new file mode 100644 index 00000000..2c993192 --- /dev/null +++ b/src/pages/home/model/useHomeFieldGuide.ts @@ -0,0 +1,44 @@ +import { useEffect, useState } from "react"; + +import { HOME_FIELD_GUIDE_VALUES, type HomeFieldGuideValue } from "../config"; + +type HomeFieldGuideViewModel = { + activeValue: HomeFieldGuideValue; + handleValueChange: (value: string) => void; +}; + +export const useHomeFieldGuide = (): HomeFieldGuideViewModel => { + const [activeValue, setActiveValue] = useState( + HOME_FIELD_GUIDE_VALUES.MACHINE, + ); + + useEffect(() => { + const syncValueFromHash = () => { + setActiveValue( + window.location.hash === `#${HOME_FIELD_GUIDE_VALUES.CONTROLS}` + ? HOME_FIELD_GUIDE_VALUES.CONTROLS + : HOME_FIELD_GUIDE_VALUES.MACHINE, + ); + }; + + syncValueFromHash(); + window.addEventListener("hashchange", syncValueFromHash); + + return () => window.removeEventListener("hashchange", syncValueFromHash); + }, []); + + return { + activeValue, + handleValueChange: (value) => { + if ( + value !== HOME_FIELD_GUIDE_VALUES.MACHINE && + value !== HOME_FIELD_GUIDE_VALUES.CONTROLS + ) { + return; + } + + setActiveValue(value); + window.history.replaceState(null, "", `#${value}`); + }, + }; +}; diff --git a/src/pages/home/ui/HomeBootstrapAuthenticatedStatusCard.tsx b/src/pages/home/ui/HomeBootstrapAuthenticatedStatusCard.tsx deleted file mode 100644 index 948ce207..00000000 --- a/src/pages/home/ui/HomeBootstrapAuthenticatedStatusCard.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import { CheckCircle2, ShieldCheck } from "lucide-react"; - -import { HOME_STATUS_COPY } from "../config"; - -import { HomeBootstrapStatusShell } from "./HomeBootstrapStatusShell"; - -type HomeBootstrapAuthenticatedStatusCardProps = { - readyStatusLabel: string | null; -}; - -export function HomeBootstrapAuthenticatedStatusCard({ - readyStatusLabel, -}: HomeBootstrapAuthenticatedStatusCardProps) { - return ( - } - title={HOME_STATUS_COPY.AUTHENTICATED.title} - > -
- {readyStatusLabel ? ( - - - {readyStatusLabel} - - ) : null} - {HOME_STATUS_COPY.AUTHENTICATED.detail} -
-
- ); -} diff --git a/src/pages/home/ui/HomeBootstrapCheckingStatusCard.tsx b/src/pages/home/ui/HomeBootstrapCheckingStatusCard.tsx deleted file mode 100644 index 24010365..00000000 --- a/src/pages/home/ui/HomeBootstrapCheckingStatusCard.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { LoaderCircle } from "lucide-react"; - -import { Skeleton } from "@/shared/ui"; - -import { HOME_STATUS_COPY } from "../config"; - -import { HomeBootstrapStatusShell } from "./HomeBootstrapStatusShell"; - -export function HomeBootstrapCheckingStatusCard() { - return ( - } - title={HOME_STATUS_COPY.CHECKING_SESSION.title} - > -
- -

- {HOME_STATUS_COPY.CHECKING_SESSION.detail} -

-
-
- ); -} diff --git a/src/pages/home/ui/HomeBootstrapFailedStatusCard.tsx b/src/pages/home/ui/HomeBootstrapFailedStatusCard.tsx deleted file mode 100644 index d71df87f..00000000 --- a/src/pages/home/ui/HomeBootstrapFailedStatusCard.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import { TriangleAlert } from "lucide-react"; - -import { - Alert, - AlertAction, - AlertDescription, - AlertTitle, - Badge, - Button, -} from "@/shared/ui"; - -import { HOME_STATUS_COPY } from "../config"; - -type HomeBootstrapFailedStatusCardProps = { - errorMessage: string | null; - onRetry: () => void; -}; - -export function HomeBootstrapFailedStatusCard({ - errorMessage, - onRetry, -}: HomeBootstrapFailedStatusCardProps) { - return ( - - -
-
- - {HOME_STATUS_COPY.BOOTSTRAP_FAILED.badge} - - - {HOME_STATUS_COPY.BOOTSTRAP_FAILED.title} - -
- - {errorMessage ?? HOME_STATUS_COPY.BOOTSTRAP_FAILED.description} - -

- {HOME_STATUS_COPY.BOOTSTRAP_FAILED.detail} -

-
- - - -
- ); -} diff --git a/src/pages/home/ui/HomeBootstrapStatusCard.test.tsx b/src/pages/home/ui/HomeBootstrapStatusCard.test.tsx deleted file mode 100644 index 1814960a..00000000 --- a/src/pages/home/ui/HomeBootstrapStatusCard.test.tsx +++ /dev/null @@ -1,85 +0,0 @@ -// @vitest-environment happy-dom - -import { cleanup, render, screen } from "@testing-library/react"; -import { afterEach, describe, expect, it, vi } from "vitest"; - -import { AUTH_STATUS } from "@/features/auth"; - -import { HOME_STATUS_COPY } from "../config"; - -import { HomeBootstrapStatusCard } from "./HomeBootstrapStatusCard"; - -afterEach(cleanup); - -describe("HomeBootstrapStatusCard", () => { - it("renders a full-width session status shell while checking", () => { - render( - , - ); - - expect( - screen.getByRole("region", { name: "Session status" }).className, - ).toContain("w-full"); - expect( - screen.getByText(HOME_STATUS_COPY.CHECKING_SESSION.badge), - ).not.toBeNull(); - }); - - it("renders the bootstrap failure badge with the shared destructive variant", () => { - render( - , - ); - - const alert = screen.getByRole("alert"); - expect(alert.className).toContain("w-full"); - - const badge = screen - .getByText(HOME_STATUS_COPY.BOOTSTRAP_FAILED.badge) - .closest('[data-slot="badge"]'); - - expect(badge).not.toBeNull(); - expect(badge?.getAttribute("data-variant")).toBe("destructive"); - expect(badge?.className).toContain("bg-destructive/10"); - expect(badge?.className).not.toContain("bg-transparent"); - expect( - screen.getByRole("button", { - name: HOME_STATUS_COPY.BOOTSTRAP_FAILED.actionLabel, - }), - ).toBeTruthy(); - }); - - it("renders a full-width session status shell when authenticated", () => { - render( - , - ); - - expect( - screen.getByRole("region", { name: "Session status" }).className, - ).toContain("w-full"); - expect( - screen.getByText(HOME_STATUS_COPY.AUTHENTICATED.badge), - ).not.toBeNull(); - - const authenticatedDetailRow = screen - .getByText(HOME_STATUS_COPY.AUTHENTICATED.detail) - .closest("div"); - - expect(authenticatedDetailRow?.className).toContain("justify-center"); - expect(authenticatedDetailRow?.className).toContain("text-center"); - }); -}); diff --git a/src/pages/home/ui/HomeBootstrapStatusCard.tsx b/src/pages/home/ui/HomeBootstrapStatusCard.tsx deleted file mode 100644 index ec982ded..00000000 --- a/src/pages/home/ui/HomeBootstrapStatusCard.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import { AUTH_STATUS, type AuthStatus } from "@/features/auth"; - -import { HomeBootstrapAuthenticatedStatusCard } from "./HomeBootstrapAuthenticatedStatusCard"; -import { HomeBootstrapCheckingStatusCard } from "./HomeBootstrapCheckingStatusCard"; -import { HomeBootstrapFailedStatusCard } from "./HomeBootstrapFailedStatusCard"; -import { HomeBootstrapUsernameStatusCard } from "./HomeBootstrapUsernameStatusCard"; - -type HomeBootstrapStatusCardProps = { - authStatus: AuthStatus; - errorMessage: string | null; - onRetry: () => void; - readyStatusLabel: string | null; -}; - -export function HomeBootstrapStatusCard({ - authStatus, - errorMessage, - onRetry, - readyStatusLabel, -}: HomeBootstrapStatusCardProps) { - if (authStatus === AUTH_STATUS.CHECKING_SESSION) { - return ; - } - - if (authStatus === AUTH_STATUS.BOOTSTRAP_FAILED) { - return ( - - ); - } - - if (authStatus === AUTH_STATUS.AUTHENTICATED) { - return ( - - ); - } - - const isSubmittingUsername = authStatus === AUTH_STATUS.SUBMITTING_USERNAME; - - return ( - - ); -} diff --git a/src/pages/home/ui/HomeBootstrapStatusShell.tsx b/src/pages/home/ui/HomeBootstrapStatusShell.tsx deleted file mode 100644 index 5bcad18a..00000000 --- a/src/pages/home/ui/HomeBootstrapStatusShell.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import type { ReactNode } from "react"; - -import { Badge } from "@/shared/ui"; - -type HomeBootstrapStatusShellProps = { - badgeLabel: string; - children: ReactNode; - description: string; - icon: ReactNode; - title: string; -}; - -export function HomeBootstrapStatusShell({ - badgeLabel, - children, - description, - icon, - title, -}: HomeBootstrapStatusShellProps) { - return ( -
-
-
- {icon} -
-
-
- - {badgeLabel} - -

{title}

-
-

{description}

- {children} -
-
-
- ); -} diff --git a/src/pages/home/ui/HomeBootstrapUsernameStatusCard.tsx b/src/pages/home/ui/HomeBootstrapUsernameStatusCard.tsx deleted file mode 100644 index c6f7e897..00000000 --- a/src/pages/home/ui/HomeBootstrapUsernameStatusCard.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import { KeyRound, LoaderCircle } from "lucide-react"; - -import { HOME_STATUS_COPY } from "../config"; - -import { HomeBootstrapStatusShell } from "./HomeBootstrapStatusShell"; - -type HomeBootstrapUsernameStatusCardProps = { - isSubmittingUsername: boolean; -}; - -export function HomeBootstrapUsernameStatusCard({ - isSubmittingUsername, -}: HomeBootstrapUsernameStatusCardProps) { - return ( - - ) : ( - - ) - } - title={ - isSubmittingUsername - ? HOME_STATUS_COPY.SUBMITTING_USERNAME.title - : HOME_STATUS_COPY.REQUIRES_USERNAME.title - } - > -

- {isSubmittingUsername - ? HOME_STATUS_COPY.SUBMITTING_USERNAME.detail - : HOME_STATUS_COPY.REQUIRES_USERNAME.detail} -

-
- ); -} diff --git a/src/pages/home/ui/HomeEntryAction.tsx b/src/pages/home/ui/HomeEntryAction.tsx new file mode 100644 index 00000000..4ac8aa7a --- /dev/null +++ b/src/pages/home/ui/HomeEntryAction.tsx @@ -0,0 +1,79 @@ +import { Link } from "@tanstack/react-router"; +import { DoorOpen } from "lucide-react"; + +import { AUTH_STATUS } from "@/features/auth"; +import { Button } from "@/shared/ui"; +import { MARKETING_ROUTES } from "@/widgets/marketing-shell"; + +import { HOME_COPY } from "../config"; +import type { HomePageViewModel } from "../lib"; + +type HomeEntryActionProps = HomePageViewModel["entryProps"] & { + label: string; +}; + +export function HomeEntryAction({ + authStatus, + errorMessage, + isAuthenticated, + label, + onEntryRequest, + onRetry, + readyStatusLabel, +}: HomeEntryActionProps) { + if (isAuthenticated) { + return ( +
+ + {readyStatusLabel ? ( +

+ Playing as {readyStatusLabel} +

+ ) : null} +
+ ); + } + + if (authStatus === AUTH_STATUS.BOOTSTRAP_FAILED) { + return ( +
+ +

+ {errorMessage ?? "Entry is temporarily unavailable."} +

+
+ ); + } + + return ( + + ); +} diff --git a/src/pages/home/ui/HomeFieldGuideSection.tsx b/src/pages/home/ui/HomeFieldGuideSection.tsx new file mode 100644 index 00000000..96853e94 --- /dev/null +++ b/src/pages/home/ui/HomeFieldGuideSection.tsx @@ -0,0 +1,180 @@ +import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/shared/ui"; + +import { + HOME_CAMERA_MODES, + HOME_CONCEPT_MAPPINGS, + HOME_CONTROL_GROUPS, + HOME_COPY, + HOME_FIELD_GUIDE_VALUES, + HOME_SECTION_IDS, + HOME_TOUCH_CAMERA_MODES, + HOME_TOUCH_CONTROL_GROUPS, +} from "../config"; +import { useHomeFieldGuide } from "../model"; + +export function HomeFieldGuideSection() { + const { activeValue, handleValueChange } = useHomeFieldGuide(); + + return ( +
+
+

+ {HOME_COPY.FIELD_GUIDE_HEADING} +

+

+ {HOME_COPY.FIELD_GUIDE_SUBTITLE} +

+
+ + + + + + + The machine + + + Controls + + + + +
+
+
+

+ 01 / machine +

+

Dungeon grammar

+
+ + world → logic + +
+ +
+ {HOME_CONCEPT_MAPPINGS.map((mapping) => ( +
+
+ {mapping.construct} +
+
{mapping.manifestation}
+
+ {mapping.description} +
+
+ ))} +
+
+
+ + +
+
+
+

+ 02 / controls +

+

How to move

+
+ + touch layout + keyboard layout + +
+ +
+ {HOME_TOUCH_CONTROL_GROUPS.map((control) => ( +
+
{control.label}
+
+ + {control.control} + +
+
+ ))} +
+ +
+ {HOME_CONTROL_GROUPS.map((control) => ( +
+
{control.label}
+
+ + {control.keys} + +
+
+ ))} +
+ +
+

Camera selector

+
    + {HOME_TOUCH_CAMERA_MODES.map((mode) => ( +
  • + + {mode.abbreviation} + + {mode.label} +
  • + ))} +
+

+ Use the top-left selector to switch views. Interact and attack + buttons appear only when their actions are available. Landscape + is required for the run workspace. +

+
+ +
+

Camera modes

+
    + {HOME_CAMERA_MODES.map((mode) => ( +
  • {mode}
  • + ))} +
+

+ Use the numbered shortcuts to switch the active dungeon camera. +

+
+
+
+
+
+ ); +} diff --git a/src/pages/home/ui/HomeFinalSection.tsx b/src/pages/home/ui/HomeFinalSection.tsx new file mode 100644 index 00000000..7cbd5948 --- /dev/null +++ b/src/pages/home/ui/HomeFinalSection.tsx @@ -0,0 +1,56 @@ +import { ArrowUpRight } from "lucide-react"; + +import { Button } from "@/shared/ui"; +import { MARKETING_ROUTES } from "@/widgets/marketing-shell"; + +import { HOME_COPY } from "../config"; +import type { HomePageViewModel } from "../lib"; +import { HomeEntryAction } from "./HomeEntryAction"; + +type HomeFinalSectionProps = { + entryProps: HomePageViewModel["entryProps"]; +}; + +export function HomeFinalSection({ entryProps }: HomeFinalSectionProps) { + return ( +
+
+ ); +} diff --git a/src/pages/home/ui/HomeHeroSection.tsx b/src/pages/home/ui/HomeHeroSection.tsx index 16c17c98..bdb8b86c 100644 --- a/src/pages/home/ui/HomeHeroSection.tsx +++ b/src/pages/home/ui/HomeHeroSection.tsx @@ -1,83 +1,62 @@ -import { Link } from "@tanstack/react-router"; -import { DoorOpen } from "lucide-react"; +import { ArrowDownRight } from "lucide-react"; -import type { AuthStatus } from "@/features/auth"; import { Badge, Button } from "@/shared/ui"; -import { MARKETING_ROUTES } from "@/widgets/marketing-shell"; -import { HOME_COPY } from "../config"; +import { HOME_COPY, HOME_SECTION_IDS } from "../config"; +import type { HomePageViewModel } from "../lib"; -import { HomeBootstrapStatusCard } from "./HomeBootstrapStatusCard"; +import { HomeEntryAction } from "./HomeEntryAction"; +import { HomeRuntimeDiagram } from "./HomeRuntimeDiagram"; type HomeHeroSectionProps = { - authStatus: AuthStatus; - errorMessage: string | null; - isAuthenticated: boolean; - onEntryRequest: () => void; - onRetry: () => void; - readyStatusLabel: string | null; + entryProps: HomePageViewModel["entryProps"]; }; -export function HomeHeroSection({ - authStatus, - errorMessage, - isAuthenticated, - onEntryRequest, - onRetry, - readyStatusLabel, -}: HomeHeroSectionProps) { +export function HomeHeroSection({ entryProps }: HomeHeroSectionProps) { return ( -
- - {HOME_COPY.BADGE} - - -
-

- {HOME_COPY.HEADING} -

-

- {HOME_COPY.SUBTITLE} -

-
+
+
); } diff --git a/src/pages/home/ui/HomeManifestNode.tsx b/src/pages/home/ui/HomeManifestNode.tsx deleted file mode 100644 index a3782b36..00000000 --- a/src/pages/home/ui/HomeManifestNode.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { cn } from "@/shared/lib"; - -import type { HomeManifestNodeViewModel } from "../lib"; - -type HomeManifestNodeProps = { - node: HomeManifestNodeViewModel; -}; - -export function HomeManifestNode({ node }: HomeManifestNodeProps) { - return ( -
  • -
    -
    - {node.indexLabel} -
    - {node.isLast ? null :
    } -
    - -
    -

    {node.title}

    -

    {node.description}

    -
    -
  • - ); -} diff --git a/src/pages/home/ui/HomeManifestSection.tsx b/src/pages/home/ui/HomeManifestSection.tsx deleted file mode 100644 index 4ea21853..00000000 --- a/src/pages/home/ui/HomeManifestSection.tsx +++ /dev/null @@ -1,89 +0,0 @@ -import { Badge } from "@/shared/ui"; - -import type { HomeManifestNodeViewModel } from "../lib"; - -import { HomeManifestNode } from "./HomeManifestNode"; - -type HomeManifestSectionProps = { - focusItem: { - badge: string; - description: string; - title: string; - toneClassName: string; - }; - heading: string; - nodes: readonly HomeManifestNodeViewModel[]; - subtitle: string; -}; - -export function HomeManifestSection({ - focusItem, - heading, - nodes, - subtitle, -}: HomeManifestSectionProps) { - return ( -
    -
    -

    - {heading} -

    -

    - {subtitle} -

    -
    - -
    -
    -
    - -
    -
    - ); -} diff --git a/src/pages/home/ui/HomePage.test.tsx b/src/pages/home/ui/HomePage.test.tsx index bcf8f730..09dec85d 100644 --- a/src/pages/home/ui/HomePage.test.tsx +++ b/src/pages/home/ui/HomePage.test.tsx @@ -1,18 +1,12 @@ // @vitest-environment happy-dom -import { - cleanup, - fireEvent, - render, - screen, - within, -} from "@testing-library/react"; +import { cleanup, fireEvent, render, screen } from "@testing-library/react"; import type { ReactNode } from "react"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { AUTH_STATUS } from "@/features/auth"; -import { HOME_COPY, HOME_STATUS_COPY } from "../config"; +import { HOME_COPY } from "../config"; import { HomePage } from "./HomePage"; @@ -61,7 +55,7 @@ const createAuthContext = (isAuthenticated: boolean) => ({ }); describe("HomePage", () => { - it("renders the redesigned landing copy and concept sections", () => { + it("renders the runtime narrative, objective, concepts, and controls", () => { mockUseAuthContext.mockReturnValue(createAuthContext(false)); render(); @@ -70,29 +64,27 @@ describe("HomePage", () => { screen.getByRole("heading", { name: HOME_COPY.HEADING }), ).not.toBeNull(); expect(screen.getByText(HOME_COPY.SUBTITLE)).not.toBeNull(); - expect(screen.getByText("Node Inspector")).not.toBeNull(); - expect(screen.getByText(HOME_COPY.FEATURES_HEADING)).not.toBeNull(); - expect(screen.getByText("State")).not.toBeNull(); + expect( + screen.getByRole("heading", { name: HOME_COPY.PROOF_HEADING }), + ).not.toBeNull(); + expect( + screen.getByRole("heading", { name: HOME_COPY.RUN_HEADING }), + ).not.toBeNull(); + expect( + screen.getByRole("heading", { name: HOME_COPY.FIELD_GUIDE_HEADING }), + ).not.toBeNull(); expect(screen.getByText("Room")).not.toBeNull(); - expect(screen.getByText("States become rooms")).not.toBeNull(); - expect(screen.getByText("Actors stay isolated")).not.toBeNull(); - expect(screen.getByText("What the dungeon teaches")).not.toBeNull(); - const teachingSection = screen - .getByRole("heading", { name: HOME_COPY.FEATURES_HEADING }) - .closest("section"); - expect(teachingSection).not.toBeNull(); - const firstTeachingCard = within( - teachingSection as HTMLElement, - ).getAllByRole("listitem")[0]; - expect(firstTeachingCard?.className).toContain("lg:col-span-2"); - expect(screen.queryByText(HOME_COPY.RUNTIME_HEADING)).toBeNull(); - - const mobileOrientationNotice = screen - .getByText(HOME_COPY.MOBILE_ORIENTATION_NOTICE) - .closest("div"); - - expect(mobileOrientationNotice?.className).toContain("text-center"); - expect(mobileOrientationNotice?.className).toContain("sm:hidden"); + expect(screen.getByText("State")).not.toBeNull(); + expect(screen.getByText("Interact")).not.toBeNull(); + expect(screen.getByText("Attack")).not.toBeNull(); + expect(screen.getByText("E")).not.toBeNull(); + expect(screen.getByText("F")).not.toBeNull(); + expect(screen.getByText("Left joystick")).not.toBeNull(); + expect(screen.getByText("Drag the viewport")).not.toBeNull(); + expect(screen.getByText("Context buttons")).not.toBeNull(); + expect(screen.getByText("Panels button")).not.toBeNull(); + expect(screen.getByText(HOME_COPY.HERO_META)).not.toBeNull(); + expect(screen.queryByText(/no (account|password|sign-in)/i)).toBeNull(); }); it("requests username entry before authentication", () => { @@ -103,16 +95,14 @@ describe("HomePage", () => { render(); fireEvent.click( - screen.getByRole("button", { + screen.getAllByRole("button", { name: HOME_COPY.CTA_LABEL, - }), + })[0] as HTMLButtonElement, ); expect(authContext.handleUsernameEntryRequest).toHaveBeenCalledOnce(); expect( - screen.getByRole("link", { - name: HOME_COPY.TUTORIAL_LABEL, - }), + screen.getByRole("link", { name: HOME_COPY.TRACE_LABEL }), ).not.toBeNull(); }); @@ -128,7 +118,7 @@ describe("HomePage", () => { ).toBeGreaterThan(0); }); - it("shows a retry action when bootstrap fails", () => { + it("shows a retry action when entry bootstrap fails", () => { const handleSessionBootstrapRetry = vi.fn(); mockUseAuthContext.mockReturnValue({ @@ -141,9 +131,9 @@ describe("HomePage", () => { render(); screen - .getByRole("button", { - name: HOME_STATUS_COPY.BOOTSTRAP_FAILED.actionLabel, - }) + .getAllByRole("button", { + name: HOME_COPY.RETRY_LABEL, + })[0] .click(); expect(handleSessionBootstrapRetry).toHaveBeenCalledOnce(); diff --git a/src/pages/home/ui/HomePage.tsx b/src/pages/home/ui/HomePage.tsx index 0e21aae6..47f176f2 100644 --- a/src/pages/home/ui/HomePage.tsx +++ b/src/pages/home/ui/HomePage.tsx @@ -1,26 +1,20 @@ import { useHomePage } from "../model"; +import { HomeFieldGuideSection } from "./HomeFieldGuideSection"; +import { HomeFinalSection } from "./HomeFinalSection"; import { HomeHeroSection } from "./HomeHeroSection"; -import { HomeManifestSection } from "./HomeManifestSection"; -import { HomeTeachingSection } from "./HomeTeachingSection"; -import { HomeTranslationRail } from "./HomeTranslationRail"; +import { HomeProofSection } from "./HomeProofSection"; +import { HomeRunSection } from "./HomeRunSection"; export function HomePage() { - const { - heroProps, - manifestSectionProps, - teachingSectionProps, - translationRailItems, - } = useHomePage(); + const { entryProps } = useHomePage(); return ( <> - - - - - - - + + + + + ); } diff --git a/src/pages/home/ui/HomeProofSection.tsx b/src/pages/home/ui/HomeProofSection.tsx new file mode 100644 index 00000000..ab4c3157 --- /dev/null +++ b/src/pages/home/ui/HomeProofSection.tsx @@ -0,0 +1,70 @@ +import { Activity, Box, Braces } from "lucide-react"; + +import { HOME_COPY, HOME_SECTION_IDS, HOME_SYSTEM_VIEWS } from "../config"; + +const HOME_SYSTEM_VIEW_ICONS = [Box, Activity, Braces] as const; + +export function HomeProofSection() { + return ( +
    +
    +
    + Runestone showing the 3D dungeon beside a live statechart and run context +
    + One run, three synchronized views + live +
    +
    + +
    +
    +

    + {HOME_COPY.PROOF_HEADING} +

    +

    + {HOME_COPY.PROOF_SUBTITLE} +

    +
    + +
      + {HOME_SYSTEM_VIEWS.map((view, index) => { + const Icon = HOME_SYSTEM_VIEW_ICONS[index] ?? Activity; + return ( +
    • +
    • + ); + })} +
    +
    +
    +
    + ); +} diff --git a/src/pages/home/ui/HomeRunSection.tsx b/src/pages/home/ui/HomeRunSection.tsx new file mode 100644 index 00000000..628850f7 --- /dev/null +++ b/src/pages/home/ui/HomeRunSection.tsx @@ -0,0 +1,39 @@ +import { HOME_COPY, HOME_RUN_STEPS } from "../config"; + +export function HomeRunSection() { + return ( +
    +
    +

    + {HOME_COPY.RUN_HEADING} +

    +

    + {HOME_COPY.RUN_SUBTITLE} +

    +
    + +
      + {HOME_RUN_STEPS.map((step) => ( +
    1. + + {step.index} + +

      {step.title}

      +

      + {step.description} +

      +
    2. + ))} +
    +
    + ); +} diff --git a/src/pages/home/ui/HomeRuntimeDiagram.tsx b/src/pages/home/ui/HomeRuntimeDiagram.tsx new file mode 100644 index 00000000..c98a5c84 --- /dev/null +++ b/src/pages/home/ui/HomeRuntimeDiagram.tsx @@ -0,0 +1,74 @@ +import { Check, LockKeyhole } from "lucide-react"; + +import { cn } from "@/shared/lib"; + +import { HOME_RUNTIME_ROOMS } from "../config"; + +export function HomeRuntimeDiagram() { + return ( +
    +
    +
    floorOne.machine
    + + + Running + +
    + +
      + {HOME_RUNTIME_ROOMS.map((room, index) => ( +
    1. + + {String(index + 1).padStart(2, "0")} + + + + {room.room} + + + state: {room.machineState} + + + {room.status === "guarded" ? ( + + ) : room.status === "active" ? ( + + ) : ( + + )} +
    2. + ))} +
    + +
    +

    + context.key + false +

    +

    + guard.treasury + blocked +

    +
    +
    + ); +} diff --git a/src/pages/home/ui/HomeRuntimeReadingSection.tsx b/src/pages/home/ui/HomeRuntimeReadingSection.tsx deleted file mode 100644 index 589082b5..00000000 --- a/src/pages/home/ui/HomeRuntimeReadingSection.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import { cn } from "@/shared/lib"; -import { MARKETING_LAYOUT_CLASS_NAMES } from "@/widgets/marketing-shell"; - -import { HOME_COPY, HOME_RUNTIME_PANELS } from "../config"; - -export function HomeRuntimeReadingSection() { - return ( -
    -
    -

    - {HOME_COPY.RUNTIME_HEADING} -

    -

    - {HOME_COPY.RUNTIME_SUBTITLE} -

    -
    - -
      - {HOME_RUNTIME_PANELS.map((panel) => ( -
    • -
      -
      -
      -

      - {panel.title} -

      -

      - {panel.description} -

      -
      -
      -
    • - ))} -
    -
    - ); -} diff --git a/src/pages/home/ui/HomeTeachingItem.tsx b/src/pages/home/ui/HomeTeachingItem.tsx deleted file mode 100644 index dc1c36f6..00000000 --- a/src/pages/home/ui/HomeTeachingItem.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { cn } from "@/shared/lib"; - -import type { HomeTeachingFeatureViewModel } from "../lib"; - -type HomeTeachingItemProps = { - feature: HomeTeachingFeatureViewModel; -}; - -export function HomeTeachingItem({ feature }: HomeTeachingItemProps) { - return ( -
    -
    -
    -
    - -
    -

    - {feature.title} -

    -

    - {feature.description} -

    -
    -
    -
    - ); -} diff --git a/src/pages/home/ui/HomeTeachingSection.tsx b/src/pages/home/ui/HomeTeachingSection.tsx deleted file mode 100644 index 80f87ef1..00000000 --- a/src/pages/home/ui/HomeTeachingSection.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import type { HomeTeachingFeatureViewModel } from "../lib"; - -import { HomeTeachingItem } from "./HomeTeachingItem"; - -type HomeTeachingSectionProps = { - features: readonly HomeTeachingFeatureViewModel[]; - heading: string; -}; - -export function HomeTeachingSection({ - features, - heading, -}: HomeTeachingSectionProps) { - return ( -
    -
    -
    -

    - {heading} -

    -
    -
    - -
      - {features.map((feature) => ( -
    • - -
    • - ))} -
    -
    - ); -} diff --git a/src/pages/home/ui/HomeTranslationRail.tsx b/src/pages/home/ui/HomeTranslationRail.tsx deleted file mode 100644 index 383f2a45..00000000 --- a/src/pages/home/ui/HomeTranslationRail.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import { ArrowRight } from "lucide-react"; - -import { cn } from "@/shared/lib"; -import { MARKETING_LAYOUT_CLASS_NAMES } from "@/widgets/marketing-shell"; - -import { HOME_TRANSLATION_ARROW_CLASS_NAME } from "../config"; -import type { HomeTranslationItemViewModel } from "../lib"; - -type HomeTranslationRailProps = { - items: readonly HomeTranslationItemViewModel[]; -}; - -export function HomeTranslationRail({ items }: HomeTranslationRailProps) { - return ( -
      - {items.map((item) => ( -
    • - - {item.label} - -
    • - ))} -
    - ); -} diff --git a/src/pages/tutorial/config/index.ts b/src/pages/tutorial/config/index.ts deleted file mode 100644 index ec5db816..00000000 --- a/src/pages/tutorial/config/index.ts +++ /dev/null @@ -1,24 +0,0 @@ -export { - TUTORIAL_CAMERA_MODES, - TUTORIAL_CONTROL_GROUPS, - TUTORIAL_CONTROL_TONES, - type TutorialControlTone, -} from "./tutorialControlConfig"; -export { - TUTORIAL_CONTROLS_COPY, - TUTORIAL_COPY, - TUTORIAL_FIRST_RUN_COPY, - TUTORIAL_TAB_IDS, - TUTORIAL_TABS, - type TutorialTabId, -} from "./tutorialCopy"; -export { - TUTORIAL_FIRST_RUN_STEPS, - TUTORIAL_FIRST_RUN_TONE_CLASS_NAMES, - TUTORIAL_FIRST_RUN_TONES, - type TutorialFirstRunTone, -} from "./tutorialFirstRunConfig"; -export { - TUTORIAL_ICON_KEYS, - type TutorialIconKey, -} from "./tutorialIconConfig"; diff --git a/src/pages/tutorial/config/tutorialControlConfig.ts b/src/pages/tutorial/config/tutorialControlConfig.ts deleted file mode 100644 index 49dfb290..00000000 --- a/src/pages/tutorial/config/tutorialControlConfig.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { TUTORIAL_ICON_KEYS } from "./tutorialIconConfig"; - -export const TUTORIAL_CONTROL_TONES = { - ACCENT: "accent", - PRIMARY: "primary", -} as const; - -export type TutorialControlTone = - (typeof TUTORIAL_CONTROL_TONES)[keyof typeof TUTORIAL_CONTROL_TONES]; - -export const TUTORIAL_CONTROL_GROUPS = [ - { - heading: "Movement", - rows: [ - { - label: "Move", - mobileIconKey: TUTORIAL_ICON_KEYS.GAMEPAD, - mobileLabel: "Left joystick", - shortcuts: ["W", "A", "S", "D"], - }, - { - label: "Run toggle", - mobileIconKey: TUTORIAL_ICON_KEYS.FOOTPRINTS, - mobileLabel: "Footprints button", - shortcuts: ["Shift"], - }, - { - label: "Jump", - mobileIconKey: TUTORIAL_ICON_KEYS.CHEVRONS_UP, - mobileLabel: "Chevrons-up button", - shortcuts: ["Space"], - }, - ], - tone: TUTORIAL_CONTROL_TONES.PRIMARY, - }, - { - heading: "Actions", - rows: [ - { - label: "Interact", - shortcuts: ["E"], - }, - { - label: "Attack", - shortcuts: ["F"], - }, - ], - tone: TUTORIAL_CONTROL_TONES.ACCENT, - }, -] as const; - -export const TUTORIAL_CAMERA_MODES = [ - { - code: "3P", - key: "1", - label: "3rd Person", - }, - { - code: "TD", - key: "2", - label: "Top Down", - }, - { - code: "1P", - key: "3", - label: "1st Person", - }, - { - code: "FO", - key: "4", - label: "Free Orbital", - }, -] as const; diff --git a/src/pages/tutorial/config/tutorialCopy.ts b/src/pages/tutorial/config/tutorialCopy.ts deleted file mode 100644 index 10cfd14b..00000000 --- a/src/pages/tutorial/config/tutorialCopy.ts +++ /dev/null @@ -1,38 +0,0 @@ -export const TUTORIAL_TAB_IDS = { - CONTROLS: "controls", - FIRST_RUN: "first-run", -} as const; - -export type TutorialTabId = - (typeof TUTORIAL_TAB_IDS)[keyof typeof TUTORIAL_TAB_IDS]; - -export const TUTORIAL_COPY = { - CTA_LABEL: "Enter Dungeon", - HEADING: "Manual", - SUBTITLE: - "Navigate the functional structure of the playable architecture. Understand state transitions, entity data, and traversal paths.", -} as const; - -export const TUTORIAL_TABS = [ - { - id: TUTORIAL_TAB_IDS.CONTROLS, - label: "Controls", - }, - { - id: TUTORIAL_TAB_IDS.FIRST_RUN, - label: "First Run", - }, -] as const; - -export const TUTORIAL_CONTROLS_COPY = { - SECTION_HEADING: "Controls", - SECTION_DESCRIPTION: - "Master the tactile interface to navigate the architecture.", - MOVEMENT_HEADING: "Movement", - ACTIONS_HEADING: "Actions", - CAMERA_HEADING: "Camera modes", -} as const; - -export const TUTORIAL_FIRST_RUN_COPY = { - SECTION_HEADING: "First run path", -} as const; diff --git a/src/pages/tutorial/config/tutorialFirstRunConfig.ts b/src/pages/tutorial/config/tutorialFirstRunConfig.ts deleted file mode 100644 index 840de582..00000000 --- a/src/pages/tutorial/config/tutorialFirstRunConfig.ts +++ /dev/null @@ -1,78 +0,0 @@ -export const TUTORIAL_FIRST_RUN_TONES = { - ACCENT: "accent", - PRIMARY: "primary", - SEALED: "sealed", - SUCCESS: "success", -} as const; - -export type TutorialFirstRunTone = - (typeof TUTORIAL_FIRST_RUN_TONES)[keyof typeof TUTORIAL_FIRST_RUN_TONES]; - -export const TUTORIAL_FIRST_RUN_TONE_CLASS_NAMES = { - [TUTORIAL_FIRST_RUN_TONES.ACCENT]: "text-dungeon-gold", - [TUTORIAL_FIRST_RUN_TONES.PRIMARY]: "text-dungeon-gold", - [TUTORIAL_FIRST_RUN_TONES.SEALED]: "text-dungeon-rune-sealed", - [TUTORIAL_FIRST_RUN_TONES.SUCCESS]: "text-success", -} as const; - -export const TUTORIAL_FIRST_RUN_STEPS = [ - { - detail: - "Mount the run at Entrance, hydrate the active room, and publish the initial state snapshot.", - label: "Enter the initial state", - tokens: [ - { - label: "ENTRANCE", - tone: TUTORIAL_FIRST_RUN_TONES.PRIMARY, - }, - ], - }, - { - detail: - "Emit a movement event; the corridor transition resolves before the next room becomes active.", - label: "Dispatch movement events", - tokens: [ - { - label: "CORRIDORS", - tone: TUTORIAL_FIRST_RUN_TONES.ACCENT, - }, - ], - }, - { - detail: - "Evaluate the guard against keys and blockers; the path stays sealed until the predicate passes.", - label: "Satisfy guards", - tokens: [ - { - label: "KEYS / BLOCKERS", - tone: TUTORIAL_FIRST_RUN_TONES.SEALED, - }, - ], - }, - { - detail: - "Mutate combat state and inventory, then recalculate which transitions remain valid.", - label: "Resolve combat and context", - tokens: [ - { - label: "ENEMY STATE", - tone: TUTORIAL_FIRST_RUN_TONES.ACCENT, - }, - { - label: "INVENTORY", - tone: TUTORIAL_FIRST_RUN_TONES.PRIMARY, - }, - ], - }, - { - detail: - "Write the terminal floor state and close the run once the final room resolves.", - label: "Reach the final state", - tokens: [ - { - label: "COMPLETE FLOOR", - tone: TUTORIAL_FIRST_RUN_TONES.SUCCESS, - }, - ], - }, -] as const; diff --git a/src/pages/tutorial/config/tutorialIconConfig.ts b/src/pages/tutorial/config/tutorialIconConfig.ts deleted file mode 100644 index 71154b8a..00000000 --- a/src/pages/tutorial/config/tutorialIconConfig.ts +++ /dev/null @@ -1,8 +0,0 @@ -export const TUTORIAL_ICON_KEYS = { - CHEVRONS_UP: "chevrons-up", - FOOTPRINTS: "footprints", - GAMEPAD: "gamepad", -} as const; - -export type TutorialIconKey = - (typeof TUTORIAL_ICON_KEYS)[keyof typeof TUTORIAL_ICON_KEYS]; diff --git a/src/pages/tutorial/index.ts b/src/pages/tutorial/index.ts deleted file mode 100644 index b1baa62e..00000000 --- a/src/pages/tutorial/index.ts +++ /dev/null @@ -1,13 +0,0 @@ -export { - TUTORIAL_CAMERA_MODES, - TUTORIAL_CONTROL_GROUPS, - TUTORIAL_CONTROLS_COPY, - TUTORIAL_COPY, - TUTORIAL_FIRST_RUN_COPY, - TUTORIAL_FIRST_RUN_STEPS, - TUTORIAL_FIRST_RUN_TONE_CLASS_NAMES, - TUTORIAL_TAB_IDS, - TUTORIAL_TABS, - type TutorialTabId, -} from "./config"; -export { TutorialPage } from "./ui"; diff --git a/src/pages/tutorial/lib/createTutorialPageViewModel.test.ts b/src/pages/tutorial/lib/createTutorialPageViewModel.test.ts deleted file mode 100644 index dce2606b..00000000 --- a/src/pages/tutorial/lib/createTutorialPageViewModel.test.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { ChevronsUp, Footprints, Gamepad2 } from "lucide-react"; -import { describe, expect, it, vi } from "vitest"; - -import { createTutorialPageViewModel } from "./createTutorialPageViewModel"; - -describe("createTutorialPageViewModel", () => { - it("maps auth state into hero props and control view models", () => { - const handleUsernameEntryRequest = vi.fn(); - - const viewModel = createTutorialPageViewModel({ - handleUsernameEntryRequest, - isAuthenticated: false, - }); - - expect(viewModel.heroProps.isAuthenticated).toBe(false); - expect(viewModel.heroProps.onEntryRequest).toBe(handleUsernameEntryRequest); - expect( - viewModel.controlsSectionProps.controlGroups[0]?.rows[0]?.mobileIcon, - ).toBe(Gamepad2); - expect( - viewModel.controlsSectionProps.controlGroups[0]?.rows[1]?.mobileIcon, - ).toBe(Footprints); - expect( - viewModel.controlsSectionProps.controlGroups[0]?.rows[2]?.mobileIcon, - ).toBe(ChevronsUp); - expect(viewModel.firstRunSectionProps.steps[0]?.label).toBe( - "Enter the initial state", - ); - }); -}); diff --git a/src/pages/tutorial/lib/createTutorialPageViewModel.ts b/src/pages/tutorial/lib/createTutorialPageViewModel.ts deleted file mode 100644 index ffab28d8..00000000 --- a/src/pages/tutorial/lib/createTutorialPageViewModel.ts +++ /dev/null @@ -1,85 +0,0 @@ -import type { AuthContextValue } from "@/features/auth"; - -import { - TUTORIAL_CAMERA_MODES, - TUTORIAL_CONTROL_GROUPS, - TUTORIAL_CONTROLS_COPY, - TUTORIAL_FIRST_RUN_COPY, - TUTORIAL_FIRST_RUN_STEPS, - type TutorialControlTone, -} from "../config"; - -import { resolveTutorialIcon } from "./resolveTutorialIcon"; - -type CreateTutorialPageViewModelInput = Pick< - AuthContextValue, - "handleUsernameEntryRequest" | "isAuthenticated" ->; - -export type TutorialControlRowViewModel = { - label: string; - mobileIcon: ReturnType | null; - mobileLabel?: string; - shortcuts: readonly string[]; -}; - -export type TutorialControlGroupViewModel = { - heading: string; - rows: readonly TutorialControlRowViewModel[]; - tone: TutorialControlTone; -}; - -type TutorialPageViewModel = { - controlsSectionProps: { - description: string; - cameraModes: typeof TUTORIAL_CAMERA_MODES; - controlGroups: readonly TutorialControlGroupViewModel[]; - heading: string; - cameraHeading: string; - }; - firstRunSectionProps: { - heading: string; - steps: typeof TUTORIAL_FIRST_RUN_STEPS; - }; - heroProps: { - isAuthenticated: boolean; - onEntryRequest: () => void; - }; -}; - -export const createTutorialPageViewModel = ({ - handleUsernameEntryRequest, - isAuthenticated, -}: CreateTutorialPageViewModelInput): TutorialPageViewModel => { - const controlGroups = TUTORIAL_CONTROL_GROUPS.map((group) => ({ - heading: group.heading, - rows: group.rows.map((row) => ({ - label: row.label, - mobileIcon: - "mobileIconKey" in row ? resolveTutorialIcon(row.mobileIconKey) : null, - mobileLabel: "mobileLabel" in row ? row.mobileLabel : undefined, - shortcuts: row.shortcuts, - })), - tone: group.tone, - })); - - return { - controlsSectionProps: { - cameraModes: TUTORIAL_CAMERA_MODES, - cameraHeading: TUTORIAL_CONTROLS_COPY.CAMERA_HEADING, - controlGroups, - description: TUTORIAL_CONTROLS_COPY.SECTION_DESCRIPTION, - heading: TUTORIAL_CONTROLS_COPY.SECTION_HEADING, - }, - firstRunSectionProps: { - heading: TUTORIAL_FIRST_RUN_COPY.SECTION_HEADING, - steps: TUTORIAL_FIRST_RUN_STEPS, - }, - heroProps: { - isAuthenticated, - onEntryRequest: handleUsernameEntryRequest, - }, - }; -}; - -export type { CreateTutorialPageViewModelInput, TutorialPageViewModel }; diff --git a/src/pages/tutorial/lib/index.ts b/src/pages/tutorial/lib/index.ts deleted file mode 100644 index a84e0abf..00000000 --- a/src/pages/tutorial/lib/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -export { - type CreateTutorialPageViewModelInput, - createTutorialPageViewModel, - type TutorialControlGroupViewModel, - type TutorialControlRowViewModel, - type TutorialPageViewModel, -} from "./createTutorialPageViewModel"; -export { resolveTutorialIcon } from "./resolveTutorialIcon"; diff --git a/src/pages/tutorial/lib/resolveTutorialIcon.test.ts b/src/pages/tutorial/lib/resolveTutorialIcon.test.ts deleted file mode 100644 index 6ce9a045..00000000 --- a/src/pages/tutorial/lib/resolveTutorialIcon.test.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { ChevronsUp, Footprints, Gamepad2 } from "lucide-react"; -import { describe, expect, it } from "vitest"; - -import { TUTORIAL_ICON_KEYS } from "../config"; -import { resolveTutorialIcon } from "./resolveTutorialIcon"; - -describe("resolveTutorialIcon", () => { - it("resolves configured tutorial icons", () => { - expect(resolveTutorialIcon(TUTORIAL_ICON_KEYS.GAMEPAD)).toBe(Gamepad2); - expect(resolveTutorialIcon(TUTORIAL_ICON_KEYS.FOOTPRINTS)).toBe(Footprints); - expect(resolveTutorialIcon(TUTORIAL_ICON_KEYS.CHEVRONS_UP)).toBe( - ChevronsUp, - ); - }); -}); diff --git a/src/pages/tutorial/lib/resolveTutorialIcon.ts b/src/pages/tutorial/lib/resolveTutorialIcon.ts deleted file mode 100644 index 3190d738..00000000 --- a/src/pages/tutorial/lib/resolveTutorialIcon.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { - ChevronsUp, - Footprints, - Gamepad2, - type LucideIcon, -} from "lucide-react"; - -import { TUTORIAL_ICON_KEYS, type TutorialIconKey } from "../config"; - -export const resolveTutorialIcon = (iconKey: TutorialIconKey): LucideIcon => { - switch (iconKey) { - case TUTORIAL_ICON_KEYS.CHEVRONS_UP: - return ChevronsUp; - case TUTORIAL_ICON_KEYS.FOOTPRINTS: - return Footprints; - case TUTORIAL_ICON_KEYS.GAMEPAD: - return Gamepad2; - } -}; diff --git a/src/pages/tutorial/model/index.ts b/src/pages/tutorial/model/index.ts deleted file mode 100644 index 85e0cac5..00000000 --- a/src/pages/tutorial/model/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { useTutorialPage } from "./useTutorialPage"; diff --git a/src/pages/tutorial/model/useTutorialPage.ts b/src/pages/tutorial/model/useTutorialPage.ts deleted file mode 100644 index ad146c67..00000000 --- a/src/pages/tutorial/model/useTutorialPage.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { useAuthContext } from "@/features/auth"; - -import { createTutorialPageViewModel } from "../lib"; - -export const useTutorialPage = () => { - const { handleUsernameEntryRequest, isAuthenticated } = useAuthContext(); - - return createTutorialPageViewModel({ - handleUsernameEntryRequest, - isAuthenticated, - }); -}; diff --git a/src/pages/tutorial/ui/TutorialCameraModesCard.tsx b/src/pages/tutorial/ui/TutorialCameraModesCard.tsx deleted file mode 100644 index bb888251..00000000 --- a/src/pages/tutorial/ui/TutorialCameraModesCard.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import { Camera } from "lucide-react"; - -import { cn } from "@/shared/lib"; -import { Card, CardContent } from "@/shared/ui"; - -import type { TutorialPageViewModel } from "../lib"; - -type TutorialCameraModesCardProps = { - cameraHeading: TutorialPageViewModel["controlsSectionProps"]["cameraHeading"]; - cameraModes: TutorialPageViewModel["controlsSectionProps"]["cameraModes"]; -}; - -export function TutorialCameraModesCard({ - cameraHeading, - cameraModes, -}: TutorialCameraModesCardProps) { - return ( - - -
    -
    - -
    -

    - {cameraHeading} -

    -
    - -
      - {cameraModes.map((mode) => ( -
    • -
      - - {mode.label} - -
      - - {mode.code} - - - {mode.key} - -
      -
      -
    • - ))} -
    -
    -
    - ); -} diff --git a/src/pages/tutorial/ui/TutorialControlGroupCard.tsx b/src/pages/tutorial/ui/TutorialControlGroupCard.tsx deleted file mode 100644 index 3341284c..00000000 --- a/src/pages/tutorial/ui/TutorialControlGroupCard.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import { Keyboard, Zap } from "lucide-react"; - -import { cn } from "@/shared/lib"; -import { Card, CardContent } from "@/shared/ui"; - -import { TUTORIAL_CONTROL_TONES } from "../config"; -import type { TutorialControlGroupViewModel } from "../lib"; - -import { TutorialControlRow } from "./TutorialControlRow"; - -type TutorialControlGroupCardProps = { - group: TutorialControlGroupViewModel; -}; - -export function TutorialControlGroupCard({ - group, -}: TutorialControlGroupCardProps) { - return ( - - -
    -
    - {group.tone === TUTORIAL_CONTROL_TONES.ACCENT ? ( - - ) : ( - - )} -
    -

    - {group.heading} -

    -
    - -
      - {group.rows.map((row) => ( - - ))} -
    -
    -
    - ); -} diff --git a/src/pages/tutorial/ui/TutorialControlRow.tsx b/src/pages/tutorial/ui/TutorialControlRow.tsx deleted file mode 100644 index 7e8455b1..00000000 --- a/src/pages/tutorial/ui/TutorialControlRow.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import type { LucideIcon } from "lucide-react"; - -import { cn } from "@/shared/lib"; - -type TutorialControlRowData = { - label: string; - mobileIcon?: LucideIcon | null; - mobileLabel?: string; - shortcuts: readonly string[]; -}; - -type TutorialControlRowProps = { - row: TutorialControlRowData; -}; - -export function TutorialControlRow({ row }: TutorialControlRowProps) { - const MobileShortcutIcon = row.mobileIcon; - const hasMobileIcon = MobileShortcutIcon != null; - - return ( -
  • - {row.label} -
    - {hasMobileIcon && MobileShortcutIcon ? ( -
    -
    -
    - - {row.mobileLabel} - -
    - ) : null} - -
    - {row.shortcuts.map((shortcut) => ( - - {shortcut} - - ))} -
    -
    -
  • - ); -} - -export type { TutorialControlRowData }; diff --git a/src/pages/tutorial/ui/TutorialControlsPanel.tsx b/src/pages/tutorial/ui/TutorialControlsPanel.tsx deleted file mode 100644 index 33e53597..00000000 --- a/src/pages/tutorial/ui/TutorialControlsPanel.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import type { TutorialPageViewModel } from "../lib"; - -import { TutorialCameraModesCard } from "./TutorialCameraModesCard"; -import { TutorialControlGroupCard } from "./TutorialControlGroupCard"; - -type TutorialControlsPanelProps = TutorialPageViewModel["controlsSectionProps"]; - -export function TutorialControlsPanel({ - cameraHeading, - cameraModes, - controlGroups, - description, - heading, -}: TutorialControlsPanelProps) { - return ( -
    -
    -

    - {heading} -

    -

    - {description} -

    -
    - -
    -
    - {controlGroups.map((group) => ( - - ))} -
    - - -
    -
    - ); -} diff --git a/src/pages/tutorial/ui/TutorialFirstRunPanel.tsx b/src/pages/tutorial/ui/TutorialFirstRunPanel.tsx deleted file mode 100644 index cb43918c..00000000 --- a/src/pages/tutorial/ui/TutorialFirstRunPanel.tsx +++ /dev/null @@ -1,85 +0,0 @@ -import { cn } from "@/shared/lib"; -import { Badge } from "@/shared/ui"; - -import { - TUTORIAL_FIRST_RUN_TONE_CLASS_NAMES, - TUTORIAL_FIRST_RUN_TONES, -} from "../config"; -import type { TutorialPageViewModel } from "../lib"; - -type TutorialFirstRunPanelProps = TutorialPageViewModel["firstRunSectionProps"]; - -export function TutorialFirstRunPanel({ - heading, - steps, -}: TutorialFirstRunPanelProps) { - return ( -
    -
    -

    - {heading} -

    -
    -
    - -
      - {steps.map((step, index) => ( -
    1. -
      -
      - {String(index + 1).padStart(2, "0")} -
      - {index < steps.length - 1 ? ( -
      - ) : null} -
      - -
      -
      -
      -

      - {step.label} -

      -
      - {step.tokens.map((token) => ( - - {token.label} - - ))} -
      -

      - {step.detail} -

      -
      -
      -
    2. - ))} -
    -
    - ); -} diff --git a/src/pages/tutorial/ui/TutorialHero.tsx b/src/pages/tutorial/ui/TutorialHero.tsx deleted file mode 100644 index 048cc92a..00000000 --- a/src/pages/tutorial/ui/TutorialHero.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { Link } from "@tanstack/react-router"; -import { BookOpen, DoorOpen } from "lucide-react"; - -import { Button } from "@/shared/ui"; -import { MARKETING_ROUTES } from "@/widgets/marketing-shell"; - -import { TUTORIAL_COPY } from "../config"; - -type TutorialHeroProps = { - isAuthenticated: boolean; - onEntryRequest: () => void; -}; - -export function TutorialHero({ - isAuthenticated, - onEntryRequest, -}: TutorialHeroProps) { - return ( -
    -
    - -

    - {TUTORIAL_COPY.HEADING} -

    -
    -

    - {TUTORIAL_COPY.SUBTITLE} -

    - - {isAuthenticated ? ( - - ) : ( - - )} -
    - ); -} diff --git a/src/pages/tutorial/ui/TutorialPage.test.tsx b/src/pages/tutorial/ui/TutorialPage.test.tsx deleted file mode 100644 index b7a78939..00000000 --- a/src/pages/tutorial/ui/TutorialPage.test.tsx +++ /dev/null @@ -1,160 +0,0 @@ -// @vitest-environment happy-dom - -import { - cleanup, - fireEvent, - render, - screen, - waitFor, - within, -} from "@testing-library/react"; -import type { ReactNode } from "react"; -import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; - -import { TutorialPage } from "./TutorialPage"; - -const mockUseAuthContext = vi.hoisted(() => vi.fn()); - -vi.mock("@/features/auth", async () => { - const actual = - await vi.importActual("@/features/auth"); - - return { - ...actual, - useAuthContext: mockUseAuthContext, - }; -}); - -vi.mock("@tanstack/react-router", () => ({ - Link: ({ children, to, ...props }: { children: ReactNode; to: string }) => ( - - {children} - - ), -})); - -afterEach(cleanup); - -beforeEach(() => { - mockUseAuthContext.mockReturnValue({ - handleUsernameEntryRequest: vi.fn(), - isAuthenticated: true, - }); -}); - -const activateTab = (name: string) => { - const tab = screen.getByRole("tab", { name }); - - fireEvent.pointerDown(tab); - fireEvent.mouseDown(tab); - fireEvent.click(tab); -}; - -describe("TutorialPage", () => { - it("renders the guide with stable tabs", () => { - render(); - - expect(screen.getByText("Manual")).not.toBeNull(); - expect(screen.getByRole("tab", { name: "Controls" })).not.toBeNull(); - expect(screen.getByRole("tab", { name: "First Run" })).not.toBeNull(); - expect(screen.queryByRole("tab", { name: "Concepts" })).toBeNull(); - }); - - it("renders accurate desktop controls", () => { - render(); - - expect( - screen.getByText( - "Master the tactile interface to navigate the architecture.", - ), - ).not.toBeNull(); - expect(screen.getByText("Movement")).not.toBeNull(); - expect(screen.getByText("Actions")).not.toBeNull(); - expect(screen.getByText("Camera modes")).not.toBeNull(); - expect(screen.getByText("3rd Person")).not.toBeNull(); - expect(screen.getByText("Top Down")).not.toBeNull(); - expect(screen.getByText("1st Person")).not.toBeNull(); - expect(screen.getByText("Free Orbital")).not.toBeNull(); - expect(screen.getByText("W", { selector: "kbd" })).not.toBeNull(); - expect(screen.getByText("Shift", { selector: "kbd" })).not.toBeNull(); - expect(screen.getByText("Space", { selector: "kbd" })).not.toBeNull(); - expect(screen.getByText("E", { selector: "kbd" })).not.toBeNull(); - expect(screen.getByText("F", { selector: "kbd" })).not.toBeNull(); - expect(screen.getByText("Left joystick")).not.toBeNull(); - expect(screen.getByText("Footprints button")).not.toBeNull(); - expect(screen.getByText("Chevrons-up button")).not.toBeNull(); - }); - - it("renders first run content without developer setup copy", async () => { - render(); - - activateTab("First Run"); - - await waitFor(() => - expect(screen.getByText("First run path")).not.toBeNull(), - ); - expect(screen.getByText("Enter the initial state")).not.toBeNull(); - expect(screen.getByText("Dispatch movement events")).not.toBeNull(); - expect(screen.getByText("Satisfy guards")).not.toBeNull(); - expect(screen.getByText("Resolve combat and context")).not.toBeNull(); - expect(screen.getByText("Reach the final state")).not.toBeNull(); - expect( - screen.getByText( - "Mount the run at Entrance, hydrate the active room, and publish the initial state snapshot.", - ), - ).not.toBeNull(); - expect( - screen.getByText( - "Emit a movement event; the corridor transition resolves before the next room becomes active.", - ), - ).not.toBeNull(); - expect( - screen.getByText( - "Evaluate the guard against keys and blockers; the path stays sealed until the predicate passes.", - ), - ).not.toBeNull(); - expect( - screen.getByText( - "Mutate combat state and inventory, then recalculate which transitions remain valid.", - ), - ).not.toBeNull(); - expect( - screen.getByText( - "Write the terminal floor state and close the run once the final room resolves.", - ), - ).not.toBeNull(); - expect(screen.getByText("ENTRANCE")).not.toBeNull(); - expect(screen.getByText("CORRIDORS")).not.toBeNull(); - expect(screen.getByText("KEYS / BLOCKERS")).not.toBeNull(); - expect(screen.getByText("ENEMY STATE")).not.toBeNull(); - expect(screen.getByText("INVENTORY")).not.toBeNull(); - expect(screen.getByText("COMPLETE FLOOR")).not.toBeNull(); - expect(screen.queryByText(/git clone/i)).toBeNull(); - expect(screen.queryByText(/pnpm/i)).toBeNull(); - expect(screen.queryByText(/deployment/i)).toBeNull(); - }); - - it("requests username entry when unauthenticated", () => { - const handleUsernameEntryRequest = vi.fn(); - - mockUseAuthContext.mockReturnValue({ - handleUsernameEntryRequest, - isAuthenticated: false, - }); - - render(); - - const hero = screen - .getByRole("heading", { name: "Manual" }) - .closest("header"); - - expect(hero).not.toBeNull(); - const entryButton = within(hero as HTMLElement).getByRole("button", { - name: "Enter Dungeon", - }); - - fireEvent.click(entryButton); - - expect(handleUsernameEntryRequest).toHaveBeenCalledOnce(); - }); -}); diff --git a/src/pages/tutorial/ui/TutorialPage.tsx b/src/pages/tutorial/ui/TutorialPage.tsx deleted file mode 100644 index af8df724..00000000 --- a/src/pages/tutorial/ui/TutorialPage.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/shared/ui"; - -import { TUTORIAL_TAB_IDS, TUTORIAL_TABS } from "../config"; -import { useTutorialPage } from "../model"; - -import { TutorialControlsPanel } from "./TutorialControlsPanel"; -import { TutorialFirstRunPanel } from "./TutorialFirstRunPanel"; -import { TutorialHero } from "./TutorialHero"; - -export function TutorialPage() { - const { controlsSectionProps, firstRunSectionProps, heroProps } = - useTutorialPage(); - - return ( - <> - - - - - {TUTORIAL_TABS.map((tab) => ( - - {tab.label} - - ))} - - - - - - - - - - - - ); -} diff --git a/src/pages/tutorial/ui/index.ts b/src/pages/tutorial/ui/index.ts deleted file mode 100644 index 50a9dfd6..00000000 --- a/src/pages/tutorial/ui/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { TutorialPage } from "./TutorialPage"; diff --git a/src/widgets/marketing-shell/config/marketingLayoutConfig.ts b/src/widgets/marketing-shell/config/marketingLayoutConfig.ts index 2a9d905f..49b4820c 100644 --- a/src/widgets/marketing-shell/config/marketingLayoutConfig.ts +++ b/src/widgets/marketing-shell/config/marketingLayoutConfig.ts @@ -1,39 +1,8 @@ export const MARKETING_LAYOUT_CLASS_NAMES = { PAGE_FRAME: - "mx-auto flex w-full max-w-7xl flex-col gap-12 px-4 py-10 sm:gap-14 sm:px-6 sm:py-14 lg:gap-16 lg:px-8 lg:py-16", + "flex w-full flex-col gap-20 py-6 sm:gap-24 sm:py-8 lg:gap-28 lg:py-10", + CONTENT_GUTTER: "px-3 sm:px-4", CONTENT_WIDTH: "max-w-7xl", SHELL_BACKGROUND: - "pointer-events-none absolute inset-0 overflow-hidden bg-background", - SHELL_GLOW_PRIMARY: - "absolute -left-24 -top-24 size-96 rounded-full bg-dungeon-gold/10 blur-3xl", - SHELL_GLOW_ACCENT: - "absolute right-[-6rem] top-16 size-96 rounded-full bg-dungeon-gold/10 blur-3xl", - SHELL_GRID: - "absolute inset-0 bg-[url('/marketing/hex-grid.svg')] bg-[size:120px_104px] opacity-[0.08]", - SHELL_EDGE_FADE: - "absolute inset-x-0 top-0 h-24 bg-gradient-to-b from-background/82 to-transparent", - SECTION_GAP: "space-y-6 sm:space-y-8", - SPLIT_GRID: "grid gap-6 lg:grid-cols-[1.1fr_0.9fr]", - CARD_GRID: "grid gap-5 sm:grid-cols-2 xl:grid-cols-3", - CARD_SURFACE: "rounded-lg border border-border bg-card/80 shadow-none ring-0", - CARD_CONTENT: "p-5 sm:p-6", - SUBTLE_PANEL: "rounded-lg border border-border bg-card/70 shadow-none ring-0", - MAJOR_PANEL: "rounded-xl border border-border bg-card/80 shadow-none ring-0", - CTA_BAND: "rounded-xl border border-border bg-card/70 px-5 py-5 sm:px-6", - TOKEN_RAIL: - "flex w-full items-center gap-2 overflow-x-auto border-y border-border bg-card/40 px-4 py-3 backdrop-blur no-scrollbar", - LIGHT_ROW: "rounded-lg border border-border bg-card/70 transition-colors", - LIGHT_ROW_INTERACTIVE: - "rounded-lg border border-border bg-card/70 transition-colors hover:border-dungeon-gold/40 hover:bg-dungeon-gold/5", - TIMELINE_LIST: - "relative grid gap-4 rounded-xl border border-border bg-card/50 p-4 sm:p-5", - TIMELINE_ITEM: - "relative grid grid-cols-[auto_minmax(0,1fr)] gap-3 rounded-lg border border-border bg-card/80 px-4 py-4 sm:gap-4 sm:px-5", - TIMELINE_RAIL: "flex flex-col items-center pt-1", - TIMELINE_NODE: - "flex size-8 items-center justify-center rounded-full border border-dungeon-gold/45 bg-dungeon-gold/10 text-[0.7rem] font-bold text-dungeon-gold", - MAPPING_RAIL: - "grid gap-4 rounded-xl border border-border bg-card/50 p-4 sm:p-5", - MAPPING_ROW: - "grid gap-4 rounded-lg border border-border bg-card/80 p-4 sm:grid-cols-[minmax(0,0.75fr)_auto_minmax(0,1fr)] sm:items-center sm:p-5", + "observatory-backdrop pointer-events-none absolute inset-0 overflow-hidden", } as const; diff --git a/src/widgets/marketing-shell/config/marketingShellConfig.ts b/src/widgets/marketing-shell/config/marketingShellConfig.ts index d277b271..3ea1922b 100644 --- a/src/widgets/marketing-shell/config/marketingShellConfig.ts +++ b/src/widgets/marketing-shell/config/marketingShellConfig.ts @@ -1,6 +1,6 @@ export const MARKETING_NAVIGATION_ITEM_IDS = { - GUIDE: "guide", - CONCEPTS: "concepts", + HOW_IT_WORKS: "how-it-works", + FIELD_GUIDE: "field-guide", } as const; export type MarketingNavigationItemId = @@ -20,42 +20,48 @@ export const MARKETING_SHELL_COPY = { BRAND_STONE_SEGMENT: "STONE", COMPACT_BRAND_RUNE_SEGMENT: "R", COMPACT_BRAND_STONE_SEGMENT: "S", - ENTER_DUNGEON_LABEL: "Enter Dungeon", + ENTER_DUNGEON_LABEL: "Enter Floor I", NAVIGATION_SHEET_TITLE: "Runestone", - NAVIGATION_SHEET_DESCRIPTION: "Navigate the playable architecture guide.", + NAVIGATION_SHEET_DESCRIPTION: + "Inspect Floor I, the running machine, and its controls.", FOOTER_COPYRIGHT: "© 2026 Runestone", - FOOTER_TAGLINE: "Playable architecture", + FOOTER_TAGLINE: "Executable logic, made physical", GITHUB_LABEL: "GitHub", OPEN_NAVIGATION_LABEL: "Open navigation", } as const; export const MARKETING_NAVIGATION_ITEMS = [ { - id: MARKETING_NAVIGATION_ITEM_IDS.GUIDE, - label: "Guide", - to: MARKETING_ROUTES.GUIDE, + id: MARKETING_NAVIGATION_ITEM_IDS.HOW_IT_WORKS, + label: "How it works", + href: "/#how-it-works", }, { - id: MARKETING_NAVIGATION_ITEM_IDS.CONCEPTS, - label: "Concepts", - to: MARKETING_ROUTES.CONCEPTS, + id: MARKETING_NAVIGATION_ITEM_IDS.FIELD_GUIDE, + label: "Field guide", + href: "/#machine", }, ] as const; export const MARKETING_FOOTER_LINKS = [ { - label: "Guide", - to: MARKETING_ROUTES.GUIDE, - type: "internal", + label: "How it works", + href: "/#how-it-works", + type: "anchor", }, { - label: "Concepts", - to: MARKETING_ROUTES.CONCEPTS, - type: "internal", + label: "The machine", + href: "/#machine", + type: "anchor", + }, + { + label: "Controls", + href: "/#controls", + type: "anchor", }, { label: "GitHub", - to: MARKETING_ROUTES.GITHUB_REPOSITORY, + href: MARKETING_ROUTES.GITHUB_REPOSITORY, type: "external", }, ] as const; diff --git a/src/widgets/marketing-shell/lib/createMarketingNavigationViewModel.test.ts b/src/widgets/marketing-shell/lib/createMarketingNavigationViewModel.test.ts index 95668e3f..7377d332 100644 --- a/src/widgets/marketing-shell/lib/createMarketingNavigationViewModel.test.ts +++ b/src/widgets/marketing-shell/lib/createMarketingNavigationViewModel.test.ts @@ -10,19 +10,19 @@ import { createMarketingNavigationViewModel } from "./createMarketingNavigationV describe("createMarketingNavigationViewModel", () => { it("marks the active navigation item", () => { const viewModel = createMarketingNavigationViewModel({ - activeNavigationItemId: MARKETING_NAVIGATION_ITEM_IDS.CONCEPTS, + activeNavigationItemId: MARKETING_NAVIGATION_ITEM_IDS.FIELD_GUIDE, footerLinks: MARKETING_FOOTER_LINKS, navigationItems: MARKETING_NAVIGATION_ITEMS, }); expect( viewModel.navigationItems.find( - (item) => item.id === MARKETING_NAVIGATION_ITEM_IDS.CONCEPTS, + (item) => item.id === MARKETING_NAVIGATION_ITEM_IDS.FIELD_GUIDE, )?.isActive, ).toBe(true); expect( viewModel.navigationItems.find( - (item) => item.id === MARKETING_NAVIGATION_ITEM_IDS.GUIDE, + (item) => item.id === MARKETING_NAVIGATION_ITEM_IDS.HOW_IT_WORKS, )?.isActive, ).toBe(false); }); diff --git a/src/widgets/marketing-shell/lib/resolveMarketingNavigationItemId.test.ts b/src/widgets/marketing-shell/lib/resolveMarketingNavigationItemId.test.ts index e86444ba..edc55ed1 100644 --- a/src/widgets/marketing-shell/lib/resolveMarketingNavigationItemId.test.ts +++ b/src/widgets/marketing-shell/lib/resolveMarketingNavigationItemId.test.ts @@ -7,13 +7,13 @@ import { resolveMarketingNavigationItemId } from "./resolveMarketingNavigationIt describe("resolveMarketingNavigationItemId", () => { it("resolves the guide navigation item for the tutorial route", () => { expect(resolveMarketingNavigationItemId(MARKETING_ROUTES.GUIDE)).toBe( - MARKETING_NAVIGATION_ITEM_IDS.GUIDE, + MARKETING_NAVIGATION_ITEM_IDS.FIELD_GUIDE, ); }); it("resolves the concepts navigation item for the concepts route", () => { expect(resolveMarketingNavigationItemId(MARKETING_ROUTES.CONCEPTS)).toBe( - MARKETING_NAVIGATION_ITEM_IDS.CONCEPTS, + MARKETING_NAVIGATION_ITEM_IDS.FIELD_GUIDE, ); }); diff --git a/src/widgets/marketing-shell/lib/resolveMarketingNavigationItemId.ts b/src/widgets/marketing-shell/lib/resolveMarketingNavigationItemId.ts index 240a35e5..757caca8 100644 --- a/src/widgets/marketing-shell/lib/resolveMarketingNavigationItemId.ts +++ b/src/widgets/marketing-shell/lib/resolveMarketingNavigationItemId.ts @@ -9,9 +9,9 @@ export const resolveMarketingNavigationItemId = ( ): MarketingNavigationItemId | null => { switch (pathname) { case MARKETING_ROUTES.GUIDE: - return MARKETING_NAVIGATION_ITEM_IDS.GUIDE; + return MARKETING_NAVIGATION_ITEM_IDS.FIELD_GUIDE; case MARKETING_ROUTES.CONCEPTS: - return MARKETING_NAVIGATION_ITEM_IDS.CONCEPTS; + return MARKETING_NAVIGATION_ITEM_IDS.FIELD_GUIDE; default: return null; } diff --git a/src/widgets/marketing-shell/model/index.ts b/src/widgets/marketing-shell/model/index.ts index d165d811..7812a6ef 100644 --- a/src/widgets/marketing-shell/model/index.ts +++ b/src/widgets/marketing-shell/model/index.ts @@ -1,3 +1,4 @@ export { useMarketingLayoutRoute } from "./useMarketingLayoutRoute"; export { useMarketingNavigation } from "./useMarketingNavigation"; +export { useMarketingNavigationSheet } from "./useMarketingNavigationSheet"; export { useRunestoneLogo } from "./useRunestoneLogo"; diff --git a/src/widgets/marketing-shell/model/useMarketingLayoutRoute.test.tsx b/src/widgets/marketing-shell/model/useMarketingLayoutRoute.test.tsx index 42c89aaa..d55362f3 100644 --- a/src/widgets/marketing-shell/model/useMarketingLayoutRoute.test.tsx +++ b/src/widgets/marketing-shell/model/useMarketingLayoutRoute.test.tsx @@ -1,12 +1,11 @@ // @vitest-environment happy-dom -import { renderHook } from "@testing-library/react"; -import { describe, expect, it, vi } from "vitest"; +import { cleanup, renderHook } from "@testing-library/react"; +import { afterEach, describe, expect, it, vi } from "vitest"; import { AUTH_STATUS } from "@/features/auth"; const mockUseAuthContext = vi.hoisted(() => vi.fn()); -const mockNavigate = vi.hoisted(() => vi.fn()); const mockUseLocation = vi.hoisted(() => vi.fn()); vi.mock("@/features/auth", async () => { @@ -21,9 +20,6 @@ vi.mock("@/features/auth", async () => { vi.mock("@tanstack/react-router", () => ({ useLocation: mockUseLocation, - useRouter: () => ({ - navigate: mockNavigate, - }), })); import { MARKETING_NAVIGATION_ITEM_IDS, MARKETING_ROUTES } from "../config"; @@ -45,6 +41,11 @@ const createAuthContext = () => ({ authStatus: AUTH_STATUS.REQUIRES_USERNAME, }); +afterEach(() => { + cleanup(); + document.body.replaceChildren(); +}); + describe("useMarketingLayoutRoute", () => { it("resolves the active navigation item and keeps the modal flow routed through the hook", () => { const authContext = createAuthContext(); @@ -55,7 +56,7 @@ describe("useMarketingLayoutRoute", () => { const { result } = renderHook(() => useMarketingLayoutRoute()); expect(result.current.shellProps.activeNavigationItemId).toBe( - MARKETING_NAVIGATION_ITEM_IDS.CONCEPTS, + MARKETING_NAVIGATION_ITEM_IDS.FIELD_GUIDE, ); expect(result.current.shellProps.isAuthenticated).toBe(false); expect(result.current.shellProps.onEntryRequest).toBe( @@ -70,11 +71,24 @@ describe("useMarketingLayoutRoute", () => { authContext.handleUsernameFormSubmit, ); + const hiddenEntryTrigger = document.createElement("button"); + hiddenEntryTrigger.dataset.entryTrigger = "true"; + hiddenEntryTrigger.getClientRects = () => [] as unknown as DOMRectList; + const visibleEntryTrigger = document.createElement("button"); + visibleEntryTrigger.dataset.entryTrigger = "true"; + visibleEntryTrigger.getClientRects = () => [{}] as unknown as DOMRectList; + document.body.append(hiddenEntryTrigger, visibleEntryTrigger); + const closeEvent = new Event("close", { cancelable: true }); + + result.current.usernameModalProps.onCloseAutoFocus(closeEvent); + + expect(closeEvent.defaultPrevented).toBe(true); + expect(document.activeElement).toBe(visibleEntryTrigger); + result.current.shellProps.onEntryRequest(); result.current.usernameModalProps.onKeepReading(); expect(authContext.handleUsernameEntryRequest).toHaveBeenCalledOnce(); expect(authContext.handleUsernameEntryDismiss).toHaveBeenCalledOnce(); - expect(mockNavigate).toHaveBeenCalledWith({ to: MARKETING_ROUTES.HOME }); }); }); diff --git a/src/widgets/marketing-shell/model/useMarketingLayoutRoute.ts b/src/widgets/marketing-shell/model/useMarketingLayoutRoute.ts index 0276f860..49f76230 100644 --- a/src/widgets/marketing-shell/model/useMarketingLayoutRoute.ts +++ b/src/widgets/marketing-shell/model/useMarketingLayoutRoute.ts @@ -1,8 +1,8 @@ -import { useLocation, useRouter } from "@tanstack/react-router"; +import { useLocation } from "@tanstack/react-router"; import { type UsernameFormInput, useAuthContext } from "@/features/auth"; -import { MARKETING_ROUTES, type MarketingNavigationItemId } from "../config"; +import type { MarketingNavigationItemId } from "../config"; import { resolveMarketingNavigationItemId } from "../lib"; type MarketingLayoutRouteViewModel = { @@ -16,6 +16,7 @@ type MarketingLayoutRouteViewModel = { isOpen: boolean; isSubmitting: boolean; suggestedUsername: string; + onCloseAutoFocus: (event: Event) => void; onKeepReading: () => void; onSubmit: (input: UsernameFormInput) => Promise; }; @@ -33,7 +34,6 @@ export const useMarketingLayoutRoute = (): MarketingLayoutRouteViewModel => { suggestedUsername, } = useAuthContext(); const { pathname } = useLocation(); - const router = useRouter(); const activeNavigationItemId = resolveMarketingNavigationItemId(pathname); return { @@ -47,9 +47,19 @@ export const useMarketingLayoutRoute = (): MarketingLayoutRouteViewModel => { isOpen: isUsernameModalOpen, isSubmitting: isUsernameSubmitting, suggestedUsername, + onCloseAutoFocus: (event) => { + event.preventDefault(); + const entryTriggers = document.querySelectorAll( + "[data-entry-trigger]", + ); + const visibleEntryTrigger = Array.from(entryTriggers).find( + (entryTrigger) => entryTrigger.getClientRects().length > 0, + ); + + (visibleEntryTrigger ?? entryTriggers.item(0))?.focus(); + }, onKeepReading: () => { handleUsernameEntryDismiss(); - void router.navigate({ to: MARKETING_ROUTES.HOME }); }, onSubmit: handleUsernameFormSubmit, }, diff --git a/src/widgets/marketing-shell/model/useMarketingNavigationSheet.test.tsx b/src/widgets/marketing-shell/model/useMarketingNavigationSheet.test.tsx new file mode 100644 index 00000000..8ceb1fb9 --- /dev/null +++ b/src/widgets/marketing-shell/model/useMarketingNavigationSheet.test.tsx @@ -0,0 +1,36 @@ +// @vitest-environment happy-dom + +import { act, renderHook } from "@testing-library/react"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; + +import { useMarketingNavigationSheet } from "./useMarketingNavigationSheet"; + +describe("useMarketingNavigationSheet", () => { + beforeEach(() => { + vi.useFakeTimers(); + }); + + afterEach(() => { + vi.useRealTimers(); + document.body.replaceChildren(); + }); + + it("scrolls to the selected anchor after the sheet releases scroll lock", () => { + const target = document.createElement("section"); + target.id = "machine"; + target.scrollIntoView = vi.fn(); + document.body.append(target); + const anchor = document.createElement("a"); + anchor.href = "/#machine"; + const { result } = renderHook(() => useMarketingNavigationSheet()); + + act(() => { + result.current.handleAnchorNavigation({ + currentTarget: anchor, + } as React.MouseEvent); + vi.runAllTimers(); + }); + + expect(target.scrollIntoView).toHaveBeenCalledOnce(); + }); +}); diff --git a/src/widgets/marketing-shell/model/useMarketingNavigationSheet.ts b/src/widgets/marketing-shell/model/useMarketingNavigationSheet.ts new file mode 100644 index 00000000..c92771c0 --- /dev/null +++ b/src/widgets/marketing-shell/model/useMarketingNavigationSheet.ts @@ -0,0 +1,16 @@ +import type { MouseEvent } from "react"; + +type MarketingNavigationSheetViewModel = { + handleAnchorNavigation: (event: MouseEvent) => void; +}; + +export const useMarketingNavigationSheet = + (): MarketingNavigationSheetViewModel => ({ + handleAnchorNavigation: (event) => { + const targetId = event.currentTarget.hash.slice(1); + + window.setTimeout(() => { + document.getElementById(targetId)?.scrollIntoView(); + }, 0); + }, + }); diff --git a/src/widgets/marketing-shell/ui/MarketingFooter.tsx b/src/widgets/marketing-shell/ui/MarketingFooter.tsx index f6942e23..7d6c7cb6 100644 --- a/src/widgets/marketing-shell/ui/MarketingFooter.tsx +++ b/src/widgets/marketing-shell/ui/MarketingFooter.tsx @@ -15,22 +15,22 @@ type MarketingFooterProps = { export function MarketingFooter({ viewModel }: MarketingFooterProps) { return ( -