Skip to content

Commit

Permalink
change piece set on hover
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscoBSalgueiro committed Dec 4, 2024
1 parent a0e6612 commit ca7de4d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 30 deletions.
14 changes: 6 additions & 8 deletions src/components/boards/BoardGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -568,15 +568,13 @@ function BoardGame() {
);
}
if (pos?.turn === "white" && blackTime !== null) {
setBlackTime(
(prev) => {
if (pos?.fullmoves === 1) {
return prev!;
}

return prev! + (players.black.timeControl?.increment ?? 0);
setBlackTime((prev) => {
if (pos?.fullmoves === 1) {
return prev!;
}
);

return prev! + (players.black.timeControl?.increment ?? 0);
});
}
setIntervalId(intervalId);
}
Expand Down
34 changes: 13 additions & 21 deletions src/components/settings/PiecesSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
Box,
Combobox,
Flex,
Group,
Input,
InputBase,
ScrollArea,
Expand Down Expand Up @@ -51,23 +50,8 @@ const pieceSets: Item[] = [
{ label: "Tatiana", value: "tatiana" },
];

function SelectOption({ label, piece }: { label: string; piece?: boolean }) {
return (
<Group wrap="nowrap">
{piece && (
<Box h="2.5rem" w="2.5rem">
<PieceComponent piece={{ color: "white", role: "knight" }} />
</Box>
)}
<Text fz="sm" fw={500}>
{label}
</Text>
</Group>
);
}

function DisplayPieces() {
const pieces = ["rook", "knight", "bishop", "queen", "king", "pawn"];
const pieces = ["rook", "knight", "bishop", "queen", "king", "pawn"] as const;
return (
<Flex gap="xs">
{pieces.map((role, index) => (
Expand All @@ -87,8 +71,14 @@ export default function PiecesSelect() {
const [pieceSet, setPieceSet] = useAtom(pieceSetAtom);

const options = pieceSets.map((item) => (
<Combobox.Option value={item.value} key={item.value}>
<SelectOption label={item.label} />
<Combobox.Option
value={item.value}
key={item.value}
onMouseOver={() => setPieceSet(item.value)}
>
<Text fz="sm" fw={500}>
{item.label}
</Text>
</Combobox.Option>
));

Expand Down Expand Up @@ -116,7 +106,9 @@ export default function PiecesSelect() {
w="10rem"
>
{selected ? (
<SelectOption label={selected.label} piece />
<Text fz="sm" fw={500}>
{selected.label}
</Text>
) : (
<Input.Placeholder>Pick value</Input.Placeholder>
)}
Expand All @@ -125,7 +117,7 @@ export default function PiecesSelect() {

<Combobox.Dropdown>
<Combobox.Options>
<ScrollArea.Autosize mah={200} type="always">
<ScrollArea.Autosize mah={200} type="always" scrollbars="y">
{options}
</ScrollArea.Autosize>
</Combobox.Options>
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import react from "@vitejs/plugin-react-swc";
import { TanStackRouterVite } from "@tanstack/router-vite-plugin";
import { defineConfig } from "vite";

const isDebug = !!process.env.TAURI_DEBUG;
const isDebug = !!process.env.TAURI_ENV_DEBUG;

// https://vitejs.dev/config/
export default defineConfig({
Expand Down

0 comments on commit ca7de4d

Please sign in to comment.