From 2a0a33ac4c54c494dab3bbf657b9298398a2ed03 Mon Sep 17 00:00:00 2001 From: Manu Artero Anguita Date: Fri, 20 Oct 2023 14:40:49 +0200 Subject: [PATCH 1/5] feat: listening to keyboard at --- src/components/draft.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/components/draft.tsx b/src/components/draft.tsx index 99e8a86..3045558 100644 --- a/src/components/draft.tsx +++ b/src/components/draft.tsx @@ -5,6 +5,7 @@ import { DraftCard } from "elements/draft-card"; import type { DeckCard, Player, Selection } from "app-domain"; import type { Card } from "services/cards"; +import { useKeyboard } from "hooks/use-keyboard"; type Props = { cards: Card[]; @@ -23,6 +24,18 @@ export function Draft({ const [player1, setPlayer1] = useState(); const [player2, setPlayer2] = useState(); + useKeyboard({ + 1: () => { + handleSelectCard(cards[0]); + }, + 2: () => { + handleSelectCard(cards[1]); + }, + 3: () => { + handleSelectCard(cards[2]); + }, + }); + const ready = player1?.card && player2?.card; const handleSelectCard = (card: Card) => { From 36b35a74cd4e8a52bbc1c94af6b52ff9ad14ac0b Mon Sep 17 00:00:00 2001 From: Manu Artero Anguita Date: Fri, 20 Oct 2023 14:51:22 +0200 Subject: [PATCH 2/5] fix: Draft - alternate players. --- src/components/draft.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/draft.tsx b/src/components/draft.tsx index 3045558..b07e721 100644 --- a/src/components/draft.tsx +++ b/src/components/draft.tsx @@ -1,6 +1,6 @@ import c from "classnames"; import { ReadyButton } from "elements/ready-button"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { DraftCard } from "elements/draft-card"; import type { DeckCard, Player, Selection } from "app-domain"; @@ -36,6 +36,10 @@ export function Draft({ }, }); + useEffect(() => { + setCurrentPlayer(startingPlayer); + }, [startingPlayer]); + const ready = player1?.card && player2?.card; const handleSelectCard = (card: Card) => { From c2677160f176b8a53d027b6b5a4b471fb0ae2e1a Mon Sep 17 00:00:00 2001 From: Manu Artero Anguita Date: Fri, 20 Oct 2023 15:03:27 +0200 Subject: [PATCH 3/5] style: introducing css vars with tailwind --- src/components/deck.tsx | 2 +- src/components/toolbar.tsx | 2 +- src/index.css | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/deck.tsx b/src/components/deck.tsx index 303f2f6..c3166a5 100644 --- a/src/components/deck.tsx +++ b/src/components/deck.tsx @@ -24,7 +24,7 @@ export function Deck({ className, playerDeck, player }: Props) { className={c( className, "flex flex-col justify-around p-4 pb-32 h-full", - "border-gray-700", + "border-[var(--light-grey)]", player === "Player 1" && "bg-gradient-to-r border-r-4", player === "Player 2" && "bg-gradient-to-l border-l-4", player !== "Player 1" && diff --git a/src/components/toolbar.tsx b/src/components/toolbar.tsx index ca9940f..223d7d4 100644 --- a/src/components/toolbar.tsx +++ b/src/components/toolbar.tsx @@ -15,7 +15,7 @@ export function Toolbar({ onDeckSettings, onCollection }: Props) { return (