-
Notifications
You must be signed in to change notification settings - Fork 146
Expand file tree
/
Copy pathdetail-list-timestamp-value.svelte
More file actions
44 lines (36 loc) · 1.13 KB
/
detail-list-timestamp-value.svelte
File metadata and controls
44 lines (36 loc) · 1.13 KB
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
<script lang="ts">
import type { Snippet } from 'svelte';
import Tooltip from '$lib/holocene/tooltip.svelte';
import { relativeTime } from '$lib/stores/time-format';
import type { ValidTime } from '$lib/utilities/format-time';
import { timestamp } from '../timestamp.svelte';
import DetailListValue from './detail-list-value.svelte';
interface Props {
timestamp: ValidTime | undefined | null;
children?: Snippet;
fallback?: string;
}
let { timestamp: t, children, fallback }: Props = $props();
let formattedTimestamp = $derived(
t ? $timestamp(t) : fallback ? fallback : '',
);
let relativeTimestamp = $derived(
t ? $timestamp(t, { relative: true }) : fallback ? fallback : '',
);
</script>
{#snippet content()}
<div class="flex select-all items-center gap-1 truncate rounded-sm">
{$relativeTime ? relativeTimestamp : formattedTimestamp}
</div>
{/snippet}
<DetailListValue class="font-mono">
<Tooltip
hide={!t}
text={$relativeTime ? formattedTimestamp : relativeTimestamp}
top
class="min-w-0"
>
{@render content()}
{@render children?.()}
</Tooltip>
</DetailListValue>