feat: sentence trainer custom prompt

resolves #162
This commit is contained in:
2025-02-14 15:31:17 +01:00
parent f319714489
commit fb5959998a
2 changed files with 24 additions and 9 deletions

View File

@@ -30,8 +30,6 @@
return a + (b - a) * t; return a + (b - a) * t;
} }
$inspect(chords);
$effect(() => { $effect(() => {
const [chord] = chords; const [chord] = chords;
if (!chord) return; if (!chord) return;

View File

@@ -11,7 +11,8 @@
import { onMount } from "svelte"; import { onMount } from "svelte";
import TrackText from "$lib/charrecorder/TrackText.svelte"; import TrackText from "$lib/charrecorder/TrackText.svelte";
import { browser } from "$app/environment"; import { browser } from "$app/environment";
import { expoIn, expoOut } from "svelte/easing"; import { expoOut } from "svelte/easing";
import { goto } from "$app/navigation";
function viaLocalStorage<T>(key: string, initial: T) { function viaLocalStorage<T>(key: string, initial: T) {
try { try {
@@ -66,18 +67,18 @@
let idleTimeout: ReturnType<typeof setTimeout> | null = null; let idleTimeout: ReturnType<typeof setTimeout> | null = null;
let cooldown = $state(false);
onMount(() => {
selectNextWord();
});
$effect(() => { $effect(() => {
if (wpm > bestWPM) { if (wpm > bestWPM) {
bestWPM = wpm; bestWPM = wpm;
} }
}); });
$effect(() => {
if (browser && $page.url.searchParams) {
selectNextWord();
}
});
$effect(() => { $effect(() => {
localStorage.setItem("idle-timeout", idleTime.toString()); localStorage.setItem("idle-timeout", idleTime.toString());
}); });
@@ -219,6 +220,15 @@
<div> <div>
<h1>Sentence Trainer</h1> <h1>Sentence Trainer</h1>
<input
type="text"
value={inputSentence}
onchange={(it) => {
const params = new URLSearchParams(window.location.search);
params.set("sentence", (it.target as HTMLInputElement).value);
goto(`?${params.toString()}`);
}}
/>
<div class="levels"> <div class="levels">
{#each masteryThresholds as [, , title], i} {#each masteryThresholds as [, , title], i}
@@ -577,4 +587,11 @@
opacity: 1; opacity: 1;
} }
} }
input[type="text"] {
background: none;
color: inherit;
font: inherit;
border: none;
}
</style> </style>