Skip to content

Commit

Permalink
update seek creation UI
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Aug 28, 2024
1 parent cdee6ec commit 1aa7469
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
11 changes: 6 additions & 5 deletions ui/lobby/src/view/setup/components/colorButtons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,18 @@ const renderBlindModeColorPicker = (ctrl: LobbyController) => [
),
];

export const colorButtons = (ctrl: LobbyController) => {
export const createButtons = (ctrl: LobbyController) => {
const { setupCtrl } = ctrl;

const enabledColors: (Color | 'random')[] = [];
if (setupCtrl.valid()) {
enabledColors.push('random');

const randomColorOnly =
setupCtrl.gameType !== 'ai' &&
setupCtrl.gameMode() === 'rated' &&
variantsWhereWhiteIsBetter.includes(setupCtrl.variant());
setupCtrl.gameType === 'hook' ||
(setupCtrl.gameType !== 'ai' &&
setupCtrl.gameMode() === 'rated' &&
variantsWhereWhiteIsBetter.includes(setupCtrl.variant()));
if (!randomColorOnly) enabledColors.push('white', 'black');
}

Expand All @@ -52,7 +53,7 @@ export const colorButtons = (ctrl: LobbyController) => {
`button.button.button-metal.color-submits__button.${key}`,
{
attrs: { disabled: !enabledColors.includes(key), title: name, value: key },
on: { click: () => ctrl.setupCtrl.submit(key) },
on: { click: () => setupCtrl.submit(key) },
},
h('i'),
),
Expand Down
8 changes: 4 additions & 4 deletions ui/lobby/src/view/setup/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { variantPicker } from './components/variantPicker';
import { timePickerAndSliders } from './components/timePickerAndSliders';
import { gameModeButtons } from './components/gameModeButtons';
import { ratingDifferenceSliders } from './components/ratingDifferenceSliders';
import { colorButtons } from './components/colorButtons';
import { createButtons } from './components/colorButtons';
import { ratingView } from './components/ratingView';
import { fenInput } from './components/fenInput';
import { levelButtons } from './components/levelButtons';
Expand All @@ -31,7 +31,7 @@ const views = {
timePickerAndSliders(ctrl),
gameModeButtons(ctrl),
ratingDifferenceSliders(ctrl),
colorButtons(ctrl),
createButtons(ctrl),
]),
],
friend: (ctrl: LobbyController): MaybeVNodes => [
Expand All @@ -42,7 +42,7 @@ const views = {
fenInput(ctrl),
timePickerAndSliders(ctrl, true),
gameModeButtons(ctrl),
colorButtons(ctrl),
createButtons(ctrl),
]),
],
ai: (ctrl: LobbyController): MaybeVNodes => [
Expand All @@ -52,7 +52,7 @@ const views = {
fenInput(ctrl),
timePickerAndSliders(ctrl, true),
...levelButtons(ctrl),
colorButtons(ctrl),
createButtons(ctrl),
]),
],
};

0 comments on commit 1aa7469

Please sign in to comment.