1
0
Fork 0
polaris-task-force/src/components/frontend/blocks/NavMinigames.tsx
Z8MB1E 33f3f7aa75 feat(minigames): add phasing-out status with estimated removal date
Add a "phasingOut" minigame status and an `estimatedRemovalDate` field so a
game can be announced as leaving soon while staying fully playable and keeping
scoring periods (unlike retired games). Visibility is the only difference:

- Sidebar badge + tooltip (amber "Phasing out", countdown to removal) in
  NavMinigames, via new phasingOutTooltip in countdown.ts.
- In-game banner (PhasingOutBanner) on all 9 game pages, wired from
  getMinigameReleaseState (added the fetch to call-for-fire, which lacked it).
- registry.ts status union + field; loadRegistry.ts maps the field;
  config status select + estimatedRemovalDate date field added.
- Migration adds the enum value and column (idempotent); types + db schema
  regenerated.

Adds tests for visibility, round-trip, and period scoring; updates the
minigames domain guide.
2026-10-14 23:51:37 -04:00

157 lines
5.7 KiB
TypeScript

"use client";
import { ChevronRight, Gamepad2, Trophy } from "lucide-react";
import Link from "next/link";
import { minigameIcon } from "@/components/frontend/minigames/minigameIcon";
import { UpcomingCountdown } from "@/components/frontend/minigames/UpcomingCountdown";
import { phasingOutTooltip } from "@/lib/minigames/countdown";
import type { RegistryGame } from "@/lib/minigames/registry";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuGroup,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import {
SidebarMenuButton,
SidebarMenuItem,
useSidebar,
} from "@/components/ui/sidebar";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
/**
* Minigames sidebar dropdown. The groups and entries come from the minigames
* registry (resolved on the server and passed in), so retiring a game or
* reordering the list is an admin-data change, not a code change.
*
* Retired games are hidden. `upcoming` games are shown greyed out and are not
* links: they render as a plain hoverable row rather than a disabled
* `DropdownMenuItem`, because that item sets `pointer-events: none` when
* disabled, which would suppress the hover that reveals the tooltip.
* `phasingOut` games stay clickable but carry an amber "Phasing out" badge and a
* tooltip showing the optional `estimatedRemovalDate`.
*/
export function NavMinigames({ games }: { games: RegistryGame[] }) {
const { isMobile } = useSidebar();
const visible = games.filter((game) => game.status !== "retired");
const coreGames = visible.filter((game) => game.category === "core");
const multiplayerGames = visible.filter((game) => game.category === "multiplayer");
const cardtableGames = visible.filter((game) => game.category === "cardtable");
const renderGame = (game: RegistryGame) => {
const Icon = minigameIcon(game.icon);
if (game.status === "upcoming") {
return (
<Tooltip key={game.key}>
<TooltipTrigger asChild>
<div
aria-disabled="true"
className="relative flex w-full cursor-not-allowed select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm opacity-50 outline-none [&>svg]:size-4 [&>svg]:shrink-0"
>
<Icon />
<span className="truncate">{game.label}</span>
<span className="ml-auto shrink-0 text-[10px] font-normal uppercase tracking-wide">
Upcoming
</span>
</div>
</TooltipTrigger>
<TooltipContent side={isMobile ? "bottom" : "right"}>
<UpcomingCountdown estimatedReleaseDate={game.estimatedReleaseDate} variant="tooltip" />
</TooltipContent>
</Tooltip>
);
}
if (game.status === "phasingOut") {
return (
<Tooltip key={game.key}>
<TooltipTrigger asChild>
<DropdownMenuItem asChild>
<Link href={game.route}>
<Icon />
<span className="truncate">{game.label}</span>
<span className="ml-auto shrink-0 text-[10px] font-normal uppercase tracking-wide text-amber-400">
Phasing out
</span>
</Link>
</DropdownMenuItem>
</TooltipTrigger>
<TooltipContent side={isMobile ? "bottom" : "right"}>
<span>{phasingOutTooltip(game.estimatedRemovalDate)}</span>
</TooltipContent>
</Tooltip>
);
}
return (
<DropdownMenuItem key={game.key} asChild>
<Link href={game.route}>
<Icon />
{game.label}
</Link>
</DropdownMenuItem>
);
};
return (
<SidebarMenuItem>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<SidebarMenuButton size="sm">
<Gamepad2 />
<span>Minigames</span>
<ChevronRight className="ml-auto size-4 text-sidebar-foreground/50" />
</SidebarMenuButton>
</DropdownMenuTrigger>
<DropdownMenuContent
className="w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg"
side={isMobile ? "bottom" : "right"}
align="end"
sideOffset={4}
>
<DropdownMenuGroup>
<DropdownMenuLabel>Core</DropdownMenuLabel>
{coreGames.map(renderGame)}
</DropdownMenuGroup>
{multiplayerGames.length > 0 && (
<>
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuLabel className="flex flex-col">
<span>Multiplayer</span>
<span className="text-xs font-normal text-muted-foreground">
Head-to-head duels against other operators
</span>
</DropdownMenuLabel>
{multiplayerGames.map(renderGame)}
</DropdownMenuGroup>
</>
)}
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuLabel className="flex flex-col">
<span>Cardtable</span>
<span className="text-xs font-normal text-muted-foreground">Earn chips to spend by playing Core minigames!</span>
</DropdownMenuLabel>
{cardtableGames.map(renderGame)}
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuItem asChild>
<Link href="/minigames/leaderboards">
<Trophy />
Leaderboards
</Link>
</DropdownMenuItem>
</DropdownMenuGroup>
</DropdownMenuContent>
</DropdownMenu>
</SidebarMenuItem>
);
}