Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setting to show board coordinates #75

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/atoms/atoms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
const activeTab = get(activeTabAtom);
const nextValue =
typeof newValue === "function"
? newValue(get(currentTabAtom)!)

Check warning on line 83 in src/atoms/atoms.ts

View workflow job for this annotation

GitHub Actions / test

Forbidden non-null assertion
: newValue;
const newTabs = tabs.map((tab) => {
if (tab.value === activeTab) {
Expand All @@ -100,6 +100,7 @@
export const autoPromoteAtom = atomWithStorage<boolean>("auto-promote", true);
export const autoSaveAtom = atomWithStorage<boolean>("auto-save", true);
export const forcedEnPassantAtom = atomWithStorage<boolean>("forced-ep", false);
export const showCoordinatesAtom = atomWithStorage<boolean>("show-coordinates", false);
export const pieceSetAtom = atomWithStorage<string>("piece-set", "staunty");
export const primaryColorAtom = atomWithStorage<MantineColor>(
"mantine-primary-color",
Expand Down Expand Up @@ -162,38 +163,38 @@

// Per tab settings

const invisibleFamily = atomFamily((tab: string) => atom(false));

Check warning on line 166 in src/atoms/atoms.ts

View workflow job for this annotation

GitHub Actions / test

'tab' is defined but never used
export const currentInvisibleAtom = tabValue(invisibleFamily);

const tabFamily = atomFamily((tab: string) => atom("info"));

Check warning on line 169 in src/atoms/atoms.ts

View workflow job for this annotation

GitHub Actions / test

'tab' is defined but never used
export const currentTabSelectedAtom = tabValue(tabFamily);

const localOptionsFamily = atomFamily((tab: string) => atom<LocalOptions>({

Check warning on line 172 in src/atoms/atoms.ts

View workflow job for this annotation

GitHub Actions / test

'tab' is defined but never used
path: null,
type: "exact",
fen: ""
}));
export const currentLocalOptionsAtom = tabValue(localOptionsFamily);

const lichessOptionsFamily = atomFamily((tab: string) => atom<LichessGamesOptions>({

Check warning on line 179 in src/atoms/atoms.ts

View workflow job for this annotation

GitHub Actions / test

'tab' is defined but never used
fen: "",
ratings: [1000, 1200, 1400, 1600, 1800, 2000, 2200, 2500],
speeds: ["bullet", "blitz", "rapid", "classical", "correspondence"],
}));
export const currentLichessOptionsAtom = tabValue(lichessOptionsFamily);

const masterOptionsFamily = atomFamily((tab: string) => atom<MasterGamesOptions>({

Check warning on line 186 in src/atoms/atoms.ts

View workflow job for this annotation

GitHub Actions / test

'tab' is defined but never used
fen: ""
}));
export const currentMasterOptionsAtom = tabValue(masterOptionsFamily);

const dbTypeFamily = atomFamily((tab: string) => atom<"local" | "lch_all" | "lch_master">("local"));

Check warning on line 191 in src/atoms/atoms.ts

View workflow job for this annotation

GitHub Actions / test

'tab' is defined but never used
export const currentDbTypeAtom = tabValue(dbTypeFamily);

const dbTabFamily = atomFamily((tab: string) => atom("stats"));

Check warning on line 194 in src/atoms/atoms.ts

View workflow job for this annotation

GitHub Actions / test

'tab' is defined but never used
export const currentDbTabAtom = tabValue(dbTabFamily);

const analysisTabFamily = atomFamily((tab: string) => atom("engines"));

Check warning on line 197 in src/atoms/atoms.ts

View workflow job for this annotation

GitHub Actions / test

'tab' is defined but never used
export const currentAnalysisTabAtom = tabValue(analysisTabFamily);

const pgnOptionsFamily = atomFamily((tab: string) => atom({
Expand Down
4 changes: 3 additions & 1 deletion src/components/boards/BoardPlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
forcedEnPassantAtom,
moveInputAtom,
showArrowsAtom,
showCoordinatesAtom,
showDestsAtom,
} from "@/atoms/atoms";
import PromotionModal from "./PromotionModal";
Expand Down Expand Up @@ -120,6 +121,7 @@ function BoardPlay({
const showArrows = useAtomValue(showArrowsAtom);
const autoPromote = useAtomValue(autoPromoteAtom);
const forcedEP = useAtomValue(forcedEnPassantAtom);
const showCoordinates = useAtomValue(showCoordinatesAtom);
const autoSave = useAtomValue(autoSaveAtom);

const activeTab = useAtomValue(currentTabAtom);
Expand Down Expand Up @@ -318,7 +320,7 @@ function BoardPlay({
height={boardSize}
orientation={side ?? orientation}
fen={currentNode.fen}
coordinates={false}
coordinates={showCoordinates}
movable={{
free: editingMode,
color: practiceLock
Expand Down
4 changes: 4 additions & 0 deletions src/components/puzzles/PuzzleBoard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { Completion, Puzzle } from "@/utils/puzzles";
import PromotionModal from "../boards/PromotionModal";
import { chessboard } from "@/styles/Chessboard.css";
import { Chessground } from "@/chessground/Chessground";
import { useAtomValue } from "jotai";
import { showCoordinatesAtom } from "@/atoms/atoms";

function PuzzleBoard({
puzzles,
Expand Down Expand Up @@ -45,6 +47,7 @@ function PuzzleBoard({
const dests = toDests(chess, false);
const fen = chess.fen();
const turn = formatMove(chess.turn());
const showCoordinates = useAtomValue(showCoordinatesAtom);

const boardSize = getBoardSize(window.innerHeight, window.innerWidth);

Expand Down Expand Up @@ -87,6 +90,7 @@ function PuzzleBoard({
enabled: true,
}}
width={boardSize}
coordinates={showCoordinates}
height={boardSize}
orientation={orientation}
movable={{
Expand Down
10 changes: 10 additions & 0 deletions src/components/settings/SettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
forcedEnPassantAtom,
pieceSetAtom,
showDestsAtom,
showCoordinatesAtom,
} from "@/atoms/atoms";
import { Card, createStyles, Group, Stack, Text } from "@mantine/core";
import ColorControl from "./ColorControl";
Expand Down Expand Up @@ -122,6 +123,15 @@ export default function Page() {
</div>
<SettingsSwitch atom={autoPromoteAtom} />
</Group>
<Group position="apart" noWrap spacing="xl" className={classes.item}>
<div>
<Text>Coordinates</Text>
<Text size="xs" color="dimmed">
Show coordinates on the board
</Text>
</div>
<SettingsSwitch atom={showCoordinatesAtom} />
</Group>
<Group position="apart" noWrap spacing="xl" className={classes.item}>
<div>
<Text>Auto Save</Text>
Expand Down
Loading