Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 25 additions & 47 deletions ui/chart/src/division.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
import { Division } from './interface';

const divisionLine = (division: string, ply: number) => {
const textWeak = window.Highcharts.theme.lichess.text.weak;
return {
label: {
text: division,
verticalAlign: 'top',
align: 'left',
y: 0,
style: {
color: textWeak,
},
},
color: textWeak,
width: 1,
value: ply,
zIndex: 5,
};
};

export default function (div: Division | undefined, trans: Trans) {
const lines = [];
lines.push({
Expand All @@ -8,54 +27,13 @@ export default function (div: Division | undefined, trans: Trans) {
value: 0,
zIndex: 6,
});
const textWeak = window.Highcharts.theme.lichess.text.weak;
if (div?.middle) {
lines.push({
label: {
text: trans('opening'),
verticalAlign: 'top',
align: 'left',
y: 0,
style: {
color: textWeak,
},
},
color: textWeak,
width: 1,
value: 0,
zIndex: 5,
});
lines.push({
label: {
text: trans('middlegame'),
verticalAlign: 'top',
align: 'left',
y: 0,
style: {
color: textWeak,
},
},
color: textWeak,
width: div.middle === null ? 0 : 1,
value: div.middle,
zIndex: 5,
});
if (div.middle > 1) lines.push(divisionLine(trans('opening'), 0));
lines.push(divisionLine(trans('middlegame'), div.middle - 1));
}
if (div?.end) {
if (div.end > 1 && !div?.middle) lines.push(divisionLine(trans('middlegame'), 0));
lines.push(divisionLine(trans('endgame'), div.end - 1));
}
if (div?.end)
lines.push({
label: {
text: trans('endgame'),
verticalAlign: 'top',
align: 'left',
y: 0,
style: {
color: textWeak,
},
},
color: textWeak,
width: div.end === null ? 0 : 1,
value: div.end,
zIndex: 5,
});
return lines;
}