From b2be7d179acc9edf84fbbc3b267ad7dcb9a45973 Mon Sep 17 00:00:00 2001 From: Vighnesh Brahme Date: Thu, 19 Dec 2024 17:50:25 +0530 Subject: [PATCH] add player lost color on nameplates --- src/components/Arbiter/Arbiter.tsx | 2 +- src/components/ChessWrapper/ChessWrapper.tsx | 88 ++++++++++++-------- 2 files changed, 54 insertions(+), 36 deletions(-) diff --git a/src/components/Arbiter/Arbiter.tsx b/src/components/Arbiter/Arbiter.tsx index 421dd70..f1659d8 100644 --- a/src/components/Arbiter/Arbiter.tsx +++ b/src/components/Arbiter/Arbiter.tsx @@ -185,7 +185,7 @@ export default function Arbiter() { - + { + if (lostTeams.includes(playerId)) return 'lost' + return currentPlayer === playerId ? 'active' : 'inactive' + } - const displayBgColor = players.find((p) => p.id === currentPlayer)?.color || "grey"; - const lostPlayerColor = "#eeeeee"; + const displayBgColor = players.find((p) => p.id === currentPlayer)?.color || 'grey'; return ( -
-
-
+
+
+
{players.find((p) => p.id === currentPlayer)?.name}
-
-
+
+
-
-
+
+
-
{children}
-
+
{children}
+
-
+
@@ -66,19 +75,28 @@ export default function ChessWrapper({ } interface PlayerPanelProps { - name: string; - color: string; - isActive: boolean; + name: string + color: string + playerState: PlayerState } /** Player panel component, holds player name and indicates active player */ -function PlayerPanel({ name, color, isActive }: PlayerPanelProps) { +function PlayerPanel({ name, color, playerState }: PlayerPanelProps) { + const stateToColorMap = { + active: color, + inactive: 'grey', + lost: '#444', + } + return (
-
{name}
+
{`${name} ${playerState === 'lost' ? 'lost' : ''}`}
) }