Skip to content

Commit

Permalink
Merge pull request #14 from JollyGrin/feat/counters
Browse files Browse the repository at this point in the history
Feat/counters
  • Loading branch information
JollyGrin authored Sep 11, 2024
2 parents 6de3eab + dd17422 commit d68791f
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 3 deletions.
Binary file added public/icon/earth.webp
Binary file not shown.
Binary file added public/icon/fire.webp
Binary file not shown.
Binary file added public/icon/water.webp
Binary file not shown.
Binary file added public/icon/wind.webp
Binary file not shown.
84 changes: 84 additions & 0 deletions src/components/organisms/GameBoard/Footer/Counters/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { useState } from "react";
import { cva } from "styled-system/css/cva.mjs";
import { Flex, Grid, HStack, VStack } from "styled-system/jsx";
import { button } from "styled-system/recipes";

export const CountersTray = () => {
return (
<Flex
direction="column"
h="100%"
overflowY="auto"
p={0}
m={0}
justifyContent="center"
alignItems="center"
>
{(["earth", "fire", "water", "wind"] as const).map((type) => (
<Resource key={type} type={type} />
))}
</Flex>
);
};

const Resource = (props: { type: "fire" | "water" | "wind" | "earth" }) => {
const [amount, setAmount] = useState(0);
function increment() {
setAmount((prev) => prev + 1);
}

function decrement() {
setAmount((prev) => (prev === 0 ? prev : prev - 1));
}

return (
<VStack gap={0} p={0}>
<Grid gridTemplateColumns="1fr 1fr" alignItems="center">
<img
src={`/icon/${props.type}.webp`}
alt="fire"
className={iconStyle()}
style={{ height: "21px", width: "20px" }}
/>
<p style={{ justifySelf: "end", fontSize: "0.8rem" }}>{amount}</p>
</Grid>
<HStack
gap={0}
p={0}
opacity="0.05"
_hover={{ opacity: 1 }}
transition="all 0.25s ease"
>
<button
onClick={decrement}
className={button({ variant: "destructive", size: "sm" })}
style={{
borderTopRightRadius: 0,
borderBottomRightRadius: 0,
height: "20px",
}}
>
-
</button>

<button
onClick={increment}
className={button({ size: "sm" })}
style={{
borderTopLeftRadius: 0,
borderBottomLeftRadius: 0,
height: "20px",
}}
>
+
</button>
</HStack>
</VStack>
);
};

const iconStyle = cva({
base: {
width: "25px",
},
});
2 changes: 1 addition & 1 deletion src/components/organisms/GameBoard/Footer/Decks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const DecksTray = (props: GameStateActions) => {
/>
<VStack
w="100%"
py="1rem"
py="0.25rem"
style={{
height: LAYOUT_HEIGHTS.footer,
background:
Expand Down
12 changes: 10 additions & 2 deletions src/components/organisms/GameBoard/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
BiArrowToTop as IconTop,
BiArrowToBottom as IconBottom,
} from "react-icons/bi";
import { CountersTray } from "./Counters";

/**
* HAND - Drag and Drop tray of all the cards in your hand
Expand All @@ -40,9 +41,16 @@ export const GameFooter = (props: GameStateActions) => {
overflowX: "auto",
}}
>
<Grid h="100%" gridTemplateColumns="130px 100px 1fr" gap={0}>
<Grid
h="100%"
gridTemplateColumns="130px 115px 85px 1fr"
gap={0}
overflowY="clip"
// w="100vw"
>
<GraveTray {...props} />
<DecksTray {...props} />
<CountersTray />
<DroppableGridItem id={gridIndex.toString()} gridIndex={gridIndex}>
<SortableContext
id={`grid-${gridIndex}`}
Expand All @@ -54,7 +62,7 @@ export const GameFooter = (props: GameStateActions) => {
<HStack
p={0}
m={0}
w="calc(100vw - 300px)"
w="calc(100vw - 330px)"
h="100%"
justifyContent="start"
overflowX="auto"
Expand Down

0 comments on commit d68791f

Please sign in to comment.