Skip to content

Commit ce26567

Browse files
style: improve play + h&b ui
1 parent b7c52ea commit ce26567

9 files changed

Lines changed: 219 additions & 192 deletions

File tree

src/components/Board/GameplayInterface.tsx

Lines changed: 106 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ import Head from 'next/head'
1212
import { useUnload } from 'src/hooks/useUnload'
1313
import type { DrawShape } from 'chessground/draw'
1414
import { useCallback, useContext, useMemo, useState } from 'react'
15-
import { AuthContext, WindowSizeContext } from 'src/contexts'
15+
import {
16+
AuthContext,
17+
WindowSizeContext,
18+
TreeControllerContext,
19+
} from 'src/contexts'
1620
import { PlayControllerContext } from 'src/contexts/PlayControllerContext'
1721

1822
interface Props {
@@ -36,6 +40,7 @@ export const GameplayInterface: React.FC<React.PropsWithChildren<Props>> = (
3640
orientation,
3741
timeControl,
3842
currentNode,
43+
setCurrentNode,
3944
maiaVersion,
4045
goToRootNode,
4146
goToNextNode,
@@ -156,30 +161,42 @@ export const GameplayInterface: React.FC<React.PropsWithChildren<Props>> = (
156161
style={{
157162
maxWidth: 'min(20vw, 100vw - 75vh)',
158163
}}
159-
className="flex h-[75vh] w-[40vh] flex-col justify-between gap-1"
164+
className="flex h-[75vh] w-[40vh] flex-col"
160165
>
161-
<GameInfo
162-
icon="swords"
163-
type={playType}
164-
title={
165-
playType === 'againstMaia'
166-
? 'Play vs. Maia'
167-
: 'Play Hand and Brain'
168-
}
169-
>
170-
{Info}
171-
</GameInfo>
172-
<div className="flex w-full flex-col gap-2">
173-
<ExportGame
174-
game={game}
175-
gameTree={gameTree}
176-
currentNode={currentNode}
177-
whitePlayer={whitePlayer ?? 'Unknown'}
178-
blackPlayer={blackPlayer ?? 'Unknown'}
179-
event={`Play vs. ${maiaTitle}`}
180-
type="play"
181-
/>
182-
<StatsDisplay stats={stats} hideSession={true} isGame={true} />
166+
<div className="flex h-full w-full flex-col overflow-hidden rounded-md border border-glassBorder bg-glass backdrop-blur-md">
167+
<GameInfo
168+
icon="swords"
169+
type={playType}
170+
title={
171+
playType === 'againstMaia'
172+
? 'Play vs. Maia'
173+
: 'Play Hand and Brain'
174+
}
175+
embedded
176+
>
177+
{Info}
178+
</GameInfo>
179+
<div className="mt-auto flex flex-col">
180+
<div className="px-3 pb-4">
181+
<ExportGame
182+
game={game}
183+
gameTree={gameTree}
184+
currentNode={currentNode}
185+
whitePlayer={whitePlayer ?? 'Unknown'}
186+
blackPlayer={blackPlayer ?? 'Unknown'}
187+
event={`Play vs. ${maiaTitle}`}
188+
type="play"
189+
/>
190+
</div>
191+
<div className="h-3 border-y border-glassBorder" />
192+
<StatsDisplay
193+
stats={stats}
194+
hideSession={true}
195+
isGame={true}
196+
embedded
197+
hideEmbeddedBorder
198+
/>
199+
</div>
183200
</div>
184201
</div>
185202
<div
@@ -206,30 +223,38 @@ export const GameplayInterface: React.FC<React.PropsWithChildren<Props>> = (
206223
style={{
207224
maxWidth: 'min(20vw, 100vw - 75vh)',
208225
}}
209-
className="flex h-[75vh] w-[40vh] flex-col justify-center gap-1"
226+
className="flex h-[75vh] w-[40vh] flex-col justify-center gap-2"
210227
>
211228
{timeControl != 'unlimited' ? (
212229
<GameClock
213230
player={orientation == 'white' ? 'black' : 'white'}
214231
reversed={false}
215232
/>
216233
) : null}
217-
<div className="relative bottom-0 h-full min-h-[38px] flex-1">
218-
<MovesContainer game={game} termination={game.termination} />
219-
</div>
220-
<div>{props.children}</div>
221-
<div className="flex-none">
222-
<BoardController
223-
orientation={orientation}
224-
setOrientation={setOrientation}
225-
currentNode={currentNode}
226-
plyCount={plyCount}
227-
goToNode={goToNode}
228-
goToNextNode={goToNextNode}
229-
goToPreviousNode={goToPreviousNode}
230-
goToRootNode={goToRootNode}
231-
gameTree={gameTree}
232-
/>
234+
<div className="flex h-full flex-col overflow-hidden rounded-lg border border-glassBorder bg-glass backdrop-blur-md">
235+
<div className="flex-1 overflow-hidden border-b border-glassBorder">
236+
<MovesContainer
237+
game={game}
238+
termination={game.termination}
239+
embedded
240+
heightClass="h-full"
241+
/>
242+
</div>
243+
<div className="border-b border-glassBorder">
244+
<BoardController
245+
orientation={orientation}
246+
setOrientation={setOrientation}
247+
currentNode={currentNode}
248+
plyCount={plyCount}
249+
goToNode={goToNode}
250+
goToNextNode={goToNextNode}
251+
goToPreviousNode={goToPreviousNode}
252+
goToRootNode={goToRootNode}
253+
gameTree={gameTree}
254+
embedded
255+
/>
256+
</div>
257+
<div className="px-4 py-3">{props.children}</div>
233258
</div>
234259
{timeControl != 'unlimited' ? (
235260
<GameClock player={orientation} reversed={true} />
@@ -276,25 +301,32 @@ export const GameplayInterface: React.FC<React.PropsWithChildren<Props>> = (
276301
{timeControl != 'unlimited' ? (
277302
<GameClock player={orientation} reversed={true} />
278303
) : null}
279-
<div className="flex-none">
280-
<BoardController
281-
orientation={orientation}
282-
setOrientation={setOrientation}
283-
currentNode={currentNode}
284-
plyCount={plyCount}
285-
goToNode={goToNode}
286-
goToNextNode={goToNextNode}
287-
goToPreviousNode={goToPreviousNode}
288-
goToRootNode={goToRootNode}
289-
gameTree={gameTree}
290-
/>
291-
</div>
292-
<div className="w-full overflow-x-auto">
293-
<div className="flex flex-row whitespace-nowrap py-2">
294-
<MovesContainer game={game} termination={game.termination} />
304+
<div className="w-full">
305+
<div className="flex flex-col overflow-hidden rounded-lg border border-glassBorder bg-glass backdrop-blur-md">
306+
<div className="border-b border-glassBorder">
307+
<MovesContainer
308+
game={game}
309+
termination={game.termination}
310+
embedded
311+
/>
312+
</div>
313+
<div className="border-b border-glassBorder">
314+
<BoardController
315+
orientation={orientation}
316+
setOrientation={setOrientation}
317+
currentNode={currentNode}
318+
plyCount={plyCount}
319+
goToNode={goToNode}
320+
goToNextNode={goToNextNode}
321+
goToPreviousNode={goToPreviousNode}
322+
goToRootNode={goToRootNode}
323+
gameTree={gameTree}
324+
embedded
325+
/>
326+
</div>
327+
<div className="px-4 py-3">{props.children}</div>
295328
</div>
296329
</div>
297-
<div className="w-screen">{props.children}</div>
298330
<StatsDisplay stats={stats} hideSession={true} isGame={true} />
299331
<div className="px-2">
300332
<ExportGame
@@ -321,7 +353,22 @@ export const GameplayInterface: React.FC<React.PropsWithChildren<Props>> = (
321353
<title>Maia Chess - Play</title>
322354
<meta name="description" content="Turing survey" />
323355
</Head>
324-
{layouts}
356+
<TreeControllerContext.Provider
357+
value={{
358+
gameTree,
359+
currentNode,
360+
setCurrentNode,
361+
orientation,
362+
setOrientation,
363+
goToNode,
364+
goToNextNode,
365+
goToPreviousNode,
366+
goToRootNode,
367+
plyCount,
368+
}}
369+
>
370+
{layouts}
371+
</TreeControllerContext.Provider>
325372
</>
326373
)
327374
}

src/components/Common/PlaySetupModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export const PlaySetupModal: React.FC<Props> = (props: Props) => {
205205
initial={{ opacity: 0 }}
206206
animate={{ opacity: 1 }}
207207
exit={{ opacity: 0 }}
208-
className="relative flex h-[600px] w-[500px] max-w-[90vw] flex-col overflow-hidden rounded-lg border border-glassBorder bg-glass"
208+
className="relative flex h-[600px] w-[500px] max-w-[90vw] flex-col overflow-hidden rounded-lg border border-glassBorder bg-glass backdrop-blur-md"
209209
>
210210
<div
211211
className="pointer-events-none absolute inset-0"

src/components/Common/StatsDisplay.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,15 @@ interface Props {
6666
hideSession?: boolean
6767
isGame?: boolean
6868
embedded?: boolean
69+
hideEmbeddedBorder?: boolean
6970
}
7071

7172
export const StatsDisplay: React.FC<Props> = ({
7273
hideSession,
7374
stats,
7475
isGame,
7576
embedded = false,
77+
hideEmbeddedBorder = false,
7678
}: Props) => {
7779
const [cachedRating, setCachedRating] = useState<number | undefined>(0)
7880

@@ -87,7 +89,7 @@ export const StatsDisplay: React.FC<Props> = ({
8789
<div
8890
className={
8991
embedded
90-
? 'flex flex-col gap-3 border-t border-glassBorder bg-transparent p-3'
92+
? `flex flex-col gap-3 bg-transparent p-3${hideEmbeddedBorder ? '' : ' border-t border-glassBorder'}`
9193
: 'flex flex-col gap-3 rounded-md border border-glassBorder bg-glass p-3 backdrop-blur-md'
9294
}
9395
>

0 commit comments

Comments
 (0)