reusable snapshot header, field-label, and load-progress UI components

This commit is contained in:
jarek committed 2026-08-09 10:31:28 +02:00
1 parent 16451d95d7
commit c33c404259
5 files changed
+119

No files matched your search

@@ -0,0 +1,20 @@
<script lang="ts">
import { Label } from '$lib/components/ui/label';
// Form field label with a consistent required/optional marker: a red "*" glued to
// the label text for required fields, a muted "(optional)" suffix otherwise. Keeps
// every form's marker identical instead of each field hand-rolling its own span.
interface Props {
label: string;
forId?: string;
required?: boolean;
/** Show "(optional)" when not required. Off for forms that only mark required. */
showOptional?: boolean;
}
let { label, forId, required = false, showOptional = true }: Props = $props();
</script>
<Label for={forId}>
<span>{label}{#if required}<span class="text-destructive">&nbsp;*</span>{/if}</span>
{#if !required && showOptional}<span class="text-muted-foreground text-xs font-normal">(optional)</span>{/if}
</Label>
@@ -0,0 +1,7 @@
import Root from "./field-label.svelte";
export {
Root,
//
Root as FieldLabel,
};
@@ -0,0 +1,7 @@
import Root from "./snapshot-load-progress.svelte";
export {
Root,
//
Root as SnapshotLoadProgress,
};
@@ -0,0 +1,23 @@
<script lang="ts">
import { Loader2 } from 'lucide-svelte';
// Progress indicator for the per-destination snapshot sweep. Each backup repo is
// queried separately and a slow/unreachable one can take up to the backend's restic
// timeout (5 min), so we show "X of N repos" rather than an indeterminate spinner -
// the user sees it advancing instead of wondering if it hung. Shared across the
// Backups page and the container/stack snapshot panels.
interface Props {
done: number;
total: number;
/** Extra classes for the wrapper (sizing/spacing per call site). */
class?: string;
}
let { done, total, class: className = '' }: Props = $props();
</script>
<span class="flex items-center gap-1.5 text-xs text-muted-foreground {className}">
<Loader2 class="w-3.5 h-3.5 animate-spin" />
<!-- The "X of N repos" count only adds information with more than one repo; with a
single repo it reads oddly ("1 of 1"), so just say "Loading snapshots…". -->
Loading snapshots…{#if total > 1} {done} of {total} repos{/if}
</span>