Skip to content

Commit

Permalink
fix ScoreOptions height in Safari, set default wait to 1.5 secs
Browse files Browse the repository at this point in the history
  • Loading branch information
TeemuKoivisto committed Apr 4, 2024
1 parent 9d30fcf commit 6753c61
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
40 changes: 19 additions & 21 deletions packages/client/src/components/play/GameOptions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,38 @@
import { gameActions, gameOptions } from '$stores/game'
let count = $gameOptions.count || ''
let waitSeconds = $gameOptions.waitSeconds || ''
let count = $gameOptions.count.toString()
let waitSeconds = $gameOptions.waitSeconds.toString()
gameOptions.subscribe(v => {
count = v.count || ''
waitSeconds = v.waitSeconds || ''
count = v.count.toString()
waitSeconds = v.waitSeconds.toString()
})
function handleCountChanged({
currentTarget: { value }
}: Event & { currentTarget: EventTarget & HTMLInputElement }) {
function handleCountChanged(e: Event & { currentTarget: EventTarget & HTMLInputElement }) {
let int
try {
int = parseInt(value)
if (int <= 0) {
int = parseInt(e.currentTarget.value)
if (int <= 0 || isNaN(int)) {
int = 1
}
gameActions.setOptionValue('count', int)
e.currentTarget.blur()
} catch (err) {
count = $gameOptions.count
count = $gameOptions.count.toString()
}
}
function handleWaitChanged({
currentTarget: { value }
}: Event & { currentTarget: EventTarget & HTMLInputElement }) {
let int
function handleWaitChanged(e: Event & { currentTarget: EventTarget & HTMLInputElement }) {
let n
try {
int = parseInt(value)
if (int < 0) {
int = 0
n = parseFloat(e.currentTarget.value)
if (n < 0 || isNaN(n)) {
n = 0
}
gameActions.setOptionValue('waitSeconds', int)
gameActions.setOptionValue('waitSeconds', n)
e.currentTarget.blur()
} catch (err) {
waitSeconds = $gameOptions.waitSeconds
waitSeconds = $gameOptions.waitSeconds.toString()
}
}
</script>
Expand All @@ -49,7 +47,7 @@
id="guess-count"
type="number"
bind:value={count}
on:input={handleCountChanged}
on:change={handleCountChanged}
/>
</li>
<li class="flex items-center justify-between items-center mr-6">
Expand All @@ -75,7 +73,7 @@
id="wait-ms"
type="number"
bind:value={waitSeconds}
on:input={handleWaitChanged}
on:change={handleWaitChanged}
/>
</li>
</ul>
Expand Down
6 changes: 3 additions & 3 deletions packages/client/src/components/play/ScoreOptions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<Icon icon={restore} width={16} />
</button>
<div class="options" class:hidden={$hidden}>
<div class="range flex flex-col h-full">
<div class="range flex flex-col">
<label class="font-bold" for="range_min">Range</label>
<div class="my-1 flex w-full">
<input
Expand All @@ -125,7 +125,7 @@
{/if}
</div>
</div>
<div class="flex flex-col h-full">
<div class="flex flex-col">
<label class="font-bold" for="score-scale">Scale</label>
<div class="scale-dropdown my-1 w-full">
<SearchDropdown
Expand All @@ -144,7 +144,7 @@
</div>
{/if}
</div>
<div class="flex flex-col h-full">
<div class="flex flex-col">
<label class="font-bold" for="key">Key</label>
<div class="my-1 flex">
<input class="h-[28px]" id="key" bind:value={selectedKey} on:input={handleKeyChange} />
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/stores/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const DEFAULT_OPTIONS = {
count: 10,
duplicates: true,
autoplay: true,
waitSeconds: 3
waitSeconds: 1.5
}

export const guessState = writable<GuessState>('waiting')
Expand Down

0 comments on commit 6753c61

Please sign in to comment.