~james/core

core/web/src/lib/components/ui/ConfirmModal.svelte -rw-r--r-- 883 bytes
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 15 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<script lang="ts">
	import Modal from "#lib/components/ui/Modal.svelte";
	import Button, { type ButtonVariants } from "#lib/components/ui/Button.svelte";

	interface Props {
		open?: boolean;
		title: string;
		description?: string;
		confirmLabel: string;
		variant?: ButtonVariants["variant"];
		cancelLabel?: string;
		loading?: boolean;
		onconfirm: () => void;
		testid?: string;
	}

	let {
		open = $bindable(false),
		title,
		description,
		confirmLabel,
		variant = "destructive",
		cancelLabel = "Cancel",
		loading = false,
		onconfirm,
		testid
	}: Props = $props();
</script>

{#snippet footer()}
	<Button class="flex-1" disabled={loading} onclick={() => (open = false)}>
		{cancelLabel}
	</Button>
	<Button {variant} class="flex-1" {loading} onclick={onconfirm}>
		{confirmLabel}
	</Button>
{/snippet}

<Modal bind:open {title} {description} {footer} {testid}></Modal>