~james/core

core/web/src/lib/components/profile/VouchCard.svelte -rw-r--r-- 1.9 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
<script lang="ts">
	import { resolve } from "$app/paths";
	import { canonicalHandle } from "#lib/api/profileIdentifier.ts";
	import ArrowUpRight from "$icon/arrow-up-right";
	import ArrowDownLeft from "$icon/arrow-down-left";
	import TimeAgo from "#lib/components/ui/TimeAgo.svelte";
	import type { VouchData } from "#lib/components/profile/types.ts";

	let { vouch, profileLabel }: { vouch: VouchData; profileLabel: string } = $props();

	const href = $derived(resolve(`/${canonicalHandle(vouch.handle) ?? vouch.did}` as "/"));
	const denounce = $derived(vouch.kind === "denounce");
	const outgoing = $derived(vouch.direction === "outgoing");
	const tone = $derived(
		denounce
			? { bg: "bg-background-danger-subtle", fg: "text-foreground-danger" }
			: { bg: "bg-background-success-subtle", fg: "text-foreground-success" }
	);
</script>

<div class="relative z-10 -ml-md flex items-start gap-sm">
	<div
		class={`flex size-8 shrink-0 items-center justify-center rounded-full border border-border-default ${tone.bg}`}
	>
		{#if outgoing}
			<ArrowUpRight class={`size-5 ${tone.fg}`} aria-hidden="true" />
		{:else}
			<ArrowDownLeft class={`size-5 ${tone.fg}`} aria-hidden="true" />
		{/if}
	</div>

	<div class="mt-2xs flex flex-col gap-2xs">
		<div class="flex flex-wrap items-center gap-2xs text-foreground-default">
			{#if outgoing}
				<span class="font-medium">{profileLabel}</span>
			{:else}
				<a {href} class="font-medium hover:underline">{vouch.handle}</a>
			{/if}
			<span class="text-foreground-subtle">{denounce ? "denounced" : "vouched for"}</span>
			{#if outgoing}
				<a {href} class="font-medium hover:underline">{vouch.handle}</a>
			{:else}
				<span class="font-medium">{profileLabel}</span>
			{/if}
			<TimeAgo
				value={vouch.createdAt}
				class="typography-paragraph-small text-foreground-subtle"
			/>
		</div>
		{#if vouch.reason}
			<p class="typography-paragraph-small text-foreground-subtle">{vouch.reason}</p>
		{/if}
	</div>
</div>