~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0
55 lines · 941 B Raw History
<script lang="ts">
	import Field from '#lib/molecules/Field.svelte';
	import { words } from '#lib/words';

	// The email code form: what was sent, and the code. Its submit button,
	// in the view's actions, names it by `id`.
	let {
		id,
		sentence,
		code = $bindable(''),
		codeField = $bindable(),
		describedby,
		onsubmit
	}: {
		id: string;
		sentence: string;
		code?: string;
		codeField?: HTMLInputElement;
		describedby?: string;
		onsubmit: () => void;
	} = $props();
</script>

<form
	class="form"
	{id}
	onsubmit={(e) => {
		e.preventDefault();
		onsubmit();
	}}
>
	<p class="sent">{sentence}</p>
	<Field
		id="code"
		label={words.code}
		autocomplete="one-time-code"
		{describedby}
		invalid={!!describedby}
		bind:value={code}
		bind:element={codeField}
	/>
</form>

<style>
	.form {
		display: flex;
		flex-direction: column;
		gap: var(--space-4);
	}

	.sent {
		color: var(--mute);
		overflow-wrap: anywhere;
	}
</style>