Skip to content

Commit

Permalink
fix new linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscoBSalgueiro committed Sep 15, 2024
1 parent 986c0b8 commit 99decfb
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 164 deletions.
8 changes: 4 additions & 4 deletions src/components/boards/BoardGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -542,12 +542,12 @@ function BoardGame() {
const whiteName =
players.white.type === "human"
? players.white.name
: players.white.engine?.name ?? "?";
: (players.white.engine?.name ?? "?");

const blackName =
players.black.type === "human"
? players.black.name
: players.black.engine?.name ?? "?";
: (players.black.engine?.name ?? "?");

return tab.value === activeTab
? {
Expand Down Expand Up @@ -593,10 +593,10 @@ function BoardGame() {
canTakeBack={onePlayerIsEngine}
movable={movable}
whiteTime={
gameState === "playing" ? whiteTime ?? undefined : undefined
gameState === "playing" ? (whiteTime ?? undefined) : undefined
}
blackTime={
gameState === "playing" ? blackTime ?? undefined : undefined
gameState === "playing" ? (blackTime ?? undefined) : undefined
}
whiteTc={players.white.timeControl}
blackTc={players.black.timeControl}
Expand Down
3 changes: 2 additions & 1 deletion src/components/common/AccountCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,9 @@ function PlayerSession({
</Group>
<Divider />
<Accordion multiple chevronSize={0}>
{sessions.map((session) => (
{sessions.map((session, i) => (
<LichessOrChessCom
key={i}
session={session}
databases={databases}
setDatabases={setDatabases}
Expand Down
5 changes: 3 additions & 2 deletions src/components/common/GameNotation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
import { INITIAL_FEN } from "chessops/fen";
import { useAtom, useAtomValue } from "jotai";
import { memo, useContext, useEffect, useRef, useState } from "react";
import React from "react";
import { useHotkeys } from "react-hotkeys-hook";
import { useStore } from "zustand";
import CompleteMoveCell from "./CompleteMoveCell";
Expand Down Expand Up @@ -200,7 +201,7 @@ const RenderVariationTree = memo(
const variations = tree.children;
const moveNodes = showVariations
? variations.slice(1).map((variation) => (
<>
<React.Fragment key={variation.fen}>
<CompleteMoveCell
targetRef={targetRef}
annotations={variation.annotations}
Expand Down Expand Up @@ -230,7 +231,7 @@ const RenderVariationTree = memo(
start={start}
path={[...path, variations.indexOf(variation)]}
/>
</>
</React.Fragment>
))
: [];

Expand Down
299 changes: 146 additions & 153 deletions src/components/panels/analysis/AnalysisPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,163 +110,156 @@ function AnalysisPanel() {
flexDirection: "column",
}}
>
<>
<ScrollArea
offsetScrollbars
onScrollPositionChange={() =>
document.dispatchEvent(new Event("analysis-panel-scroll"))
}
>
{pos &&
(getPiecesCount(pos) <= 7 ||
(getPiecesCount(pos) === 8 && hasCaptures(pos))) && (
<>
<TablebaseInfo fen={currentNodeFen} turn={pos.turn} />
<Space h="sm" />
</>
)}
{loadedEngines.length > 1 && (
<Paper withBorder p="xs" flex={1}>
<Group w="100%">
<Stack w="6rem" gap="xs">
<Text ta="center" fw="bold">
{t("Board.Analysis.Summary")}
</Text>
<Button
rightSection={
allEnabled ? (
<IconPlayerPause size="1.2rem" />
) : (
<IconChevronsRight size="1.2rem" />
)
}
variant={allEnabled ? "filled" : "default"}
onClick={() => enable(!allEnabled)}
>
{allEnabled ? t("Common.Stop") : t("Common.Run")}
</Button>
</Stack>
<Group grow flex={1}>
{loadedEngines.map((engine, i) => (
<EngineSummary
key={engine.name}
engine={engine}
fen={rootFen}
moves={moves}
i={i}
/>
))}
</Group>
</Group>
</Paper>
<ScrollArea
offsetScrollbars
onScrollPositionChange={() =>
document.dispatchEvent(new Event("analysis-panel-scroll"))
}
>
{pos &&
(getPiecesCount(pos) <= 7 ||
(getPiecesCount(pos) === 8 && hasCaptures(pos))) && (
<>
<TablebaseInfo fen={currentNodeFen} turn={pos.turn} />
<Space h="sm" />
</>
)}
<Stack mt="sm">
<Accordion
variant="separated"
multiple
chevronSize={0}
defaultValue={loadedEngines.map((e) => e.name)}
value={expanded}
onChange={(v) => setExpanded(v)}
styles={{
label: {
paddingTop: 0,
paddingBottom: 0,
},
content: {
padding: "0.3rem",
},
}}
>
<DragDropContext
onDragEnd={({ destination, source }) =>
destination?.index !== undefined &&
setEngines(async (prev) => {
const result = Array.from(await prev);
const prevLoaded = result.filter((e) => e.loaded);
const [removed] = prevLoaded.splice(source.index, 1);
prevLoaded.splice(destination.index, 0, removed);
{loadedEngines.length > 1 && (
<Paper withBorder p="xs" flex={1}>
<Group w="100%">
<Stack w="6rem" gap="xs">
<Text ta="center" fw="bold">
{t("Board.Analysis.Summary")}
</Text>
<Button
rightSection={
allEnabled ? (
<IconPlayerPause size="1.2rem" />
) : (
<IconChevronsRight size="1.2rem" />
)
}
variant={allEnabled ? "filled" : "default"}
onClick={() => enable(!allEnabled)}
>
{allEnabled ? t("Common.Stop") : t("Common.Run")}
</Button>
</Stack>
<Group grow flex={1}>
{loadedEngines.map((engine, i) => (
<EngineSummary
key={engine.name}
engine={engine}
fen={rootFen}
moves={moves}
i={i}
/>
))}
</Group>
</Group>
</Paper>
)}
<Stack mt="sm">
<Accordion
variant="separated"
multiple
chevronSize={0}
defaultValue={loadedEngines.map((e) => e.name)}
value={expanded}
onChange={(v) => setExpanded(v)}
styles={{
label: {
paddingTop: 0,
paddingBottom: 0,
},
content: {
padding: "0.3rem",
},
}}
>
<DragDropContext
onDragEnd={({ destination, source }) =>
destination?.index !== undefined &&
setEngines(async (prev) => {
const result = Array.from(await prev);
const prevLoaded = result.filter((e) => e.loaded);
const [removed] = prevLoaded.splice(source.index, 1);
prevLoaded.splice(destination.index, 0, removed);

result.forEach((e, i) => {
if (e.loaded) {
result[i] = prevLoaded.shift()!;
}
});
return result;
})
}
>
<Droppable droppableId="droppable" direction="vertical">
{(provided) => (
<div
ref={provided.innerRef}
{...provided.droppableProps}
>
<Stack w="100%">
{loadedEngines.map((engine, i) => (
<Draggable
key={engine.name + i.toString()}
draggableId={engine.name}
index={i}
>
{(provided) => (
<div
ref={provided.innerRef}
{...provided.draggableProps}
>
<Accordion.Item value={engine.name}>
<BestMoves
id={i}
engine={engine}
fen={rootFen}
moves={moves}
halfMoves={currentNodeHalfMoves}
dragHandleProps={
provided.dragHandleProps
}
orientation={
headers.orientation || "white"
}
/>
</Accordion.Item>
</div>
)}
</Draggable>
))}
</Stack>
result.forEach((e, i) => {
if (e.loaded) {
result[i] = prevLoaded.shift()!;
}
});
return result;
})
}
>
<Droppable droppableId="droppable" direction="vertical">
{(provided) => (
<div ref={provided.innerRef} {...provided.droppableProps}>
<Stack w="100%">
{loadedEngines.map((engine, i) => (
<Draggable
key={engine.name + i.toString()}
draggableId={engine.name}
index={i}
>
{(provided) => (
<div
ref={provided.innerRef}
{...provided.draggableProps}
>
<Accordion.Item value={engine.name}>
<BestMoves
id={i}
engine={engine}
fen={rootFen}
moves={moves}
halfMoves={currentNodeHalfMoves}
dragHandleProps={provided.dragHandleProps}
orientation={
headers.orientation || "white"
}
/>
</Accordion.Item>
</div>
)}
</Draggable>
))}
</Stack>

{provided.placeholder}
</div>
)}
</Droppable>
</DragDropContext>
</Accordion>
<Group gap="xs">
<Button
flex={1}
variant="default"
onClick={() => {
navigate({ to: "/engines" });
}}
leftSection={<IconSettings size="0.875rem" />}
>
Manage Engines
</Button>
<Popover width={250} position="top-end" shadow="md">
<Popover.Target>
<ActionIcon variant="default" size="lg">
<IconSelector />
</ActionIcon>
</Popover.Target>
{provided.placeholder}
</div>
)}
</Droppable>
</DragDropContext>
</Accordion>
<Group gap="xs">
<Button
flex={1}
variant="default"
onClick={() => {
navigate({ to: "/engines" });
}}
leftSection={<IconSettings size="0.875rem" />}
>
Manage Engines
</Button>
<Popover width={250} position="top-end" shadow="md">
<Popover.Target>
<ActionIcon variant="default" size="lg">
<IconSelector />
</ActionIcon>
</Popover.Target>

<Popover.Dropdown>
<EngineSelection />
</Popover.Dropdown>
</Popover>
</Group>
</Stack>
</ScrollArea>
</>
<Popover.Dropdown>
<EngineSelection />
</Popover.Dropdown>
</Popover>
</Group>
</Stack>
</ScrollArea>
</Tabs.Panel>
<Tabs.Panel
value="report"
Expand Down
2 changes: 1 addition & 1 deletion src/styles/chessgroundBaseOverride.css
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ piece.fading {
top: -4%;
flex-flow: column-reverse;
height: 100%;
width: 1rem
width: 1rem;
}

.cg-wrap coords.ranks.black {
Expand Down
Loading

0 comments on commit 99decfb

Please sign in to comment.