flotilla/src/app/components/EventItem.svelte

25 lines
927 B
Svelte
Raw Normal View History

2024-09-20 18:00:41 +00:00
<script lang="ts">
import {fromPairs} from "@welshman/lib"
2024-12-09 22:03:59 +00:00
import {formatTimestamp, formatTimestampAsDate, formatTimestampAsTime} from "@welshman/app"
2024-09-20 18:00:41 +00:00
import Icon from "@lib/components/Icon.svelte"
const {event} = $props()
2024-09-20 18:00:41 +00:00
const meta = $derived(fromPairs(event.tags) as Record<string, string>)
const end = $derived(parseInt(meta.end))
const start = $derived(parseInt(meta.start))
const startDateDisplay = $derived(formatTimestampAsDate(start))
const endDateDisplay = $derived(formatTimestampAsDate(end))
const isSingleDay = $derived(startDateDisplay === endDateDisplay)
2024-09-20 18:00:41 +00:00
</script>
2024-09-23 20:58:01 +00:00
<div class="card2 flex items-center justify-between gap-2">
2024-09-20 18:00:41 +00:00
<span>{meta.title || meta.name}</span>
<div class="flex items-center gap-2 text-sm">
<Icon icon="clock-circle" size={4} />
2024-12-09 22:03:59 +00:00
{formatTimestampAsTime(start)} — {isSingleDay
? formatTimestampAsTime(end)
: formatTimestamp(end)}
2024-09-20 18:00:41 +00:00
</div>
</div>