~james/core

core/web/src/lib/components/ui/HiddenContent.svelte -rw-r--r-- 1.3 KiB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
<script module lang="ts">
	import { tv, type VariantProps } from "tailwind-variants";

	export const hiddenContent = tv({
		base: "flex flex-wrap items-center gap-x-xs gap-y-2xs text-foreground-muted not-italic",
		variants: {
			size: {
				small: "typography-paragraph-small",
				regular: "typography-paragraph-regular"
			}
		},
		defaultVariants: {
			size: "small"
		}
	});

	export type HiddenContentSize = NonNullable<VariantProps<typeof hiddenContent>["size"]>;
</script>

<script lang="ts">
	import TriangleAlert from "$icon/triangle-alert";
	import Button from "#lib/components/ui/Button.svelte";
	import Card from "#lib/components/ui/Card.svelte";

	interface Props {
		message: string;
		action?: { label: string; onclick: () => void };
		size?: HiddenContentSize;
		icon?: boolean;
		class?: string;
	}

	let { message, action, size = "small", icon = true, class: className }: Props = $props();
</script>

<Card
	border={false}
	background={false}
	rounded={false}
	padding="none"
	class={hiddenContent({ size, class: className })}
>
	<span class="flex min-w-0 flex-[1_1_12rem] items-center gap-xs">
		{#if icon}
			<TriangleAlert class="size-4 shrink-0" aria-hidden="true" />
		{/if}
		<span class="min-w-0">{message}</span>
	</span>
	{#if action}
		<Button size="small" onclick={action.onclick}>{action.label}</Button>
	{/if}
</Card>