diff --git a/ui/@types/lichess/index.d.ts b/ui/@types/lichess/index.d.ts index ab6ff1a6a3..1520451db0 100644 --- a/ui/@types/lichess/index.d.ts +++ b/ui/@types/lichess/index.d.ts @@ -300,7 +300,7 @@ declare type VariantKey = | 'racingKings' | 'crazyhouse'; -declare type Speed = 'bullet' | 'blitz' | 'classical' | 'correspondence'; +declare type Speed = 'ultraBullet' | 'bullet' | 'blitz' | 'rapid' | 'classical' | 'correspondence'; declare type Perf = | 'bullet' diff --git a/ui/analyse/src/explorer/explorerConfig.ts b/ui/analyse/src/explorer/explorerConfig.ts index ffdb4e77c6..780b399b46 100644 --- a/ui/analyse/src/explorer/explorerConfig.ts +++ b/ui/analyse/src/explorer/explorerConfig.ts @@ -5,9 +5,12 @@ import { storedProp, storedJsonProp, StoredJsonProp, StoredProp } from 'common/s import { ExplorerDb, ExplorerSpeed, ExplorerMode } from './interfaces'; import { snabModal } from 'common/modal'; import AnalyseCtrl from '../ctrl'; +import { perf } from 'game/perf'; +import { iconTag } from '../util'; +import { ucfirst } from './explorerUtil'; const allDbs: ExplorerDb[] = ['lichess', 'player']; -const allSpeeds: ExplorerSpeed[] = ['bullet', 'blitz', 'rapid', 'classical']; +const allSpeeds: ExplorerSpeed[] = ['ultraBullet', 'bullet', 'blitz', 'rapid', 'classical', 'correspondence']; const allModes: ExplorerMode[] = ['casual', 'rated']; const allRatings = [1600, 1800, 2000, 2200, 2500]; @@ -138,15 +141,15 @@ const masterDb = (ctrl: ExplorerConfigCtrl) => ]); const radioButton = - (ctrl: ExplorerConfigCtrl, storage: StoredJsonProp) => + (ctrl: ExplorerConfigCtrl, storage: StoredJsonProp, render?: (t: T) => VNode) => (v: T) => h( 'button', { - attrs: { 'aria-pressed': `${storage().includes(v)}` }, + attrs: { 'aria-pressed': `${storage().includes(v)}`, title: render ? ucfirst('' + v) : '' }, hook: bind('click', _ => ctrl.toggleMany(storage)(v), ctrl.root.redraw), }, - '' + v + render ? render(v) : '' + v ); const lichessDb = (ctrl: ExplorerConfigCtrl) => @@ -161,7 +164,7 @@ const lichessDb = (ctrl: ExplorerConfigCtrl) => const speedSection = (ctrl: ExplorerConfigCtrl) => h('section.speed', [ h('label', ctrl.root.trans.noarg('timeControl')), - h('div.choices', allSpeeds.map(radioButton(ctrl, ctrl.data.speed))), + h('div.choices', allSpeeds.map(radioButton(ctrl, ctrl.data.speed, s => iconTag(perf.icons[s])))), ]); const modeSection = (ctrl: ExplorerConfigCtrl) => diff --git a/ui/analyse/src/explorer/explorerUtil.ts b/ui/analyse/src/explorer/explorerUtil.ts index c5d4a2ed48..ace1b0a1dd 100644 --- a/ui/analyse/src/explorer/explorerUtil.ts +++ b/ui/analyse/src/explorer/explorerUtil.ts @@ -11,3 +11,5 @@ export function winnerOf(fen: Fen, move: TablebaseMoveStats): Color | undefined if (move.variant_win || (move.dtz && move.dtz > 0)) return opposite(stm); return undefined; } + +export const ucfirst = (str: string) => `${str[0].toUpperCase()}${str.slice(1)}`; diff --git a/ui/analyse/src/explorer/explorerView.ts b/ui/analyse/src/explorer/explorerView.ts index 7fd4d59b07..18ad34ce1d 100644 --- a/ui/analyse/src/explorer/explorerView.ts +++ b/ui/analyse/src/explorer/explorerView.ts @@ -4,7 +4,7 @@ import { perf } from 'game/perf'; import { bind, dataIcon, MaybeVNode } from 'common/snabbdom'; import { defined } from 'common'; import { view as renderConfig } from './explorerConfig'; -import { winnerOf } from './explorerUtil'; +import { ucfirst, winnerOf } from './explorerUtil'; import AnalyseCtrl from '../ctrl'; import { isOpening, @@ -155,7 +155,7 @@ function showGameTable(ctrl: AnalyseCtrl, title: string, games: OpeningGame[]): game.speed && h('i', { attrs: { - title: game.speed, + title: ucfirst(game.speed), ...dataIcon(perf.icons[game.speed]), }, }) diff --git a/ui/analyse/src/explorer/explorerXhr.ts b/ui/analyse/src/explorer/explorerXhr.ts index 4d27f070bf..0804796364 100644 --- a/ui/analyse/src/explorer/explorerXhr.ts +++ b/ui/analyse/src/explorer/explorerXhr.ts @@ -29,7 +29,10 @@ export async function opening( params.set('play', opts.play.join(',')); if (opts.db === 'lichess') { params.set('variant', opts.variant || 'standard'); - for (const speed of conf.speed()) params.append('speeds[]', speed); + conf + .speed() + .filter(s => s != 'ultraBullet' && s != 'correspondence') + .forEach(s => params.append('speeds[]', s)); for (const rating of conf.rating()) params.append('ratings[]', rating.toString()); } if (opts.db === 'player') { diff --git a/ui/analyse/src/explorer/interfaces.ts b/ui/analyse/src/explorer/interfaces.ts index 60debfd348..2fdf18f7b2 100644 --- a/ui/analyse/src/explorer/interfaces.ts +++ b/ui/analyse/src/explorer/interfaces.ts @@ -5,7 +5,7 @@ export interface Hovering { export type ExplorerDb = 'lichess' | 'masters' | 'player'; -export type ExplorerSpeed = 'bullet' | 'blitz' | 'rapid' | 'classical'; +export type ExplorerSpeed = Speed; export type ExplorerMode = 'casual' | 'rated'; export interface PlayerOpts {