Phase 5 of the minigame periods feature: - Read model (lib/minigames/periods/standings.ts) that shapes period boards from the ledger (rank, placement points, names) and All-Time boards from the untouched profile aggregates into one row type. - GET /api/minigames/leaderboards: ?period=current|<id>|all-time, returning the period, the period list, the boards and the achievements honor roll. - New /minigames/leaderboards page: period selector (current, every past period, All-Time), per-game tabs, and the achievements honor roll. Core-only in period mode; every registered game in All-Time. - Shared client pieces: useLeaderboards hook, StandingsTable, PeriodStandingsCard (period by default, All-Time toggle) and AchievementsHonorRoll. - Each Core game page gains an "Anchored period standings" card so the period board is visible on the game itself; its existing all-time board and mode/difficulty selectors are untouched, and it links to the full page. (Plan said replace the inline board; keeping it preserves the per-mode selectors, so the period board is added instead. Easy to swap if you prefer.) - Ledger fetch helper extracted to lib/minigames/periods/ledger.ts. - Integration test for the period boards, the All-Time path and the honor roll.
96 lines
3.2 KiB
TypeScript
96 lines
3.2 KiB
TypeScript
"use client";
|
|
|
|
import { ChevronRight, Gamepad2, Trophy } from "lucide-react";
|
|
import Link from "next/link";
|
|
|
|
import { minigameIcon } from "@/components/frontend/minigames/minigameIcon";
|
|
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";
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
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 cardtableGames = visible.filter((game) => game.category === "cardtable");
|
|
|
|
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((game) => {
|
|
const Icon = minigameIcon(game.icon);
|
|
return (
|
|
<DropdownMenuItem key={game.key} asChild>
|
|
<Link href={game.route}>
|
|
<Icon />
|
|
{game.label}
|
|
</Link>
|
|
</DropdownMenuItem>
|
|
);
|
|
})}
|
|
</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((game) => {
|
|
const Icon = minigameIcon(game.icon);
|
|
return (
|
|
<DropdownMenuItem key={game.key} asChild>
|
|
<Link href={game.route}>
|
|
<Icon />
|
|
{game.label}
|
|
</Link>
|
|
</DropdownMenuItem>
|
|
);
|
|
})}
|
|
</DropdownMenuGroup>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuGroup>
|
|
<DropdownMenuItem asChild>
|
|
<Link href="/minigames/leaderboards">
|
|
<Trophy />
|
|
Leaderboards
|
|
</Link>
|
|
</DropdownMenuItem>
|
|
</DropdownMenuGroup>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</SidebarMenuItem>
|
|
);
|
|
}
|