Skip to content

Commit

Permalink
show opening name as tooltip for explorer moves (closes lichess-org#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Nov 9, 2024
1 parent 6fd1e79 commit 169f025
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ui/analyse/src/explorer/explorerView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,21 @@ function showMoveTable(ctrl: AnalyseCtrl, data: OpeningData): VNode | null {
movesWithCurrent.map(move => {
const total = move.white + move.draws + move.black;
return h(`tr${move.uci ? '' : '.sum'}`, { key: move.uci, attrs: { 'data-uci': move.uci } }, [
h('td', move.san[0] === 'P' ? move.san.slice(1) : move.san),
h(
'td',
{ attrs: { title: move.opening ? `${move.opening.eco}: ${move.opening.name}` : '' } },
move.san,
),
h('td', ((total / sumTotal) * 100).toFixed(0) + '%'),
h('td', numberFormat(total)),
h('td', { attrs: { title: moveTooltip(ctrl, move) } }, resultBar(move)),
h('td', { attrs: { title: moveStatsTooltip(ctrl, move) } }, resultBar(move)),
]);
}),
),
]);
}

function moveTooltip(ctrl: AnalyseCtrl, move: OpeningMoveStats): string {
function moveStatsTooltip(ctrl: AnalyseCtrl, move: OpeningMoveStats): string {
if (!move.uci) return 'Total';
if (move.game) {
const g = move.game;
Expand Down
1 change: 1 addition & 0 deletions ui/analyse/src/explorer/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export interface OpeningMoveStats extends MoveStats {
averageOpponentRating?: number;
performance?: number;
game?: OpeningGame;
opening?: Opening;
}
export interface TablebaseMoveStats extends MoveStats {
dtz: number | null;
Expand Down

0 comments on commit 169f025

Please sign in to comment.