Skip to content

Commit aadd837

Browse files
feat: align desktop analysis UI with mobile board chrome
1 parent a07d3e9 commit aadd837

9 files changed

Lines changed: 1284 additions & 423 deletions

File tree

src/components/Analysis/AnalysisSidebar.tsx

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
import { motion } from 'framer-motion'
1010
import type { DrawShape } from 'chessground/draw'
1111
import { Dispatch, SetStateAction, useCallback, useMemo } from 'react'
12-
import type { ComponentProps } from 'react'
12+
import type { ComponentProps, CSSProperties, ReactNode } from 'react'
1313
import { useLocalStorage } from 'src/hooks'
1414
import { useAnalysisController } from 'src/hooks/useAnalysisController'
1515
import type { MaiaEvaluation, StockfishEvaluation } from 'src/types'
@@ -26,6 +26,10 @@ interface Props {
2626
analysisEnabled: boolean
2727
controller: ReturnType<typeof useAnalysisController>
2828
handleToggleAnalysis: () => void
29+
hideDetailedBlunderMeter?: boolean
30+
containerStyle?: CSSProperties
31+
footerContent?: ReactNode
32+
desktopContentHeightCss?: string
2933
itemVariants?: {
3034
hidden: {
3135
opacity: number
@@ -59,6 +63,10 @@ export const AnalysisSidebar: React.FC<Props> = ({
5963
setHoverArrow,
6064
analysisEnabled,
6165
handleToggleAnalysis,
66+
hideDetailedBlunderMeter = false,
67+
containerStyle,
68+
footerContent,
69+
desktopContentHeightCss = '85vh',
6270
itemVariants,
6371
}) => {
6472
const emptyBlunderMeterData = useMemo(
@@ -125,6 +133,8 @@ export const AnalysisSidebar: React.FC<Props> = ({
125133
boardDescription: highlightBoardDescription,
126134
currentNode: controller.currentNode ?? undefined,
127135
simplified: isSimplifiedView,
136+
hideStockfishEvalSummary: hideDetailedBlunderMeter,
137+
hideWhiteWinRateSummary: hideDetailedBlunderMeter,
128138
}
129139

130140
const simplifiedBlunderMeterProps: ComponentProps<
@@ -263,6 +273,7 @@ export const AnalysisSidebar: React.FC<Props> = ({
263273
highlightProps={highlightProps}
264274
blunderMeterProps={simplifiedBlunderMeterProps}
265275
analysisEnabled={analysisEnabled}
276+
hideBlunderMeter={hideDetailedBlunderMeter}
266277
/>
267278
</div>
268279
{!analysisEnabled &&
@@ -279,6 +290,7 @@ export const AnalysisSidebar: React.FC<Props> = ({
279290
highlightProps={highlightProps}
280291
blunderMeterProps={simplifiedBlunderMeterProps}
281292
analysisEnabled={analysisEnabled}
293+
hideBlunderMeter={hideDetailedBlunderMeter}
282294
/>
283295
</div>
284296
{!analysisEnabled &&
@@ -293,7 +305,10 @@ export const AnalysisSidebar: React.FC<Props> = ({
293305
const detailedLayout = (
294306
<>
295307
<div className="hidden xl:flex xl:h-full xl:flex-col xl:gap-3">
296-
<div className="desktop-analysis-big-row-1-container relative flex gap-3">
308+
<div
309+
className="desktop-analysis-big-row-1-container relative flex gap-3"
310+
style={{ height: `calc((${desktopContentHeightCss} - 0.75rem) / 2)` }}
311+
>
297312
<div className="flex h-full w-full flex-col overflow-hidden rounded-md border border-glass-border bg-glass-strong backdrop-blur-md">
298313
{renderHeader('desktop')}
299314
<div className="flex h-full w-full flex-1">
@@ -311,11 +326,14 @@ export const AnalysisSidebar: React.FC<Props> = ({
311326
})}
312327
</div>
313328

314-
<div className="desktop-analysis-big-row-2-container relative flex flex-row gap-3">
329+
<div
330+
className="desktop-analysis-big-row-2-container relative flex flex-row gap-3"
331+
style={{ height: `calc((${desktopContentHeightCss} - 0.75rem) / 2)` }}
332+
>
315333
<div className="flex h-full w-full flex-col">
316334
<MoveMap {...moveMapProps} />
317335
</div>
318-
<BlunderMeter {...blunderMeterProps} />
336+
{!hideDetailedBlunderMeter && <BlunderMeter {...blunderMeterProps} />}
319337
{!analysisEnabled &&
320338
renderDisabledOverlay('Enable analysis to see position evaluation')}
321339
</div>
@@ -327,11 +345,13 @@ export const AnalysisSidebar: React.FC<Props> = ({
327345
<div className="flex h-full w-full border-r border-glass-border">
328346
<Highlight {...highlightProps} />
329347
</div>
330-
<div className="flex h-full w-auto min-w-[40%] max-w-[40%] p-3">
331-
<div className="h-full w-full">
332-
<BlunderMeter {...blunderMeterProps} showContainer={false} />
348+
{!hideDetailedBlunderMeter && (
349+
<div className="flex h-full w-auto min-w-[40%] max-w-[40%] p-3">
350+
<div className="h-full w-full">
351+
<BlunderMeter {...blunderMeterProps} showContainer={false} />
352+
</div>
333353
</div>
334-
</div>
354+
)}
335355
{!analysisEnabled &&
336356
renderDisabledOverlay('Enable analysis to see move evaluations', {
337357
offsetTop: true,
@@ -362,9 +382,12 @@ export const AnalysisSidebar: React.FC<Props> = ({
362382
id="analysis"
363383
variants={itemVariants ?? {}}
364384
className="desktop-right-column-container flex flex-col gap-3"
365-
style={{ willChange: 'transform, opacity' }}
385+
style={{ willChange: 'transform, opacity', ...containerStyle }}
366386
>
367-
{isSimplifiedView ? simplifiedLayout : detailedLayout}
387+
<div className="min-h-0 flex-1">
388+
{isSimplifiedView ? simplifiedLayout : detailedLayout}
389+
</div>
390+
{footerContent ? <div className="shrink-0">{footerContent}</div> : null}
368391
</motion.div>
369392
)
370393
}

0 commit comments

Comments
 (0)