Skip to content

Commit

Permalink
fix hiding empty players
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Nov 14, 2023
1 parent 10a59f0 commit 6bf0ca8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/view/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ export default function view(ctrl: PgnViewer) {
staticClasses = `lpv.lpv--moves-${opts.showMoves}.lpv--controls-${opts.showControls}${
opts.classes ? '.' + opts.classes.replace(' ', '.') : ''
}`;
const showPlayers = opts.showPlayers == 'auto' ? ctrl.game.hasPlayerName() : opts.showPlayers;
return h(
`div.${staticClasses}`,
{
class: {
'lpv--menu': ctrl.pane != 'board',
'lpv--players': opts.showPlayers == 'auto' ? ctrl.game.hasPlayerName() : opts.showPlayers,
'lpv--players': showPlayers,
},
attrs: {
tabindex: 0,
Expand All @@ -29,13 +30,13 @@ export default function view(ctrl: PgnViewer) {
}),
},
[
opts.showPlayers ? renderPlayer(ctrl, 'top') : undefined,
showPlayers ? renderPlayer(ctrl, 'top') : undefined,
renderBoard(ctrl),
opts.showPlayers ? renderPlayer(ctrl, 'bottom') : undefined,
showPlayers ? renderPlayer(ctrl, 'bottom') : undefined,
opts.showControls ? renderControls(ctrl) : undefined,
opts.showMoves ? renderMoves(ctrl) : undefined,
ctrl.pane == 'menu' ? renderMenu(ctrl) : ctrl.pane == 'pgn' ? renderPgnPane(ctrl) : undefined,
]
],
);
}

Expand All @@ -52,11 +53,11 @@ const renderBoard = (ctrl: PgnViewer): VNode =>
e.preventDefault();
if (e.deltaY > 0 && scroll) ctrl.goTo('next', false);
else if (e.deltaY < 0 && scroll) ctrl.goTo('prev', false);
})
}),
);
}),
},
h('div.cg-wrap')
h('div.cg-wrap'),
);

const renderPgnPane = (ctrl: PgnViewer): VNode => {
Expand All @@ -70,7 +71,7 @@ const renderPgnPane = (ctrl: PgnViewer): VNode => {
download: ctrl.opts.menu.getPgn.fileName || `${ctrl.game.title()}.pgn`,
},
},
ctrl.translate('download')
ctrl.translate('download'),
),
h('textarea.lpv__pgn__text', ctrl.opts.pgn),
]);
Expand Down

0 comments on commit 6bf0ca8

Please sign in to comment.