Phase 2: core converter, live conversion, URL state, highlight interaction
This commit is contained in:
30
src/components/UnitInput.svelte
Normal file
30
src/components/UnitInput.svelte
Normal file
@@ -0,0 +1,30 @@
|
||||
<script lang="ts">
|
||||
/**
|
||||
* UnitInput — controlled numeric input.
|
||||
* Phase 2: number input only. NL field added in Phase 3.
|
||||
*/
|
||||
|
||||
let {
|
||||
value,
|
||||
onchange
|
||||
}: {
|
||||
value: number;
|
||||
onchange: (v: number) => void;
|
||||
} = $props();
|
||||
|
||||
function handleInput(e: Event) {
|
||||
const input = e.currentTarget as HTMLInputElement;
|
||||
const parsed = parseFloat(input.value);
|
||||
if (!isNaN(parsed)) {
|
||||
onchange(parsed);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<input
|
||||
type="number"
|
||||
step="any"
|
||||
value={value}
|
||||
oninput={handleInput}
|
||||
aria-label="Input value"
|
||||
/>
|
||||
Reference in New Issue
Block a user