Skip to content

Commit

Permalink
Update card rotation and display active player in table
Browse files Browse the repository at this point in the history
  • Loading branch information
naueramant committed May 20, 2024
1 parent ed21822 commit 46db8e9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/views/Game/components/CardInventory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const CardStack = memo((props: { size: number }) => {
opacity: 0.75,
backgroundColor: (t) =>
darken(t.palette.background.paper, (i / props.size) * 0.15),
transform: randomRotationBetween(-8, 8),
transform: randomRotationBetween(-12, 12),
}}
/>
))}
Expand Down
50 changes: 30 additions & 20 deletions src/views/Game/components/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
alpha,
Chip,
Stack,
Table,
TableBody,
Expand Down Expand Up @@ -45,27 +46,36 @@ const GameTable: FunctionComponent<GameTableProps> = () => {
<TableHead>
<TableRow>
<TableCell>Round</TableCell>
{game.players.map((player, i) => (
<TableCell
key={i}
sx={{
color:
gameMetrics.activePlayerIndex === i && !gameMetrics.done
? "primary.main"
: "text.primary",
{game.players.map((player, i) => {
const isActive =
gameMetrics.activePlayerIndex === i && !gameMetrics.done;

fontWeight:
gameMetrics.activePlayerIndex === i && !gameMetrics.done
? "bold"
: "normal",
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
}}
>
{player.username}
</TableCell>
))}
return (
<TableCell
key={i}
sx={{
color: isActive ? "primary.main" : "text.primary",

fontWeight: isActive ? "bold" : "normal",
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
}}
>
{isActive ? (
<Chip
label={player.username}
color="primary"
sx={{
borderRadius: (t) => `${t.shape.borderRadius}px `,
}}
/>
) : (
<>{player.username}</>
)}
</TableCell>
);
})}
</TableRow>
</TableHead>
<TableBody>
Expand Down

0 comments on commit 46db8e9

Please sign in to comment.