~james/core

core/web/src/lib/components/repo/RepoCard.svelte -rw-r--r-- 1.5 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
51
52
53
54
55
56
57
58
59
<script lang="ts">
	import { resolve } from "$app/paths";
	import type { Snippet } from "svelte";
	import Card, { type CardVariants } from "#lib/components/ui/Card.svelte";
	import RepoCardContent from "#lib/components/repo/RepoCardContent.svelte";
	import type { RepoCardData, StarChange } from "#lib/components/profile/types.ts";
	import { navigatingTo } from "#lib/navPulse.ts";
	let {
		repo,
		starButton = true,
		showOwner = true,
		uniformHeight = false,
		layout = "card",
		links = true,
		border = true,
		background = true,
		padding = "regular",
		onStar,
		action,
		class: className
	}: {
		repo: RepoCardData;
		onStar?: (change: StarChange) => void;
		starButton?: boolean;
		showOwner?: boolean;
		uniformHeight?: boolean;
		layout?: "card" | "row";
		links?: boolean;
		border?: CardVariants["border"];
		background?: CardVariants["background"];
		padding?: CardVariants["padding"];
		action?: Snippet;
		class?: string;
	} = $props();

	const href = $derived(resolve(`/${repo.ownerHandle}/${repo.name}` as "/"));
</script>

{#snippet body()}
	<RepoCardContent {repo} {starButton} {showOwner} {uniformHeight} {layout} {links} {onStar} />
{/snippet}

<Card
	{border}
	{background}
	{padding}
	class={[navigatingTo(href) && "row-breathe", className].filter(Boolean).join(" ") || undefined}
>
	{#if action}
		<div class="flex h-full items-start gap-sm">
			<div class="flex min-w-0 flex-1 flex-col self-stretch">
				{@render body()}
			</div>
			{@render action()}
		</div>
	{:else}
		{@render body()}
	{/if}
</Card>