Skip to content

Commit

Permalink
TS code golf
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Jul 31, 2022
1 parent 9d4085a commit 2c6c277
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
15 changes: 5 additions & 10 deletions ui/round/src/ground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,12 @@ export function makeConfig(ctrl: RoundController): Config {
};
}

export function reload(ctrl: RoundController) {
ctrl.chessground.set(makeConfig(ctrl));
}
export const reload = (ctrl: RoundController) => ctrl.chessground.set(makeConfig(ctrl));

export function boardOrientation(data: RoundData, flip: boolean): Color {
if (data.game.variant.key === 'racingKings') return flip ? 'black' : 'white';
else return flip ? data.opponent.color : data.player.color;
}
export const boardOrientation = (data: RoundData, flip: boolean): Color =>
data.game.variant.key === 'racingKings' ? (flip ? 'black' : 'white') : flip ? data.opponent.color : data.player.color;

export function render(ctrl: RoundController) {
return h('div.cg-wrap', {
export const render = (ctrl: RoundController) =>
h('div.cg-wrap', {
hook: util.onInsert(el => ctrl.setChessground(Chessground(el, makeConfig(ctrl)))),
});
}
4 changes: 1 addition & 3 deletions ui/round/src/title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ function startTicker() {
if (!tickerTimer) tickerTimer = setTimeout(tick, 200);
}

export function init() {
window.addEventListener('focus', resetTicker);
}
export const init = () => window.addEventListener('focus', resetTicker);

export function set(ctrl: RoundController, text?: string) {
if (ctrl.data.player.spectator) return;
Expand Down

0 comments on commit 2c6c277

Please sign in to comment.