1- import { useState , useEffect , useRef } from 'react'
21import { MoveTooltip } from './MoveTooltip'
2+ import { useState , useEffect , useRef } from 'react'
33import { motion , AnimatePresence } from 'framer-motion'
44import { MaiaEvaluation , StockfishEvaluation , ColorSanMapping } from 'src/types'
55
6+ export const MAIA_MODELS = [
7+ 'maia_kdd_1100' ,
8+ 'maia_kdd_1200' ,
9+ 'maia_kdd_1300' ,
10+ 'maia_kdd_1400' ,
11+ 'maia_kdd_1500' ,
12+ 'maia_kdd_1600' ,
13+ 'maia_kdd_1700' ,
14+ 'maia_kdd_1800' ,
15+ 'maia_kdd_1900' ,
16+ ]
17+
618interface Props {
719 currentMaiaModel : string
20+ setCurrentMaiaModel : ( model : string ) => void
821 moveEvaluation : {
922 maia ?: MaiaEvaluation
1023 stockfish ?: StockfishEvaluation
@@ -32,6 +45,7 @@ export const Highlight: React.FC<Props> = ({
3245 colorSanMapping,
3346 recommendations,
3447 currentMaiaModel,
48+ setCurrentMaiaModel,
3549 boardDescription,
3650} : Props ) => {
3751 // Tooltip state
@@ -115,10 +129,25 @@ export const Highlight: React.FC<Props> = ({
115129 < div className = "flex h-full w-full flex-col border-white/40 bg-background-1" >
116130 < div className = "grid grid-cols-2 border-b border-white/20" >
117131 < div className = "flex flex-col items-center justify-start gap-0.5 border-r border-white/20 bg-human-3/5 xl:gap-1" >
118- < div className = "flex w-full flex-col border-b border-white/5 py-2" >
119- < p className = "whitespace-nowrap text-center text-human-1 md:text-[10px] lg:text-xs" >
120- Maia { currentMaiaModel . slice ( - 4 ) }
121- </ p >
132+ < div className = "relative flex w-full flex-col border-b border-white/5" >
133+ < select
134+ value = { currentMaiaModel }
135+ onChange = { ( e ) => setCurrentMaiaModel ( e . target . value ) }
136+ className = "cursor-pointer appearance-none bg-transparent py-2 text-center font-semibold text-human-1 outline-none transition-colors duration-200 hover:text-human-1/80 md:text-[10px] lg:text-xs"
137+ >
138+ { MAIA_MODELS . map ( ( model ) => (
139+ < option
140+ value = { model }
141+ key = { model }
142+ className = "bg-background-1 text-human-1"
143+ >
144+ Maia { model . slice ( - 4 ) }
145+ </ option >
146+ ) ) }
147+ </ select >
148+ < span className = "material-symbols-outlined pointer-events-none absolute right-1 top-1/2 -translate-y-1/2 text-sm text-human-1/60" >
149+ keyboard_arrow_down
150+ </ span >
122151 </ div >
123152 < div className = "flex w-full flex-col items-center justify-start border-b border-white/5 px-2 py-1 md:py-0.5 lg:py-1" >
124153 < p className = "whitespace-nowrap text-xs text-human-2 md:text-[10px] lg:text-xs" >
@@ -130,36 +159,44 @@ export const Highlight: React.FC<Props> = ({
130159 : '...' }
131160 </ p >
132161 </ div >
133- < div className = "grid grid-rows-2 items-center justify-center p- 1.5 xl:p -2" >
162+ < div className = "flex w-full flex-col items-center justify-center px-3 py- 1.5 xl:py -2" >
134163 < p className = "mb-1 whitespace-nowrap text-xs font-semibold text-human-2 md:text-[10px] lg:text-xs" >
135164 Human Moves
136165 </ p >
166+ < div className = "flex w-full cursor-pointer items-center justify-between" >
167+ < p className = "text-left font-mono text-[10px] text-secondary/50" >
168+ move
169+ </ p >
170+ < p className = "w-[32px] text-right font-mono text-[10px] text-secondary/50" >
171+ prob
172+ </ p >
173+ </ div >
137174 { recommendations . maia ?. slice ( 0 , 4 ) . map ( ( { move, prob } , index ) => {
138175 return (
139176 < button
140177 key = { index }
141- className = "grid cursor-pointer grid-cols-2 gap-1.5 hover:underline xl:gap-2 2xl:gap-3 "
178+ className = "flex w-full cursor-pointer items-center justify-between hover:underline"
142179 style = { {
143180 color : colorSanMapping [ move ] ?. color ?? '#fff' ,
144181 } }
145182 onMouseLeave = { handleMouseLeave }
146183 onMouseEnter = { ( e ) => handleMouseEnter ( move , 'maia' , e , prob ) }
147184 onClick = { ( ) => makeMove ( move ) }
148185 >
149- < p className = "text-right font-mono text-[10px] xl:text-xs" >
150- { ( Math . round ( prob * 1000 ) / 10 ) . toFixed ( 1 ) } %
151- </ p >
152186 < p className = "text-left font-mono text-[10px] xl:text-xs" >
153187 { colorSanMapping [ move ] ?. san ?? move }
154188 </ p >
189+ < p className = "text-right font-mono text-[10px] xl:text-xs" >
190+ { ( Math . round ( prob * 1000 ) / 10 ) . toFixed ( 1 ) } %
191+ </ p >
155192 </ button >
156193 )
157194 } ) }
158195 </ div >
159196 </ div >
160197 < div className = "flex flex-col items-center justify-start gap-0.5 bg-engine-3/5 xl:gap-1" >
161198 < div className = "flex w-full flex-col border-b border-white/5 py-2" >
162- < p className = "whitespace-nowrap text-center text-engine-1 md:text-[10px] lg:text-xs" >
199+ < p className = "whitespace-nowrap text-center font-semibold text-engine-1 md:text-[10px] lg:text-xs" >
163200 Stockfish{ ' ' }
164201 { moveEvaluation ?. stockfish ?. depth
165202 ? ` (D${ moveEvaluation . stockfish ?. depth } )`
@@ -176,17 +213,25 @@ export const Highlight: React.FC<Props> = ({
176213 : '...' }
177214 </ p >
178215 </ div >
179- < div className = "grid grid-rows-2 flex-col items-center justify-center p- 1.5 xl:p -2" >
216+ < div className = "flex w-full flex-col items-center justify-center px-3 py- 1.5 xl:py -2" >
180217 < p className = "mb-1 whitespace-nowrap text-xs font-semibold text-engine-2 md:text-[10px] lg:text-xs" >
181218 Engine Moves
182219 </ p >
220+ < div className = "flex w-full cursor-pointer items-center justify-between" >
221+ < p className = "text-left font-mono text-[10px] text-secondary/50" >
222+ move
223+ </ p >
224+ < p className = "w-[32px] text-right font-mono text-[10px] text-secondary/50" >
225+ eval
226+ </ p >
227+ </ div >
183228 { recommendations . stockfish
184229 ?. slice ( 0 , 4 )
185230 . map ( ( { move, cp, winrate, winrate_loss } , index ) => {
186231 return (
187232 < button
188233 key = { index }
189- className = "grid cursor-pointer grid-cols-2 gap-1.5 hover:underline xl:gap-2 2xl:gap-3 "
234+ className = "flex w-full cursor-pointer items-center justify-between hover:underline"
190235 style = { {
191236 color : colorSanMapping [ move ] ?. color ?? '#fff' ,
192237 } }
@@ -204,28 +249,28 @@ export const Highlight: React.FC<Props> = ({
204249 }
205250 onClick = { ( ) => makeMove ( move ) }
206251 >
252+ < p className = "text-left font-mono text-[10px] xl:text-xs" >
253+ { colorSanMapping [ move ] ?. san ?? move }
254+ </ p >
207255 < p className = "w-[32px] text-right font-mono text-[10px] xl:w-[36px] xl:text-xs 2xl:w-[42px]" >
208256 { cp > 0 ? '+' : null }
209257 { `${ ( cp / 100 ) . toFixed ( 2 ) } ` }
210258 </ p >
211- < p className = "text-left font-mono text-[10px] xl:text-xs" >
212- { colorSanMapping [ move ] ?. san ?? move }
213- </ p >
214259 </ button >
215260 )
216261 } ) }
217262 </ div >
218263 </ div >
219264 </ div >
220- < div className = "flex flex-col items-start justify-start gap-0.5 bg-background-1/80 p-2 text-sm xl:gap-1 xl:p-3 " >
265+ < div className = "flex flex-col items-start justify-start bg-background-1/80 p-2 text-sm" >
221266 < AnimatePresence mode = "wait" >
222267 { boardDescription ? (
223268 < motion . div
224269 key = { animationKey }
225270 initial = { { opacity : 0 , y : 10 } }
226271 animate = { { opacity : 1 , y : 0 } }
227272 exit = { { opacity : 0 , y : - 10 } }
228- transition = { { duration : 0.1 } }
273+ transition = { { duration : 0.075 } }
229274 className = "w-full"
230275 >
231276 < p className = "w-full whitespace-normal break-words text-[10px] leading-tight text-secondary xl:text-xs xl:leading-tight" >
0 commit comments