Skip to content

Commit 33ab1df

Browse files
feat: add configuration and export feature set
1 parent 029696c commit 33ab1df

File tree

6 files changed

+206
-127
lines changed

6 files changed

+206
-127
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import Link from 'next/link'
2+
import React from 'react'
3+
4+
import { ContinueAgainstMaia } from 'src/components'
5+
6+
interface Props {
7+
currentMaiaModel: string
8+
setCurrentMaiaModel: (model: string) => void
9+
launchContinue: () => void
10+
MAIA_MODELS: string[]
11+
}
12+
13+
export const ConfigureAnalysis: React.FC<Props> = ({
14+
currentMaiaModel,
15+
setCurrentMaiaModel,
16+
launchContinue,
17+
MAIA_MODELS,
18+
}: Props) => {
19+
return (
20+
<div className="flex flex-col gap-2">
21+
<div className="flex flex-col gap-0.5">
22+
<p className="text-sm text-secondary">Analyze using:</p>
23+
<select
24+
value={currentMaiaModel}
25+
className="cursor-pointer rounded border-none bg-human-4/40 p-2 text-primary/70 outline-none transition duration-300 hover:bg-human-4/60 hover:text-primary"
26+
onChange={(e) => setCurrentMaiaModel(e.target.value)}
27+
>
28+
{MAIA_MODELS.map((model) => (
29+
<option value={model} key={model}>
30+
{model.replace('maia_kdd_', 'Maia ')}
31+
</option>
32+
))}
33+
</select>
34+
</div>
35+
<ContinueAgainstMaia
36+
launchContinue={launchContinue}
37+
background="bg-human-4/40 hover:bg-human-4/60 text-primary/70 hover:text-primary"
38+
/>
39+
<p className="mt-2 text-sm text-secondary">
40+
If you are having performance issues, you can switch to our legacy{' '}
41+
<Link
42+
href={window.location.href.replace('/analyze', '/analysis')}
43+
className="text-primary/80 underline transition duration-200 hover:text-primary/100"
44+
>
45+
Analysis Lite
46+
</Link>{' '}
47+
to continue your analysis without Maia 2.
48+
</p>
49+
</div>
50+
)
51+
}

src/components/Analysis/MovesByRating.tsx

+18-2
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,24 @@ export const MovesByRating: React.FC<Props> = ({
141141
const prob = Math.round((point.value as number) * 10) / 10
142142
return (
143143
<div className="flex items-center justify-between px-3">
144-
<p className="text-xs">{san}</p>
145-
<p className="font-mono text-xs">{prob}%</p>
144+
<p
145+
style={{
146+
color:
147+
colorSanMapping[point.name as string].color,
148+
}}
149+
className="text-xs"
150+
>
151+
{san}
152+
</p>
153+
<p
154+
style={{
155+
color:
156+
colorSanMapping[point.name as string].color,
157+
}}
158+
className="font-mono text-xs"
159+
>
160+
{prob}%
161+
</p>
146162
</div>
147163
)
148164
})}

src/components/Board/GameplayInterface.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export const GameplayInterface: React.FC<Props> = (
187187
game={game}
188188
whitePlayer={whitePlayer ?? 'Unknown'}
189189
blackPlayer={blackPlayer ?? 'Unknown'}
190-
maiaVersion={maiaTitle}
190+
event={`Play vs. ${maiaTitle}`}
191191
/>
192192
<StatsDisplay stats={stats} hideSession={true} />
193193
</div>
@@ -277,7 +277,7 @@ export const GameplayInterface: React.FC<Props> = (
277277
game={game}
278278
whitePlayer={whitePlayer ?? 'Unknown'}
279279
blackPlayer={blackPlayer ?? 'Unknown'}
280-
maiaVersion={maiaTitle}
280+
event={`Play vs. ${maiaTitle}`}
281281
/>
282282
</div>
283283
</div>

src/components/Misc/ContinueAgainstMaia.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
interface Props {
22
launchContinue: () => void
3+
background?: string
34
}
4-
export const ContinueAgainstMaia: React.FC<Props> = ({ launchContinue }) => {
5+
export const ContinueAgainstMaia: React.FC<Props> = ({
6+
launchContinue,
7+
background,
8+
}) => {
59
return (
610
<button
711
onClick={launchContinue}
8-
className="flex w-full items-center gap-1.5 rounded bg-human-4 px-3 py-2 transition duration-200 hover:bg-human-3"
12+
className={`flex w-full items-center gap-1.5 rounded px-3 py-2 transition duration-200 ${background ? background : 'bg-human-4 hover:bg-human-3'}`}
913
>
1014
<span className="material-symbols-outlined text-base">swords</span>
1115
<span>Play position against Maia</span>

src/components/Misc/ExportGame.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ interface Props {
99
game: PlayedGame
1010
whitePlayer: string
1111
blackPlayer: string
12-
maiaVersion: string
12+
event: string
1313
}
1414

1515
export const ExportGame: React.FC<Props> = ({
1616
game,
1717
whitePlayer,
1818
blackPlayer,
19-
maiaVersion,
19+
event,
2020
}) => {
2121
const [fen, setFen] = useState('')
2222
const [pgn, setPgn] = useState('')
@@ -35,7 +35,7 @@ export const ExportGame: React.FC<Props> = ({
3535
useEffect(() => {
3636
const initial = new Chess(game.moves[0].board)
3737
initial.addHeader('ID', game.id)
38-
initial.addHeader('Event', `Play v. ${maiaVersion}`)
38+
initial.addHeader('Event', event)
3939
initial.addHeader('Site', `https://maiachess.com/`)
4040
initial.addHeader('White', whitePlayer)
4141
initial.addHeader('Black', blackPlayer)
@@ -80,7 +80,7 @@ export const ExportGame: React.FC<Props> = ({
8080
role="button"
8181
tabIndex={0}
8282
onClick={() => copy(fen)}
83-
className="border-1 group flex cursor-pointer overflow-x-hidden rounded border border-white/5 bg-background-1/50 px-4 py-2"
83+
className="border-1 group flex cursor-pointer overflow-x-hidden rounded border border-white/5 bg-background-1/50 px-3 py-2"
8484
>
8585
<p className="whitespace-nowrap text-xs text-secondary group-hover:text-secondary/80">
8686
{fen}
@@ -105,7 +105,7 @@ export const ExportGame: React.FC<Props> = ({
105105
role="button"
106106
tabIndex={0}
107107
onClick={() => copy(pgn)}
108-
className="border-1 group flex cursor-pointer overflow-x-hidden rounded border border-white/5 bg-background-1/50 px-4 py-2"
108+
className="border-1 group flex max-h-32 cursor-pointer overflow-x-hidden overflow-y-scroll rounded border border-white/5 bg-background-1/50 p-3"
109109
>
110110
<p className="whitespace-pre-wrap text-xs text-secondary group-hover:text-secondary/80">
111111
{pgn}

0 commit comments

Comments
 (0)