~james/core

ref: 452f17b75181d62d1d92016edecd38e1d70fecab core/web/src/lib/components/strings/StringView.svelte -rw-r--r-- 1.6 KiB
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 17 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
60
61
62
63
64
65
66
67
68
<script lang="ts">
	import { stringRawHref } from "#lib/components/strings/urls.ts";
	import type { RepoBlobView } from "#lib/api/blob.ts";
	import type { MarkupContext } from "#lib/markup/paths.ts";
	import { compactRelativeTime } from "#lib/format.ts";
	import type { StringRecord } from "#lib/api/records.ts";
	import BlobView from "#lib/components/repo/BlobView.svelte";
	import StringHeader from "#lib/components/strings/StringHeader.svelte";

	interface Props {
		ownerHandle: string;
		ownerDid: string;
		rkey: string;
		string: StringRecord;
		blob: RepoBlobView;
		markup: MarkupContext;
		isOwner?: boolean;
		uri: string;
		cid?: string;
		starCount: number | Promise<number>;
		viewerStarRkey: string | null | Promise<string | null>;
		onedit?: () => void;
		ondelete?: () => void;
		deleting?: boolean;
	}

	let {
		ownerHandle,
		ownerDid,
		rkey,
		string,
		blob,
		markup,
		isOwner = false,
		uri,
		cid,
		starCount,
		viewerStarRkey,
		onedit,
		ondelete,
		deleting = false
	}: Props = $props();

	const rawHref = $derived(stringRawHref(ownerHandle, rkey));
	const timeLabel = $derived(`Created ${compactRelativeTime(string.createdAt)}`);
</script>

<div class="flex flex-col gap-xl">
	<div class="px-md">
		<StringHeader
			{ownerHandle}
			{ownerDid}
			{rkey}
			filename={blob.path}
			description={string.description}
			{isOwner}
			stringUri={uri}
			stringCid={cid}
			initialStarCount={starCount}
			initialStarRkey={viewerStarRkey}
			{onedit}
			{ondelete}
			{deleting}
		/>
	</div>

	<BlobView {ownerHandle} {blob} {markup} {rawHref} {timeLabel} />
</div>