import { forwardRef, type CSSProperties, type ComponentPropsWithoutRef } from "react"; import { cn } from "~/lib/utils"; import type { SeasonStatus } from "~/models/season"; import { BRACKT_GRADIENT } from "~/lib/brand"; export type { CoronaState } from "~/lib/corona-states"; import type { CoronaState } from "~/lib/corona-states"; type CoronaVariant = | "gradient" | "electric" | "emerald" | "amber" | "coral"; type DraftPickCellProps = ComponentPropsWithoutRef<"div"> & { pickNumber: number; round: number; pickInRound: number; state: "picked" | "current" | "upcoming"; pick?: { participant: { name: string }; sport: { name: string }; }; corona?: CoronaVariant; coronaState?: CoronaState; seasonStatus?: SeasonStatus; draftPaused?: boolean; isOvernightPause?: boolean; resumesAt?: Date; }; const coronaClasses: Record = { gradient: "[background:var(--brackt-gradient)]", 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: BRACKT_GRADIENT, opacity: cs.brightness, }; } } export const DraftPickCell = forwardRef( function DraftPickCell({ pickNumber, round, pickInRound, state, pick, corona = "gradient", coronaState, seasonStatus, draftPaused, isOvernightPause, resumesAt, className, children, ...rest }, ref) { const isCurrent = state === "current"; const showCorona = !isCurrent; let currentLabel = "On The Clock"; if (seasonStatus === "pre_draft") { currentLabel = "Up Next"; } else if (seasonStatus === "draft" && isOvernightPause) { currentLabel = "🌙 Overnight Pause"; } else if (seasonStatus === "draft" && draftPaused) { currentLabel = "Paused Draft"; } return (
{isCurrent ? (
) : coronaState ? (
) : state === "picked" ? (
) : state === "upcoming" ? (
) : null}
{!isCurrent && (
{round}.{String(pickInRound).padStart(2, "0")}
{coronaState && coronaState.type !== "pending" && ( {coronaState.type === "scored" && "â–²"}{coronaState.points} )}
)} {state === "picked" && pick ? ( <>
{pick.participant.name}
{pick.sport.name}
) : isCurrent ? ( <>
{currentLabel}
{resumesAt && (
Resumes {resumesAt.toLocaleTimeString(undefined, { hour: "numeric", minute: "2-digit" })}
)} ) : null}
{children &&
{children}
}
); }); DraftPickCell.displayName = "DraftPickCell";