Skip to content

Commit 39f1975

Browse files
committed
Add hint delay options
1 parent 5e26541 commit 39f1975

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
.hint-0 {
1414
opacity: 0;
15-
animation-delay: 2s;
15+
animation-delay: calc(var(--hint-delay-ms) * 1ms);
1616
animation-fill-mode: forwards;
1717
animation-name: fadeIn;
1818
animation-timing-function: ease-in;
@@ -21,7 +21,7 @@
2121

2222
.hint-1 {
2323
opacity: 0;
24-
animation-delay: 4s;
24+
animation-delay: calc(var(--hint-delay-ms) * 2ms);
2525
animation-fill-mode: forwards;
2626
animation-name: fadeIn;
2727
animation-timing-function: ease-in;

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const game = makeAutoObservable({
3333
handakuten: true,
3434
saveInLocalStorage: false,
3535
kanaLikelyhood: {} as { [key: string]: number },
36+
hintDelayMs: 4000,
3637

3738
reset(): void {
3839
this.currentInput = "";
@@ -172,6 +173,7 @@ const game = makeAutoObservable({
172173
this.dakuten = json.dakuten;
173174
this.handakuten = json.handakuten;
174175
this.kanaLikelyhood = json.kanaLikelyhood || {};
176+
this.hintDelayMs = json.hintDelayMs;
175177
}
176178
},
177179

@@ -186,6 +188,7 @@ const game = makeAutoObservable({
186188
dakuten: this.dakuten,
187189
handakuten: this.handakuten,
188190
kanaLikelyhood: this.kanaLikelyhood,
191+
hintDelayMs: this.hintDelayMs,
189192
}),
190193
);
191194
} else {
@@ -215,7 +218,10 @@ export function KanaTyper() {
215218
: `Time left: ${(game.timer.timeLeftMs / 1000).toFixed(2)}`}
216219
</div>
217220
<br />
218-
<div className="kanas-to-type">
221+
<div
222+
className="kanas-to-type"
223+
style={{ "--hint-delay-ms": game.hintDelayMs } as any}
224+
>
219225
{[game.kanasPrev, game.kanas, game.kanasNext].map((row, idx) => (
220226
<Flex
221227
key={idx}
@@ -341,6 +347,21 @@ function KanaTyperSettings() {
341347
}}
342348
/>
343349
</Flex>
350+
<Flex itemsPlacement="center">
351+
Hint delay in seconds{" "}
352+
<input
353+
value={game.hintDelayMs / 1000}
354+
onChange={(evt) => {
355+
const parsed = Number.parseFloat(evt.target.value);
356+
if (parsed != null && !Number.isNaN(parsed)) {
357+
game.hintDelayMs = parsed * 1000;
358+
} else {
359+
game.hintDelayMs = 0;
360+
}
361+
}}
362+
/>
363+
</Flex>
364+
344365
<Flex gap={8}>
345366
<CheckBox
346367
checked={game.dakuten}

0 commit comments

Comments
 (0)