~james/core

core/web/src/lib/components/timeline/PreviewCard.svelte -rw-r--r-- 1.4 KiB
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 16 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
<script lang="ts">
	import type { Component, Snippet } from "svelte";
	import type { SvelteHTMLElements } from "svelte/elements";
	import LayerCard from "#lib/components/ui/LayerCard.svelte";
	import LayerCardPrimary from "#lib/components/ui/LayerCardPrimary.svelte";
	import LayerCardSecondary from "#lib/components/ui/LayerCardSecondary.svelte";

	interface Props {
		title: string;
		icon: Component<SvelteHTMLElements["svg"]>;
		/** an unresolved app path; when set the heading itself links, as the
		 * notifications card does */
		href?: string;
		/** trailing content in the header row, e.g. a "view all" link */
		action?: Snippet;
		children: Snippet;
	}

	let { title, icon, href, action, children }: Props = $props();

	const Icon = $derived(icon);
</script>

{#snippet heading()}
	<h3 class="flex items-center gap-xs text-black dark:text-white">
		<Icon class="size-4 shrink-0" aria-hidden="true" />
		{title}
	</h3>
{/snippet}

<LayerCard>
	<LayerCardSecondary class="min-h-[calc(2.5rem-2*var(--layer-gap))] justify-between py-0 pr-0">
		{#if href}
			<!-- 
			<a
				href={resolve(href as "/")}
				class="flex flex-1 items-center px-sm py-xs no-underline hover:no-underline"
			>
			</a> 
			-->
			{@render heading()}
		{:else}
			{@render heading()}
		{/if}
		{@render action?.()}
	</LayerCardSecondary>
	<LayerCardPrimary padding="none">
		{@render children()}
	</LayerCardPrimary>
</LayerCard>