Skip to content

Commit

Permalink
add correct orientation to board preview
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscoBSalgueiro committed Feb 11, 2024
1 parent e32d258 commit a6bf01e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/components/panels/analysis/AnalysisPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function AnalysisPanel({
inProgress: boolean;
setInProgress: React.Dispatch<React.SetStateAction<boolean>>;
}) {
const { root, position } = useContext(TreeStateContext);
const { root, position, headers } = useContext(TreeStateContext);
const currentNode = getNodeAtPath(root, position);

const [engines, setEngines] = useAtom(enginesAtom);
Expand Down Expand Up @@ -215,6 +215,9 @@ function AnalysisPanel({
dragHandleProps={
provided.dragHandleProps
}
orientation={
headers.orientation || "white"
}
/>
</Accordion.Item>
</div>
Expand Down
12 changes: 11 additions & 1 deletion src/components/panels/analysis/AnalysisRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ function AnalysisRow({
halfMoves,
threat,
fen,
orientation,
}: {
score: Score;
moves: string[];
halfMoves: number;
threat: boolean;
fen: string;
orientation: "white" | "black";
}) {
const [open, setOpen] = useState<boolean>(false);

Expand Down Expand Up @@ -67,6 +69,7 @@ function AnalysisRow({
halfMoves={halfMoves}
threat={threat}
fen={fen}
orientation={orientation}
/>
))}
</Flex>
Expand All @@ -93,13 +96,15 @@ function BoardPopover({
halfMoves,
threat,
fen,
orientation,
}: {
san: string;
index: number;
moves: string[];
halfMoves: number;
threat: boolean;
fen: string;
orientation: "white" | "black";
}) {
const [opened, { close, open }] = useDisclosure(false);
const total_moves = halfMoves + index + 1 + (threat ? 1 : 0);
Expand Down Expand Up @@ -144,7 +149,12 @@ function BoardPopover({
<Popover.Dropdown
style={{ pointerEvents: "none", transitionDuration: "0ms" }}
>
<Chessground fen={fen} coordinates={false} viewOnly />
<Chessground
fen={fen}
coordinates={false}
viewOnly
orientation={orientation}
/>
</Popover.Dropdown>
</Popover>
);
Expand Down
7 changes: 6 additions & 1 deletion src/components/panels/analysis/BestMoves.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ interface BestMovesProps {
moves: string[];
halfMoves: number;
dragHandleProps: any;
orientation: "white" | "black";
}

function BestMovesComponent({
Expand All @@ -77,6 +78,7 @@ function BestMovesComponent({
moves,
halfMoves,
dragHandleProps,
orientation,
}: BestMovesProps) {
const dispatch = useContext(TreeDispatchContext);
const activeTab = useAtomValue(activeTabAtom);
Expand Down Expand Up @@ -449,6 +451,7 @@ function BestMovesComponent({
halfMoves={halfMoves}
threat={threat}
fen={threat ? swapMove(finalFen) : finalFen}
orientation={orientation}
/>
);
})}
Expand All @@ -473,6 +476,7 @@ function BestMovesComponent({
toggleThreat,
toggleSettingsOn,
halfMoves,
orientation,
],
);
}
Expand All @@ -483,6 +487,7 @@ export default memo(BestMovesComponent, (prev, next) => {
prev.engine === next.engine &&
prev.fen === next.fen &&
equal(prev.moves, next.moves) &&
prev.halfMoves === next.halfMoves
prev.halfMoves === next.halfMoves &&
prev.orientation === next.orientation
);
});

0 comments on commit a6bf01e

Please sign in to comment.