From a6bf01e75ab227e227d31e0029334a21d3a19ff1 Mon Sep 17 00:00:00 2001 From: Francisco Salgueiro Date: Sun, 11 Feb 2024 11:22:13 +0000 Subject: [PATCH] add correct orientation to board preview --- src/components/panels/analysis/AnalysisPanel.tsx | 5 ++++- src/components/panels/analysis/AnalysisRow.tsx | 12 +++++++++++- src/components/panels/analysis/BestMoves.tsx | 7 ++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/components/panels/analysis/AnalysisPanel.tsx b/src/components/panels/analysis/AnalysisPanel.tsx index d47cda3e..d9c0c55b 100644 --- a/src/components/panels/analysis/AnalysisPanel.tsx +++ b/src/components/panels/analysis/AnalysisPanel.tsx @@ -57,7 +57,7 @@ function AnalysisPanel({ inProgress: boolean; setInProgress: React.Dispatch>; }) { - const { root, position } = useContext(TreeStateContext); + const { root, position, headers } = useContext(TreeStateContext); const currentNode = getNodeAtPath(root, position); const [engines, setEngines] = useAtom(enginesAtom); @@ -215,6 +215,9 @@ function AnalysisPanel({ dragHandleProps={ provided.dragHandleProps } + orientation={ + headers.orientation || "white" + } /> diff --git a/src/components/panels/analysis/AnalysisRow.tsx b/src/components/panels/analysis/AnalysisRow.tsx index b3be7185..1ada3e6d 100644 --- a/src/components/panels/analysis/AnalysisRow.tsx +++ b/src/components/panels/analysis/AnalysisRow.tsx @@ -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(false); @@ -67,6 +69,7 @@ function AnalysisRow({ halfMoves={halfMoves} threat={threat} fen={fen} + orientation={orientation} /> ))} @@ -93,6 +96,7 @@ function BoardPopover({ halfMoves, threat, fen, + orientation, }: { san: string; index: number; @@ -100,6 +104,7 @@ function BoardPopover({ halfMoves: number; threat: boolean; fen: string; + orientation: "white" | "black"; }) { const [opened, { close, open }] = useDisclosure(false); const total_moves = halfMoves + index + 1 + (threat ? 1 : 0); @@ -144,7 +149,12 @@ function BoardPopover({ - + ); diff --git a/src/components/panels/analysis/BestMoves.tsx b/src/components/panels/analysis/BestMoves.tsx index adc97410..5ae03098 100644 --- a/src/components/panels/analysis/BestMoves.tsx +++ b/src/components/panels/analysis/BestMoves.tsx @@ -68,6 +68,7 @@ interface BestMovesProps { moves: string[]; halfMoves: number; dragHandleProps: any; + orientation: "white" | "black"; } function BestMovesComponent({ @@ -77,6 +78,7 @@ function BestMovesComponent({ moves, halfMoves, dragHandleProps, + orientation, }: BestMovesProps) { const dispatch = useContext(TreeDispatchContext); const activeTab = useAtomValue(activeTabAtom); @@ -449,6 +451,7 @@ function BestMovesComponent({ halfMoves={halfMoves} threat={threat} fen={threat ? swapMove(finalFen) : finalFen} + orientation={orientation} /> ); })} @@ -473,6 +476,7 @@ function BestMovesComponent({ toggleThreat, toggleSettingsOn, halfMoves, + orientation, ], ); } @@ -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 ); });