Skip to content

Commit 7c1faa1

Browse files
committed
more QoL
1 parent d8d33da commit 7c1faa1

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/japanese/exercises/kana-typer/KanaTyper.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const game = makeAutoObservable({
2525
timer: undefined as
2626
| undefined
2727
| { handle: number; startedAtMs: number; timeLeftMs: number },
28-
timeLimitMs: 0,
28+
timeLimitMs: 30_000,
2929
finished: false,
3030
enabledKanas: [] as string[],
3131
dakuten: true,
@@ -44,7 +44,6 @@ const game = makeAutoObservable({
4444
this.kanasNext = this.generateKanas(this.kanas.last()!.idx + 1);
4545
clearInterval(this.timer?.handle);
4646
this.timer = undefined;
47-
this.timeLimitMs = 30_000;
4847
this.finished = false;
4948
},
5049

@@ -69,7 +68,7 @@ const game = makeAutoObservable({
6968
},
7069

7170
onInput(evt: SyntheticEvent<HTMLInputElement>): void {
72-
if (!this.timer && !this.finished) {
71+
if (!this.timer && !this.finished && this.timeLimitMs) {
7372
this.timer = {
7473
handle: setInterval(() => {
7574
this.tick();
@@ -240,11 +239,24 @@ function KanaTyperSettings() {
240239
down
241240
bg="white"
242241
pad={8}
242+
gap={8}
243243
border="1px solid black"
244244
style={{ minWidth: 350 }}
245245
>
246246
<h3>Selected Kana</h3>
247-
<Flex>
247+
<Flex itemsPlacement="center">
248+
Time in seconds{" "}
249+
<input
250+
value={game.timeLimitMs / 1000}
251+
onChange={(evt) => {
252+
const parsed = Number.parseFloat(evt.target.value);
253+
if (parsed != null && !Number.isNaN(parsed)) {
254+
game.timeLimitMs = parsed * 1000;
255+
}
256+
}}
257+
/>
258+
</Flex>
259+
<Flex gap={8}>
248260
<CheckBox
249261
checked={game.dakuten}
250262
onChange={(val) => {

0 commit comments

Comments
 (0)