~james/core

core/web/src/lib/components/settings/SettingsSaveBar.svelte -rw-r--r-- 864 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
<script lang="ts">
	import Button from "#lib/components/ui/Button.svelte";
	import Save from "$icon/save";
	import RotateCcw from "$icon/rotate-ccw";

	interface Props {
		dirty: boolean;
		saving?: boolean;
		onreset?: () => void;
		onsave?: () => void;
	}

	let { dirty, saving = false, onreset, onsave }: Props = $props();
</script>

<div class="contents sm:flex sm:shrink-0 sm:items-center sm:gap-md">
	{#if dirty}
		<div
			class="order-last flex w-full items-center justify-between gap-md sm:order-0 sm:w-auto"
		>
			<Button icon={RotateCcw} onclick={onreset}>Reset</Button>
			<span
				data-testid="unsavedChanges"
				class="typography-paragraph-regular text-foreground-muted">Unsaved changes</span
			>
		</div>
	{/if}
	<Button
		variant="primary"
		icon={Save}
		disabled={!dirty || saving}
		loading={saving}
		onclick={onsave}>Save</Button
	>
</div>