feat(minigames): make period standings the primary board on game pages
The six period-scored game pages (flappy, eod, opord, radio, qualification, call-for-fire) now render their current-period PeriodStandingsCard directly under the game board, in the slot the lifetime board used to occupy. Each game's all-time leaderboard moves below it into a collapsed AllTimeLeaderboard disclosure (shadcn Collapsible) that expands on click, so period standings are centered and primary and the lifetime board is opt-in. PeriodStandingsCard drops its period/all-time toggle and keeps the current period only, now with the presence line the pages previously omitted. The old "Anchored period standings" heading and card block are removed from the six page.tsx files. The e2e spec covers the collapsed all-time section on /minigames/flappy.
This commit is contained in:
parent
15e434998a
commit
923831ba82
15 changed files with 164 additions and 100 deletions
|
|
@ -5,7 +5,6 @@ import { headers as nextHeaders } from "next/headers";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
import { Target } from "lucide-react";
|
import { Target } from "lucide-react";
|
||||||
import { CallForFireArena } from "@/components/frontend/minigames/call-for-fire/CallForFireArena";
|
import { CallForFireArena } from "@/components/frontend/minigames/call-for-fire/CallForFireArena";
|
||||||
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
|
||||||
import { PhasingOutBanner } from "@/components/frontend/minigames/PhasingOutBanner";
|
import { PhasingOutBanner } from "@/components/frontend/minigames/PhasingOutBanner";
|
||||||
import { getMinigameReleaseState } from "@/lib/minigames/loadRegistry";
|
import { getMinigameReleaseState } from "@/lib/minigames/loadRegistry";
|
||||||
|
|
||||||
|
|
@ -68,15 +67,6 @@ export default async function CallForFirePage() {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<CallForFireArena initialStats={stats} currentUserId={user.id as number} />
|
<CallForFireArena initialStats={stats} currentUserId={user.id as number} />
|
||||||
|
|
||||||
<div className="flex flex-col gap-2">
|
|
||||||
<h2 className="text-sm font-semibold text-muted-foreground">Anchored period standings</h2>
|
|
||||||
<PeriodStandingsCard
|
|
||||||
gameKey="callForFire"
|
|
||||||
icon="Target"
|
|
||||||
currentUserId={user.id as number}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import { PhasingOutBanner } from "@/components/frontend/minigames/PhasingOutBann
|
||||||
import { getMinigameReleaseState } from "@/lib/minigames/loadRegistry";
|
import { getMinigameReleaseState } from "@/lib/minigames/loadRegistry";
|
||||||
import { Bomb } from "lucide-react";
|
import { Bomb } from "lucide-react";
|
||||||
import { EodArena } from "@/components/frontend/minigames/eod/EodArena";
|
import { EodArena } from "@/components/frontend/minigames/eod/EodArena";
|
||||||
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "Minefield Clearance (Polaris Task Force)",
|
title: "Minefield Clearance (Polaris Task Force)",
|
||||||
|
|
@ -72,11 +71,6 @@ export default async function EodPage() {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<EodArena initialStats={stats} currentUserId={user.id as number} />
|
<EodArena initialStats={stats} currentUserId={user.id as number} />
|
||||||
|
|
||||||
<div className="flex flex-col gap-2">
|
|
||||||
<h2 className="text-sm font-semibold text-muted-foreground">Anchored period standings</h2>
|
|
||||||
<PeriodStandingsCard gameKey="eod" icon="Bomb" currentUserId={user.id as number} />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import { PhasingOutBanner } from "@/components/frontend/minigames/PhasingOutBann
|
||||||
import { getMinigameReleaseState } from "@/lib/minigames/loadRegistry";
|
import { getMinigameReleaseState } from "@/lib/minigames/loadRegistry";
|
||||||
import { Bird } from "lucide-react";
|
import { Bird } from "lucide-react";
|
||||||
import { FlappyArena } from "@/components/frontend/minigames/flappy/FlappyArena";
|
import { FlappyArena } from "@/components/frontend/minigames/flappy/FlappyArena";
|
||||||
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "Flight Simulator: Polaris Task Force",
|
title: "Flight Simulator: Polaris Task Force",
|
||||||
|
|
@ -70,11 +69,6 @@ export default async function FlappyPage() {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<FlappyArena initialStats={stats} currentUserId={user.id as number} />
|
<FlappyArena initialStats={stats} currentUserId={user.id as number} />
|
||||||
|
|
||||||
<div className="flex flex-col gap-2">
|
|
||||||
<h2 className="text-sm font-semibold text-muted-foreground">Anchored period standings</h2>
|
|
||||||
<PeriodStandingsCard gameKey="flappy" icon="Bird" currentUserId={user.id as number} />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import { PhasingOutBanner } from "@/components/frontend/minigames/PhasingOutBann
|
||||||
import { getMinigameReleaseState } from "@/lib/minigames/loadRegistry";
|
import { getMinigameReleaseState } from "@/lib/minigames/loadRegistry";
|
||||||
import { ScrollText } from "lucide-react";
|
import { ScrollText } from "lucide-react";
|
||||||
import { OpordArena } from "@/components/frontend/minigames/opord/OpordArena";
|
import { OpordArena } from "@/components/frontend/minigames/opord/OpordArena";
|
||||||
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "OPORD Recall (Polaris Task Force)",
|
title: "OPORD Recall (Polaris Task Force)",
|
||||||
|
|
@ -73,11 +72,6 @@ export default async function OpordPage() {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<OpordArena initialStats={stats} currentUserId={user.id as number} />
|
<OpordArena initialStats={stats} currentUserId={user.id as number} />
|
||||||
|
|
||||||
<div className="flex flex-col gap-2">
|
|
||||||
<h2 className="text-sm font-semibold text-muted-foreground">Anchored period standings</h2>
|
|
||||||
<PeriodStandingsCard gameKey="opord" icon="FileTextIcon" currentUserId={user.id as number} />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ import { Crosshair } from "lucide-react";
|
||||||
|
|
||||||
import type { AimTrainerStats } from "@/app/(frontend)/minigames/qualification/actions";
|
import type { AimTrainerStats } from "@/app/(frontend)/minigames/qualification/actions";
|
||||||
import { AimTrainerArena } from "@/components/frontend/minigames/qualification/AimTrainerArena";
|
import { AimTrainerArena } from "@/components/frontend/minigames/qualification/AimTrainerArena";
|
||||||
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "Qualification Course: Polaris Task Force",
|
title: "Qualification Course: Polaris Task Force",
|
||||||
|
|
@ -77,11 +76,6 @@ export default async function QualificationPage() {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<AimTrainerArena initialStats={stats} currentUserId={user.id} />
|
<AimTrainerArena initialStats={stats} currentUserId={user.id} />
|
||||||
|
|
||||||
<div className="flex flex-col gap-2">
|
|
||||||
<h2 className="text-sm font-semibold text-muted-foreground">Anchored period standings</h2>
|
|
||||||
<PeriodStandingsCard gameKey="qualification" icon="Crosshair" currentUserId={user.id as number} />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import { PhasingOutBanner } from "@/components/frontend/minigames/PhasingOutBann
|
||||||
import { getMinigameReleaseState } from "@/lib/minigames/loadRegistry";
|
import { getMinigameReleaseState } from "@/lib/minigames/loadRegistry";
|
||||||
import { Radio } from "lucide-react";
|
import { Radio } from "lucide-react";
|
||||||
import { RadioArena } from "@/components/frontend/minigames/radio/RadioArena";
|
import { RadioArena } from "@/components/frontend/minigames/radio/RadioArena";
|
||||||
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "Radio Traffic (Polaris Task Force)",
|
title: "Radio Traffic (Polaris Task Force)",
|
||||||
|
|
@ -81,11 +80,6 @@ export default async function RadioPage() {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<RadioArena initialStats={stats} currentUserId={user.id as number} />
|
<RadioArena initialStats={stats} currentUserId={user.id as number} />
|
||||||
|
|
||||||
<div className="flex flex-col gap-2">
|
|
||||||
<h2 className="text-sm font-semibold text-muted-foreground">Anchored period standings</h2>
|
|
||||||
<PeriodStandingsCard gameKey="radio" icon="Radio" currentUserId={user.id as number} />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
40
src/components/frontend/minigames/AllTimeLeaderboard.tsx
Normal file
40
src/components/frontend/minigames/AllTimeLeaderboard.tsx
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
"use client";
|
||||||
|
|
||||||
|
import { ChevronDown, History } from "lucide-react";
|
||||||
|
|
||||||
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
|
export interface AllTimeLeaderboardProps {
|
||||||
|
children: React.ReactNode;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collapsed container for a game's lifetime board. The period standings stay
|
||||||
|
* the primary surface on the game page; the all-time board is opt-in.
|
||||||
|
*/
|
||||||
|
export function AllTimeLeaderboard({ children, className }: AllTimeLeaderboardProps) {
|
||||||
|
return (
|
||||||
|
<Collapsible className={cn("w-full max-w-[520px]", className)}>
|
||||||
|
<CollapsibleTrigger asChild>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="group flex w-full items-center gap-2 rounded-xl border border-border bg-card px-4 py-3 text-left text-sm font-semibold text-muted-foreground transition-colors hover:bg-accent/40 hover:text-foreground"
|
||||||
|
>
|
||||||
|
<History className="size-4" aria-hidden="true" />
|
||||||
|
<span>All-time leaderboard</span>
|
||||||
|
<span className="ml-auto text-xs font-normal group-data-[state=open]:hidden">Expand</span>
|
||||||
|
<span className="ml-auto hidden text-xs font-normal group-data-[state=open]:inline">
|
||||||
|
Collapse
|
||||||
|
</span>
|
||||||
|
<ChevronDown
|
||||||
|
className="size-4 transition-transform group-data-[state=open]:rotate-180"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
</CollapsibleTrigger>
|
||||||
|
<CollapsibleContent className="pt-2">{children}</CollapsibleContent>
|
||||||
|
</Collapsible>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState } from "react";
|
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { Trophy } from "lucide-react";
|
import { Trophy } from "lucide-react";
|
||||||
|
|
||||||
|
|
@ -22,9 +21,9 @@ export interface PeriodStandingsCardProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Period-scoped standings for a single game, embedded on the game page. Defaults
|
* Current-period standings for a single game, embedded on the game page. The
|
||||||
* to the current period and offers an All-Time toggle; the full multi-board view
|
* game's lifetime board sits below it in a collapsed all-time section; the full
|
||||||
* lives at /minigames/leaderboards.
|
* multi-board view lives at /minigames/leaderboards.
|
||||||
*/
|
*/
|
||||||
export function PeriodStandingsCard({
|
export function PeriodStandingsCard({
|
||||||
gameKey,
|
gameKey,
|
||||||
|
|
@ -34,12 +33,13 @@ export function PeriodStandingsCard({
|
||||||
presence,
|
presence,
|
||||||
className,
|
className,
|
||||||
}: PeriodStandingsCardProps) {
|
}: PeriodStandingsCardProps) {
|
||||||
const [view, setView] = useState<"period" | "all-time">("period");
|
const { data, failed, loading } = useLeaderboards("current", refreshKey);
|
||||||
const { data, failed, loading } = useLeaderboards(view === "all-time" ? "all-time" : "current", refreshKey);
|
|
||||||
|
|
||||||
const board = data?.boards.find((entry) => entry.key === gameKey) ?? null;
|
const board = data?.boards.find((entry) => entry.key === gameKey) ?? null;
|
||||||
const Icon = minigameIcon(icon ?? board?.icon);
|
const Icon = minigameIcon(icon ?? board?.icon);
|
||||||
const isAllTime = view === "all-time";
|
const presenceNoun = presence?.noun ?? "operator";
|
||||||
|
const presenceLabel =
|
||||||
|
presence && presence.participants.length === 1 ? presenceNoun : `${presenceNoun}s`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cn("w-full max-w-[420px] rounded-xl border border-border bg-card", className)}>
|
<div className={cn("w-full max-w-[420px] rounded-xl border border-border bg-card", className)}>
|
||||||
|
|
@ -48,43 +48,27 @@ export function PeriodStandingsCard({
|
||||||
<Icon className="size-4 text-muted-foreground" />
|
<Icon className="size-4 text-muted-foreground" />
|
||||||
<h2 className="truncate text-sm font-semibold">{board?.label ?? "Standings"}</h2>
|
<h2 className="truncate text-sm font-semibold">{board?.label ?? "Standings"}</h2>
|
||||||
<span className="ml-auto shrink-0 text-xs text-muted-foreground">
|
<span className="ml-auto shrink-0 text-xs text-muted-foreground">
|
||||||
{isAllTime ? "All-Time" : (data?.period?.label ?? "No active period")}
|
{data?.period?.label ?? "No active period"}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center gap-1 border-b border-border px-2 py-1.5">
|
<div className="flex items-center gap-2 border-b border-border px-4 py-2 text-xs text-muted-foreground">
|
||||||
<button
|
<span>Best run this period · placement points</span>
|
||||||
type="button"
|
|
||||||
onClick={() => setView("period")}
|
|
||||||
className={cn(
|
|
||||||
"rounded-md px-2.5 py-1 text-xs font-medium",
|
|
||||||
!isAllTime ? "bg-accent text-foreground" : "text-muted-foreground hover:text-foreground",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
This period
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
onClick={() => setView("all-time")}
|
|
||||||
className={cn(
|
|
||||||
"rounded-md px-2.5 py-1 text-xs font-medium",
|
|
||||||
isAllTime ? "bg-accent text-foreground" : "text-muted-foreground hover:text-foreground",
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
All-Time
|
|
||||||
</button>
|
|
||||||
<Link
|
<Link
|
||||||
href={`/minigames/leaderboards?game=${gameKey}`}
|
href={`/minigames/leaderboards?game=${gameKey}`}
|
||||||
className="ml-auto py-1 pr-1 text-xs text-muted-foreground hover:text-foreground"
|
className="ml-auto shrink-0 py-1 text-xs text-muted-foreground hover:text-foreground"
|
||||||
>
|
>
|
||||||
All boards
|
All boards
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{presence && !isAllTime && (
|
{presence && (
|
||||||
<div className="border-b border-border px-4 py-2 text-xs text-muted-foreground" aria-live="polite">
|
<div
|
||||||
|
className="border-b border-border px-4 py-2 text-xs text-muted-foreground"
|
||||||
|
aria-live="polite"
|
||||||
|
>
|
||||||
<span className="font-medium text-emerald-400">{presence.participants.length}</span>{" "}
|
<span className="font-medium text-emerald-400">{presence.participants.length}</span>{" "}
|
||||||
{presence.participants.length === 1 ? `${presence.noun ?? "operator"} is` : `${presence.noun ?? "operators"} are`} active now
|
{presenceLabel} {presence.participants.length === 1 ? "is" : "are"} active now
|
||||||
{presence.participants.length > 0 && (
|
{presence.participants.length > 0 && (
|
||||||
<span className="ml-1 text-foreground">
|
<span className="ml-1 text-foreground">
|
||||||
({presence.participants.map((participant) => participant.name).join(", ")})
|
({presence.participants.map((participant) => participant.name).join(", ")})
|
||||||
|
|
@ -106,8 +90,8 @@ export function PeriodStandingsCard({
|
||||||
rows={board?.rows ?? []}
|
rows={board?.rows ?? []}
|
||||||
scoreLabel={board?.scoreLabel ?? "Score"}
|
scoreLabel={board?.scoreLabel ?? "Score"}
|
||||||
currentUserId={currentUserId}
|
currentUserId={currentUserId}
|
||||||
showPoints={!isAllTime}
|
showPoints
|
||||||
emptyLabel={isAllTime ? "No all-time runs yet." : "No runs this period yet. Be the first!"}
|
emptyLabel="No runs this period yet. Be the first!"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ import type {
|
||||||
} from "@/app/(frontend)/minigames/call-for-fire/actions";
|
} from "@/app/(frontend)/minigames/call-for-fire/actions";
|
||||||
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
|
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
|
||||||
import { useSidebar } from "@/components/ui/sidebar";
|
import { useSidebar } from "@/components/ui/sidebar";
|
||||||
|
import { AllTimeLeaderboard } from "@/components/frontend/minigames/AllTimeLeaderboard";
|
||||||
|
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
||||||
import { CallForFireLeaderboard } from "./CallForFireLeaderboard";
|
import { CallForFireLeaderboard } from "./CallForFireLeaderboard";
|
||||||
import { FireMissionBoard } from "./FireMissionBoard";
|
import { FireMissionBoard } from "./FireMissionBoard";
|
||||||
|
|
||||||
|
|
@ -38,6 +40,15 @@ export function CallForFireArena({
|
||||||
onPhaseChange={onPhaseChange}
|
onPhaseChange={onPhaseChange}
|
||||||
onDifficultyChange={setSelectedDifficulty}
|
onDifficultyChange={setSelectedDifficulty}
|
||||||
/>
|
/>
|
||||||
|
<PeriodStandingsCard
|
||||||
|
gameKey="callForFire"
|
||||||
|
icon="Target"
|
||||||
|
refreshKey={refreshKey}
|
||||||
|
currentUserId={currentUserId}
|
||||||
|
presence={{ participants: activeTeams, noun: "team" }}
|
||||||
|
className="max-w-[520px]"
|
||||||
|
/>
|
||||||
|
<AllTimeLeaderboard>
|
||||||
<CallForFireLeaderboard
|
<CallForFireLeaderboard
|
||||||
refreshKey={refreshKey}
|
refreshKey={refreshKey}
|
||||||
currentUserId={currentUserId}
|
currentUserId={currentUserId}
|
||||||
|
|
@ -45,6 +56,7 @@ export function CallForFireArena({
|
||||||
difficulty={selectedDifficulty}
|
difficulty={selectedDifficulty}
|
||||||
onDifficultyChange={setSelectedDifficulty}
|
onDifficultyChange={setSelectedDifficulty}
|
||||||
/>
|
/>
|
||||||
|
</AllTimeLeaderboard>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ import type { EodDifficulty, EodStats } from "@/app/(frontend)/minigames/eod/act
|
||||||
import { isEodUnlocked } from "@/lib/minigames/custom/eod";
|
import { isEodUnlocked } from "@/lib/minigames/custom/eod";
|
||||||
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
|
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
|
||||||
import { useSidebar } from "@/components/ui/sidebar";
|
import { useSidebar } from "@/components/ui/sidebar";
|
||||||
|
import { AllTimeLeaderboard } from "@/components/frontend/minigames/AllTimeLeaderboard";
|
||||||
|
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
||||||
import { UnlockNotice } from "@/components/frontend/minigames/UnlockNotice";
|
import { UnlockNotice } from "@/components/frontend/minigames/UnlockNotice";
|
||||||
import { UgcLinkButton } from "@/components/frontend/minigames/UgcLinkButton";
|
import { UgcLinkButton } from "@/components/frontend/minigames/UgcLinkButton";
|
||||||
import { EodLeaderboard } from "./EodLeaderboard";
|
import { EodLeaderboard } from "./EodLeaderboard";
|
||||||
|
|
@ -64,6 +66,15 @@ export function EodArena({
|
||||||
onPhaseChange={onPhaseChange}
|
onPhaseChange={onPhaseChange}
|
||||||
onDifficultyChange={setSelectedDifficulty}
|
onDifficultyChange={setSelectedDifficulty}
|
||||||
/>
|
/>
|
||||||
|
<PeriodStandingsCard
|
||||||
|
gameKey="eod"
|
||||||
|
icon="Bomb"
|
||||||
|
refreshKey={refreshKey}
|
||||||
|
currentUserId={currentUserId}
|
||||||
|
presence={{ participants: activeTeams, noun: "team" }}
|
||||||
|
className="max-w-[520px]"
|
||||||
|
/>
|
||||||
|
<AllTimeLeaderboard>
|
||||||
<EodLeaderboard
|
<EodLeaderboard
|
||||||
refreshKey={refreshKey}
|
refreshKey={refreshKey}
|
||||||
currentUserId={currentUserId}
|
currentUserId={currentUserId}
|
||||||
|
|
@ -71,6 +82,7 @@ export function EodArena({
|
||||||
difficulty={selectedDifficulty}
|
difficulty={selectedDifficulty}
|
||||||
onDifficultyChange={setSelectedDifficulty}
|
onDifficultyChange={setSelectedDifficulty}
|
||||||
/>
|
/>
|
||||||
|
</AllTimeLeaderboard>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
import { useCallback, useState } from "react";
|
import { useCallback, useState } from "react";
|
||||||
import type { FlappyStats } from "@/app/(frontend)/minigames/flappy/actions";
|
import type { FlappyStats } from "@/app/(frontend)/minigames/flappy/actions";
|
||||||
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
|
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
|
||||||
|
import { AllTimeLeaderboard } from "@/components/frontend/minigames/AllTimeLeaderboard";
|
||||||
|
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
||||||
import { FlappyBird } from "./FlappyBird";
|
import { FlappyBird } from "./FlappyBird";
|
||||||
import { FlappyLeaderboard } from "./FlappyLeaderboard";
|
import { FlappyLeaderboard } from "./FlappyLeaderboard";
|
||||||
|
|
||||||
|
|
@ -24,7 +26,16 @@ export function FlappyArena({
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col items-center gap-6">
|
<div className="flex flex-col items-center gap-6">
|
||||||
<FlappyBird initialStats={initialStats} onGameRecorded={() => setRefreshKey((k) => k + 1)} onPhaseChange={onPhaseChange} />
|
<FlappyBird initialStats={initialStats} onGameRecorded={() => setRefreshKey((k) => k + 1)} onPhaseChange={onPhaseChange} />
|
||||||
|
<PeriodStandingsCard
|
||||||
|
gameKey="flappy"
|
||||||
|
icon="Bird"
|
||||||
|
refreshKey={refreshKey}
|
||||||
|
currentUserId={currentUserId}
|
||||||
|
presence={{ participants: activePilots, noun: "pilot" }}
|
||||||
|
/>
|
||||||
|
<AllTimeLeaderboard className="max-w-[420px]">
|
||||||
<FlappyLeaderboard refreshKey={refreshKey} currentUserId={currentUserId} activePilots={activePilots} />
|
<FlappyLeaderboard refreshKey={refreshKey} currentUserId={currentUserId} activePilots={activePilots} />
|
||||||
|
</AllTimeLeaderboard>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import { OPORD_DIFFICULTIES, type OpordDifficulty } from "@/lib/minigames/opord-
|
||||||
import type { OpordStats } from "@/app/(frontend)/minigames/opord/actions";
|
import type { OpordStats } from "@/app/(frontend)/minigames/opord/actions";
|
||||||
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
|
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
|
||||||
import { useSidebar } from "@/components/ui/sidebar";
|
import { useSidebar } from "@/components/ui/sidebar";
|
||||||
|
import { AllTimeLeaderboard } from "@/components/frontend/minigames/AllTimeLeaderboard";
|
||||||
|
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
||||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
@ -158,12 +160,22 @@ export function OpordArena({
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
<PeriodStandingsCard
|
||||||
|
gameKey="opord"
|
||||||
|
icon="FileTextIcon"
|
||||||
|
refreshKey={refreshKey}
|
||||||
|
currentUserId={currentUserId}
|
||||||
|
presence={{ participants: activeOperators, noun: "operator" }}
|
||||||
|
className="max-w-3xl"
|
||||||
|
/>
|
||||||
|
<AllTimeLeaderboard className="max-w-3xl">
|
||||||
<OpordLeaderboard
|
<OpordLeaderboard
|
||||||
refreshKey={refreshKey}
|
refreshKey={refreshKey}
|
||||||
difficulty={difficulty}
|
difficulty={difficulty}
|
||||||
currentUserId={currentUserId}
|
currentUserId={currentUserId}
|
||||||
activeOperators={activeOperators}
|
activeOperators={activeOperators}
|
||||||
/>
|
/>
|
||||||
|
</AllTimeLeaderboard>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ import {
|
||||||
import type { AimTrainerStats } from "@/app/(frontend)/minigames/qualification/actions";
|
import type { AimTrainerStats } from "@/app/(frontend)/minigames/qualification/actions";
|
||||||
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
|
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
|
||||||
import { useSidebar } from "@/components/ui/sidebar";
|
import { useSidebar } from "@/components/ui/sidebar";
|
||||||
|
import { AllTimeLeaderboard } from "@/components/frontend/minigames/AllTimeLeaderboard";
|
||||||
|
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
||||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
@ -170,12 +172,22 @@ export function AimTrainerArena({
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
<PeriodStandingsCard
|
||||||
|
gameKey="qualification"
|
||||||
|
icon="Crosshair"
|
||||||
|
refreshKey={refreshKey}
|
||||||
|
currentUserId={currentUserId}
|
||||||
|
presence={{ participants: activeTrainees, noun: "trainee" }}
|
||||||
|
className="max-w-3xl"
|
||||||
|
/>
|
||||||
|
<AllTimeLeaderboard className="max-w-3xl">
|
||||||
<AimTrainerLeaderboard
|
<AimTrainerLeaderboard
|
||||||
refreshKey={refreshKey}
|
refreshKey={refreshKey}
|
||||||
difficulty={difficulty}
|
difficulty={difficulty}
|
||||||
currentUserId={currentUserId}
|
currentUserId={currentUserId}
|
||||||
activeTrainees={activeTrainees}
|
activeTrainees={activeTrainees}
|
||||||
/>
|
/>
|
||||||
|
</AllTimeLeaderboard>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ import {
|
||||||
WATCH_ACCURACY_REQUIREMENT,
|
WATCH_ACCURACY_REQUIREMENT,
|
||||||
} from "@/lib/minigames/custom/radio";
|
} from "@/lib/minigames/custom/radio";
|
||||||
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
|
import { useRealtimePresence } from "@/hooks/useRealtimePresence";
|
||||||
|
import { AllTimeLeaderboard } from "@/components/frontend/minigames/AllTimeLeaderboard";
|
||||||
|
import { PeriodStandingsCard } from "@/components/frontend/minigames/PeriodStandingsCard";
|
||||||
import { UnlockNotice } from "@/components/frontend/minigames/UnlockNotice";
|
import { UnlockNotice } from "@/components/frontend/minigames/UnlockNotice";
|
||||||
import { UgcLinkButton } from "@/components/frontend/minigames/UgcLinkButton";
|
import { UgcLinkButton } from "@/components/frontend/minigames/UgcLinkButton";
|
||||||
import { RadioLeaderboard } from "./RadioLeaderboard";
|
import { RadioLeaderboard } from "./RadioLeaderboard";
|
||||||
|
|
@ -90,6 +92,15 @@ export function RadioArena({
|
||||||
<li>The lifetime leaderboard ranks Top Score, Top Accuracy, Fastest Sprint, and Most Messages.</li>
|
<li>The lifetime leaderboard ranks Top Score, Top Accuracy, Fastest Sprint, and Most Messages.</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<PeriodStandingsCard
|
||||||
|
gameKey="radio"
|
||||||
|
icon="Radio"
|
||||||
|
refreshKey={refreshKey}
|
||||||
|
currentUserId={currentUserId}
|
||||||
|
presence={{ participants: activeOperators, noun: "operator" }}
|
||||||
|
className="max-w-[520px]"
|
||||||
|
/>
|
||||||
|
<AllTimeLeaderboard>
|
||||||
<RadioLeaderboard
|
<RadioLeaderboard
|
||||||
refreshKey={refreshKey}
|
refreshKey={refreshKey}
|
||||||
mode={mode}
|
mode={mode}
|
||||||
|
|
@ -97,6 +108,7 @@ export function RadioArena({
|
||||||
currentUserId={currentUserId}
|
currentUserId={currentUserId}
|
||||||
activeOperators={activeOperators}
|
activeOperators={activeOperators}
|
||||||
/>
|
/>
|
||||||
|
</AllTimeLeaderboard>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ import { expect, test } from "@playwright/test";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smoke coverage for the unified minigames leaderboards: the period view, the
|
* Smoke coverage for the unified minigames leaderboards: the period view, the
|
||||||
* All-Time switch (which also reveals the cardtable games) and the inline period
|
* All-Time switch (which also reveals the cardtable games) and the period
|
||||||
* standings card on a game page.
|
* standings card plus collapsed all-time board on a game page.
|
||||||
*/
|
*/
|
||||||
test.describe("Minigame leaderboards", () => {
|
test.describe("Minigame leaderboards", () => {
|
||||||
test.beforeEach(async ({ page }) => {
|
test.beforeEach(async ({ page }) => {
|
||||||
|
|
@ -37,12 +37,21 @@ test.describe("Minigame leaderboards", () => {
|
||||||
await expect(page.getByRole("tab", { name: "Blackjack" })).toBeVisible();
|
await expect(page.getByRole("tab", { name: "Blackjack" })).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("a game page shows its anchored period standings card", async ({ page }) => {
|
test("a game page centers period standings with all-time collapsed", async ({ page }) => {
|
||||||
await page.goto("/minigames/flappy");
|
await page.goto("/minigames/flappy");
|
||||||
|
|
||||||
await expect(
|
|
||||||
page.getByRole("heading", { level: 2, name: "Anchored period standings" }),
|
|
||||||
).toBeVisible();
|
|
||||||
await expect(page.getByRole("link", { name: "All boards" })).toBeVisible();
|
await expect(page.getByRole("link", { name: "All boards" })).toBeVisible();
|
||||||
|
|
||||||
|
const allTime = page.getByRole("button", { name: /All-time leaderboard/ });
|
||||||
|
await expect(allTime).toBeVisible();
|
||||||
|
await expect(allTime).toHaveAttribute("data-state", "closed");
|
||||||
|
await expect(page.getByText("Flight Simulator Leaderboard")).toHaveCount(0);
|
||||||
|
|
||||||
|
// The dev-server first navigation can hydrate slowly, so retry the toggle
|
||||||
|
// until the collapsed board actually mounts.
|
||||||
|
await expect(async () => {
|
||||||
|
await allTime.click();
|
||||||
|
await expect(page.getByText("Flight Simulator Leaderboard")).toBeVisible({ timeout: 1000 });
|
||||||
|
}).toPass({ timeout: 20_000 });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue