From f17d2a3250bbb066e32c96e8994ad6a3c0576e45 Mon Sep 17 00:00:00 2001 From: Chris Parsons Date: Thu, 16 Apr 2026 20:46:00 -0700 Subject: [PATCH] Create draft cell component. --- app/components/DraftGrid.tsx | 54 +++---- app/components/__tests__/DraftGrid.test.tsx | 2 +- app/components/draft/DraftGridSection.tsx | 79 +++++----- .../draft/DraftPickCell.stories.tsx | 136 ++++++++++++++++++ app/components/draft/DraftPickCell.tsx | 89 ++++++++++++ 5 files changed, 279 insertions(+), 81 deletions(-) create mode 100644 app/components/draft/DraftPickCell.stories.tsx create mode 100644 app/components/draft/DraftPickCell.tsx diff --git a/app/components/DraftGrid.tsx b/app/components/DraftGrid.tsx index 71c30f0..b99c2d3 100644 --- a/app/components/DraftGrid.tsx +++ b/app/components/DraftGrid.tsx @@ -1,10 +1,10 @@ -import { Card } from "~/components/ui/card"; import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger, } from "~/components/ui/context-menu"; +import { DraftPickCell } from "~/components/draft/DraftPickCell"; interface DraftCell { pickNumber: number; @@ -52,7 +52,7 @@ export function DraftGrid({ const totalTeams = draftSlots.length; return ( - +
{title &&

{title}

}
@@ -108,43 +108,30 @@ export function DraftGrid({ const actualIndex = isEvenRound ? roundPicks.length - 1 - index : index; - const slot = draftSlots[actualIndex]; const pickNumber = roundIndex * totalTeams + actualIndex + 1; const isCurrent = pickNumber === currentPick; const isPicked = !!cell; const cellContent = ( -
-
- {round}.{String(actualIndex + 1).padStart(2, "0")} -
- {isPicked ? ( -
-
- {cell.participant.name} -
-
- {cell.sport.name} -
-
- ) : isCurrent ? ( -
- On Clock -
- ) : null} -
+ ); - // Wrap with context menu if commissioner and current unpicked cell if ( isCommissioner && !isPicked && @@ -152,6 +139,7 @@ export function DraftGrid({ onForceAutopick && onForceManualPick ) { + const slot = draftSlots[actualIndex]; return ( @@ -185,6 +173,6 @@ export function DraftGrid({
-
+ ); } diff --git a/app/components/__tests__/DraftGrid.test.tsx b/app/components/__tests__/DraftGrid.test.tsx index 4c80d46..ea123ec 100644 --- a/app/components/__tests__/DraftGrid.test.tsx +++ b/app/components/__tests__/DraftGrid.test.tsx @@ -90,7 +90,7 @@ describe('DraftGrid Component', () => { const currentPickCell = screen.getByText('On Clock').parentElement; expect(currentPickCell).toHaveClass('border-electric'); - expect(currentPickCell).toHaveClass('bg-electric/15'); + expect(currentPickCell).toHaveClass('bg-electric/20'); }); }); diff --git a/app/components/draft/DraftGridSection.tsx b/app/components/draft/DraftGridSection.tsx index 6e6602c..462bda6 100644 --- a/app/components/draft/DraftGridSection.tsx +++ b/app/components/draft/DraftGridSection.tsx @@ -14,6 +14,7 @@ import { import { Button } from "~/components/ui/button"; import { MoreVertical } from "lucide-react"; import { formatClockTime, getTimerColorClass } from "~/lib/draft-timer"; +import { DraftPickCell } from "~/components/draft/DraftPickCell"; type MobileSheetData = | { type: "team"; teamId: string } @@ -180,37 +181,14 @@ export const DraftGridSection = memo(function DraftGridSection({ {displayPicks.map((cell) => { const isCurrent = cell.pickNumber === currentPick; const isPicked = !!cell.pick; + const cellState = isPicked ? "picked" : isCurrent ? "current" : "upcoming"; + const pickData = cell.pick + ? { participant: { name: cell.pick.participant.name }, sport: { name: cell.pick.sport.name } } + : undefined; - const cellClassName = `relative flex-1 min-w-32 h-20 border-2 rounded-lg p-2 transition-all ${ - isCurrent - ? "border-electric bg-electric/20 shadow-lg shadow-electric/25 ring-1 ring-electric/40" - : isPicked - ? "bg-emerald-500/10 border-emerald-500/30" - : "border-border bg-card" - }`; - - const cellInner = ( + const mobileButtons = isCommissioner && ( <> -
- {cell.round}. - {String(cell.pickInRound).padStart(2, "0")} -
- {isPicked ? ( -
-
- {cell.pick?.participant.name} -
-
- {cell.pick?.sport.name} -
-
- ) : isCurrent ? ( -
- On Clock -
- ) : null} - {/* Mobile commissioner button */} - {isCommissioner && !isPicked && isCurrent && ( + {!isPicked && isCurrent && ( )} - {isCommissioner && isPicked && (onReplacePick || onRollbackToPick) && ( + {isPicked && (onReplacePick || onRollbackToPick) && (