import type { CSSProperties, ReactNode } from "react"; import { cn } from "~/lib/utils"; export type CoronaState = | { type: "eliminated"; points: 0 } | { type: "pending" } | { type: "scored"; brightness: number; points: number }; type CoronaVariant = | "gradient" | "electric" | "emerald" | "amber" | "coral"; interface DraftPickCellProps { pickNumber: number; round: number; pickInRound: number; state: "picked" | "current" | "upcoming"; pick?: { participant: { name: string }; sport: { name: string }; }; corona?: CoronaVariant; coronaState?: CoronaState; className?: string; children?: ReactNode; } const coronaClasses: Record = { gradient: "[background:linear-gradient(to_bottom,#adf661,#2ce1c1)]", electric: "bg-electric", emerald: "bg-emerald-500", amber: "bg-amber-accent", coral: "bg-coral-accent", }; function getCoronaStyle(cs: CoronaState): CSSProperties { switch (cs.type) { case "eliminated": return { background: "oklch(0.45 0.20 25)" }; case "pending": return { background: "rgba(255, 255, 255, 0.08)" }; case "scored": return { background: "linear-gradient(to bottom, #adf661, #2ce1c1)", opacity: cs.brightness, }; } } export function DraftPickCell({ pickNumber, round, pickInRound, state, pick, corona = "gradient", coronaState, className, children, }: DraftPickCellProps) { const showCorona = state === "picked" || (state === "upcoming" && !!coronaState); const isCurrent = state === "current"; return (
{isCurrent ? (
) : showCorona && coronaState ? (
) : showCorona ? (
) : null}
{state === "picked" && pick ? (
{pick.participant.name}
{pick.sport.name}
) : isCurrent ? (
On The Clock
) : null} {!isCurrent && (
{round}.{String(pickInRound).padStart(2, "0")}
{coronaState && coronaState.type !== "pending" && ( {coronaState.type === "scored" && "▲"}{coronaState.points} )}
)}
{children &&
{children}
}
); }