From 89ebb7b9d11acace867f5e61cbb5cbd61928fa32 Mon Sep 17 00:00:00 2001 From: Tshepang Date: Sun, 19 Jul 2026 22:06:05 +0200 Subject: [PATCH 1/3] feat(game): revamp the dungeon observatory --- .../config/mobileActionButtonLayoutConfig.ts | 2 +- .../ui/MobileActionButtonZone.test.tsx | 2 + .../settings/config/settingsConfig.ts | 2 +- src/pages/game/config/index.ts | 25 +++-- src/pages/game/ui/GamePage.test.tsx | 32 +++++- .../game/ui/GamePageDesktopHeader.test.tsx | 6 +- src/pages/game/ui/GamePageDesktopHeader.tsx | 43 +++++--- src/pages/game/ui/GamePageDesktopLayout.tsx | 2 +- .../game/ui/GamePageDesktopSettingsAction.tsx | 2 +- .../ui/GamePageDesktopWorkspacePanels.tsx | 28 +++-- src/pages/game/ui/GamePageHomeAction.tsx | 3 +- src/pages/game/ui/GamePageHudPanel.tsx | 2 +- .../ui/GamePageMobileActionPanel.test.tsx | 29 ++++- .../game/ui/GamePageMobileActionPanel.tsx | 7 +- .../game/ui/GamePageMobileAudioAction.tsx | 6 +- .../ui/GamePageMobileCanvasStage.test.tsx | 10 ++ .../ui/GamePageMobileLeaderboardAction.tsx | 6 +- .../game/ui/GamePageMobileSettingsAction.tsx | 6 +- .../game/ui/GamePageMobileSheetAction.tsx | 6 +- .../ui/GamePageMobileSheetContent.test.tsx | 4 + .../game/ui/GamePageMobileSheetContent.tsx | 8 +- .../ui/GamePageMobileStatechartTab.test.tsx | 7 +- .../game/ui/GamePageMobileStatechartTab.tsx | 5 +- .../game/ui/GamePageMobileTopBar.test.tsx | 12 +- src/pages/game/ui/GamePageMobileTopBar.tsx | 6 +- .../game/ui/GamePagePortraitGate.test.tsx | 46 ++++++++ src/pages/game/ui/GamePagePortraitGate.tsx | 63 ++++++----- src/shared/ui/dialog.tsx | 4 +- src/shared/ui/sheet.tsx | 4 +- src/shared/ui/slider.tsx | 2 +- src/shared/ui/switch.tsx | 2 +- .../ui/CameraModeSwitcher.tsx | 13 ++- .../ui/MobileCameraModeSwitcher.test.tsx | 29 +++++ .../ui/MobileCameraModeSwitcher.tsx | 3 +- src/widgets/hud/config/hudConfig.ts | 10 +- src/widgets/hud/ui/GameHud.tsx | 2 +- .../hud/ui/GameHudActionsSection.test.tsx | 43 ++++++++ src/widgets/hud/ui/GameHudActionsSection.tsx | 3 +- src/widgets/hud/ui/GameHudSnapshotSection.tsx | 2 +- .../ui/LeaderboardPanelContent.tsx | 14 +-- .../ui/LeaderboardSheet.test.tsx | 22 +++- .../leaderboard-panel/ui/LeaderboardSheet.tsx | 6 +- .../settings-panel/ui/SettingsPanel.test.tsx | 28 ++--- .../ui/SettingsPanelGraphicsSection.tsx | 7 +- .../ui/SettingsPanelHapticsSection.tsx | 7 +- .../ui/SettingsPanelResetAction.tsx | 2 +- .../settings-panel/ui/SettingsSheet.test.tsx | 6 +- .../settings-panel/ui/SettingsSheet.tsx | 6 +- .../config/inspectorGraphConfig.ts | 20 ++-- .../guardMarkerEdgeLayoutViewModel.test.ts | 64 +++++++++++ .../lib/guardMarkerEdgeLayoutViewModel.ts | 34 +++--- .../lib/reactFlowGraphMappers.test.ts | 104 ++++++++++++++++++ .../lib/reactFlowGraphMappers.ts | 17 +-- .../model/useGuardMarkerEdgeLayout.test.ts | 52 +++++++++ .../ui/XStateInspectorDetailsPanel.tsx | 7 +- ...tateInspectorDetailsPanelStatesSection.tsx | 8 +- .../ui/XStateInspectorPanel.tsx | 65 ++++++++--- .../ui/XStateInspectorPanelFlow.tsx | 10 +- .../ui/XStateInspectorPanelGuards.tsx | 8 +- .../ui/XStateInspectorPanelHeader.tsx | 10 +- .../ui/XStateInspectorPanelTabs.tsx | 38 +++---- 61 files changed, 790 insertions(+), 232 deletions(-) create mode 100644 src/pages/game/ui/GamePagePortraitGate.test.tsx create mode 100644 src/widgets/camera-mode-switcher/ui/MobileCameraModeSwitcher.test.tsx create mode 100644 src/widgets/hud/ui/GameHudActionsSection.test.tsx diff --git a/src/features/input-orchestrator/config/mobileActionButtonLayoutConfig.ts b/src/features/input-orchestrator/config/mobileActionButtonLayoutConfig.ts index 29729fc6..c9666ec7 100644 --- a/src/features/input-orchestrator/config/mobileActionButtonLayoutConfig.ts +++ b/src/features/input-orchestrator/config/mobileActionButtonLayoutConfig.ts @@ -1,6 +1,6 @@ export const MOBILE_ACTION_BUTTON_LAYOUT_CLASS_NAMES = { ROOT: "pointer-events-auto flex flex-col gap-2 touch-none select-none", - BUTTON: "h-12 w-12 rounded-full p-0 shadow-lg backdrop-blur-md", + BUTTON: "size-11 rounded-full p-0 shadow-lg backdrop-blur-md", ICON: "h-5 w-5", } as const; diff --git a/src/features/input-orchestrator/ui/MobileActionButtonZone.test.tsx b/src/features/input-orchestrator/ui/MobileActionButtonZone.test.tsx index d3bb4801..d78ef157 100644 --- a/src/features/input-orchestrator/ui/MobileActionButtonZone.test.tsx +++ b/src/features/input-orchestrator/ui/MobileActionButtonZone.test.tsx @@ -59,6 +59,8 @@ describe("MobileActionButtonZone", () => { expect(runButton.className).toBe( MOBILE_ACTION_BUTTON_LAYOUT_CLASS_NAMES.BUTTON, ); + expect(runButton.className).toContain("size-11"); + expect(runButton.className).not.toMatch(/h-12|w-12/); expect(zoneRoot.className).toBe( MOBILE_ACTION_BUTTON_LAYOUT_CLASS_NAMES.ROOT, ); diff --git a/src/features/settings/config/settingsConfig.ts b/src/features/settings/config/settingsConfig.ts index 0794b359..96c03fba 100644 --- a/src/features/settings/config/settingsConfig.ts +++ b/src/features/settings/config/settingsConfig.ts @@ -19,7 +19,7 @@ export const SETTINGS_STORAGE_KEYS = { export const SETTINGS_COPY = { PAGE_TITLE: "Settings", - PAGE_DESCRIPTION: "Adjust audio levels and haptic feedback.", + PAGE_DESCRIPTION: "Tune audio, rendering, and haptic feedback for your run.", AUDIO_SECTION: "Audio", HAPTICS_SECTION: "Haptics", MASTER_VOLUME_LABEL: "Master Volume", diff --git a/src/pages/game/config/index.ts b/src/pages/game/config/index.ts index a45fe623..3c0b32a9 100644 --- a/src/pages/game/config/index.ts +++ b/src/pages/game/config/index.ts @@ -9,16 +9,17 @@ export { GAME_PAGE_CONTROLS } from "./gamePageControls"; export const GAME_PAGE_MOBILE_SHEET = { HEIGHT_DVH: 90, + STATECHART_MIN_ZOOM: 1, OPEN_BUTTON_LABEL: "Panels", - TITLE: "Game Surfaces", - DESCRIPTION: "Open the state visualizer and HUD panels.", + TITLE: "Dungeon Observatory", + DESCRIPTION: "Inspect the live machine and run telemetry.", TAB_IDS: { STATECHART: "statechart", HUD: "hud", }, TAB_LABELS: { - STATECHART: "Statechart", - HUD: "HUD", + STATECHART: "Runtime Map", + HUD: "Run Telemetry", }, } as const; @@ -26,6 +27,7 @@ export const GAME_PAGE_PORTRAIT_GATE = { TITLE: "Rotate Device", DESCRIPTION: "Landscape mode is required on mobile and tablet.", BODY: "Rotate your device to landscape to continue playing.", + HOME_ACTION_LABEL: "Return to landing page", } as const; export const GAME_PAGE_SCROLL_LOCK = { @@ -35,15 +37,17 @@ export const GAME_PAGE_SCROLL_LOCK = { export const GAME_PAGE_MOBILE_ACTION_PANEL_CLASS_NAMES = { ROOT: "pointer-events-auto relative flex shrink-0 flex-col items-end", - PROMPT_SLOT: "absolute bottom-full right-0 mb-4 flex w-40 flex-col gap-2", - COMPACT_WIDTH: "w-9", + PROMPT_SLOT: "absolute right-0 bottom-full mb-3 flex w-44 flex-col gap-2", + COMPACT_WIDTH: "w-24", TABLET_WIDTH: "w-40", - CONTROL_STACK: "flex w-full flex-col items-end gap-2", + CONTROL_STACK: "w-full items-end gap-2", + COMPACT_CONTROL_STACK: "grid grid-cols-2", + TABLET_CONTROL_STACK: "flex flex-col", } as const; export const GAME_PAGE_MOBILE_TOUCH_ACTION_PANEL_CLASS_NAMES = { ROOT: "flex w-full flex-col gap-2 empty:hidden", - BUTTON: "pointer-events-auto relative w-full font-bold", + BUTTON: "pointer-events-auto relative min-h-11 w-full font-bold", BUTTON_LABEL: "block w-full truncate text-center", INTERACT_BADGE: "absolute -top-2 -right-2 flex h-4 w-4 animate-pulse items-center justify-center rounded-full bg-dungeon-gold p-0 shadow-[0_0_8px_var(--dungeon-gold)]", @@ -78,8 +82,9 @@ export const GAME_PAGE_DESKTOP_HEADER_TEST_IDS = { } as const; export const GAME_PAGE_MOBILE_OVERLAY_CLASS_NAMES = { - ROOT: "pointer-events-none absolute right-4 bottom-4 z-30 flex items-end gap-2", - JOYSTICK_ANCHOR: "pointer-events-none absolute bottom-4 left-4 z-30", + ROOT: "pointer-events-none absolute right-[max(1rem,env(safe-area-inset-right))] bottom-[max(1rem,env(safe-area-inset-bottom))] z-30 flex items-end gap-2", + JOYSTICK_ANCHOR: + "pointer-events-none absolute bottom-[max(1rem,env(safe-area-inset-bottom))] left-[max(1rem,env(safe-area-inset-left))] z-30", JOYSTICK_INTERACTIVE_SURFACE: "pointer-events-auto", RUN_JUMP_ANCHOR: "flex items-end", RUN_JUMP_INTERACTIVE_SURFACE: "pointer-events-auto", diff --git a/src/pages/game/ui/GamePage.test.tsx b/src/pages/game/ui/GamePage.test.tsx index ae5d1cbe..8925bdd6 100644 --- a/src/pages/game/ui/GamePage.test.tsx +++ b/src/pages/game/ui/GamePage.test.tsx @@ -453,6 +453,20 @@ describe("GamePage", () => { expect( screen.getByTestId("xstate-inspector-details-widget"), ).not.toBeNull(); + expect( + screen.getByRole("complementary", { name: "Statechart graph" }), + ).not.toBeNull(); + expect( + screen.getByRole("region", { name: "Dungeon viewport" }), + ).not.toBeNull(); + expect( + screen.getByRole("region", { name: "Selected machine details" }), + ).not.toBeNull(); + expect( + screen.getByRole("complementary", { + name: "Game controls and state", + }), + ).not.toBeNull(); expect( within(screen.getByRole("banner")) @@ -536,7 +550,7 @@ describe("GamePage", () => { ).not.toBeNull(); }); - it("renders rotate-device banner in touch portrait mode", () => { + it("renders an accessible rotation dialog in touch portrait mode", () => { vi.mocked(useGamePage).mockReturnValue( createGamePageViewModel({ layout: { @@ -554,7 +568,21 @@ describe("GamePage", () => { , ); - expect(screen.getByText(GAME_PAGE_PORTRAIT_GATE.TITLE)).not.toBeNull(); + const rotationDialog = screen.getByRole("alertdialog", { + name: GAME_PAGE_PORTRAIT_GATE.TITLE, + }); + + expect(rotationDialog).not.toBeNull(); + expect( + within(rotationDialog).getByText(GAME_PAGE_PORTRAIT_GATE.DESCRIPTION), + ).not.toBeNull(); + expect( + within(rotationDialog) + .getByRole("link", { + name: GAME_PAGE_PORTRAIT_GATE.HOME_ACTION_LABEL, + }) + .getAttribute("href"), + ).toBe("/"); expect(screen.getByTestId("game-canvas-widget")).not.toBeNull(); expect(screen.queryByTestId("mobile-camera-switcher-widget")).toBeNull(); expect( diff --git a/src/pages/game/ui/GamePageDesktopHeader.test.tsx b/src/pages/game/ui/GamePageDesktopHeader.test.tsx index 64bf76b1..f7227386 100644 --- a/src/pages/game/ui/GamePageDesktopHeader.test.tsx +++ b/src/pages/game/ui/GamePageDesktopHeader.test.tsx @@ -63,14 +63,18 @@ describe("GamePageDesktopHeader", () => { expect(homeAction.parentElement).toBe(actions); expect(actions.lastElementChild).toBe(homeAction); expect(homeAction.getAttribute("href")).toBe("/"); - expect(homeAction.getAttribute("data-size")).toBe("icon-sm"); + expect(homeAction.getAttribute("data-size")).toBe("icon"); expect(homeAction.getAttribute("data-variant")).toBe("dungeon-outline"); + expect(homeAction.className).toContain("size-11"); expect(homeAction.className).not.toContain("w-fit"); expect( within(root).getByRole("link", { name: "RUNESTONE", }), ).toBeTruthy(); + expect(within(root).getByText("Floor I / Live Run")).toBeTruthy(); + expect(within(root).getByText("Dungeon Observatory")).toBeTruthy(); + expect(within(root).getByText("Active room")).toBeTruthy(); expect( within(actions).getByRole("button", { name: GAME_PAGE_CONTROLS.AUDIO.MUTE_ARIA_LABEL, diff --git a/src/pages/game/ui/GamePageDesktopHeader.tsx b/src/pages/game/ui/GamePageDesktopHeader.tsx index 3360f2b1..4c02712e 100644 --- a/src/pages/game/ui/GamePageDesktopHeader.tsx +++ b/src/pages/game/ui/GamePageDesktopHeader.tsx @@ -1,12 +1,18 @@ import { Link } from "@tanstack/react-router"; -import { Trophy, Volume2, VolumeX } from "lucide-react"; +import { Activity, Trophy, Volume2, VolumeX } from "lucide-react"; import { GAME_PAGE_CONTROLS, GAME_PAGE_DESKTOP_HEADER_TEST_IDS, } from "@/pages/game/config"; import { useGamePageDesktopHeaderModel } from "@/pages/game/model"; -import { Button, Tooltip, TooltipContent, TooltipTrigger } from "@/shared/ui"; +import { + Badge, + Button, + Tooltip, + TooltipContent, + TooltipTrigger, +} from "@/shared/ui"; import { LeaderboardSheet } from "@/widgets/leaderboard-panel"; import { MARKETING_ROUTES } from "@/widgets/marketing-shell"; import { GamePageDesktopSettingsAction } from "./GamePageDesktopSettingsAction"; @@ -19,29 +25,40 @@ export function GamePageDesktopHeader() { return (
-
+
RUNESTONE - ยท - Floor I +
- - Room: + + + @@ -59,7 +76,7 @@ export function GamePageDesktopHeader() { {isAudioMuted ? ( ) : ( - + )} @@ -79,7 +96,7 @@ export function GamePageDesktopHeader() { size="icon-sm" aria-label={GAME_PAGE_CONTROLS.LEADERBOARD.ARIA_LABEL} > - + diff --git a/src/pages/game/ui/GamePageDesktopLayout.tsx b/src/pages/game/ui/GamePageDesktopLayout.tsx index 12b3a832..639a3c42 100644 --- a/src/pages/game/ui/GamePageDesktopLayout.tsx +++ b/src/pages/game/ui/GamePageDesktopLayout.tsx @@ -7,7 +7,7 @@ export function GamePageDesktopLayout() { return (
diff --git a/src/pages/game/ui/GamePageDesktopSettingsAction.tsx b/src/pages/game/ui/GamePageDesktopSettingsAction.tsx index fde98e03..03c31fc3 100644 --- a/src/pages/game/ui/GamePageDesktopSettingsAction.tsx +++ b/src/pages/game/ui/GamePageDesktopSettingsAction.tsx @@ -15,7 +15,7 @@ export function GamePageDesktopSettingsAction() { size="icon-sm" aria-label={GAME_PAGE_CONTROLS.SETTINGS.ARIA_LABEL} > - + diff --git a/src/pages/game/ui/GamePageDesktopWorkspacePanels.tsx b/src/pages/game/ui/GamePageDesktopWorkspacePanels.tsx index 32b404b1..9b36ccdf 100644 --- a/src/pages/game/ui/GamePageDesktopWorkspacePanels.tsx +++ b/src/pages/game/ui/GamePageDesktopWorkspacePanels.tsx @@ -20,22 +20,30 @@ export function GamePageDesktopWorkspacePanels() { } = useGamePageDesktopLayoutModel(); return ( -
+
-
+
-

- Dungeon Canvas -

+
+

+ Dungeon viewport +

+ + Machine synchronized + +
-
+
@@ -63,7 +71,7 @@ export function GamePageDesktopWorkspacePanels() {