flotilla/src/app/components/CalendarEventHeader.svelte

38 lines
1.2 KiB
Svelte
Raw Normal View History

<script lang="ts">
2026-07-28 16:16:26 +00:00
import {formatTimestamp, formatTimestampAsDate, formatTimestampAsTime} from "@welshman/lib"
import type {TrustedEvent} from "@welshman/util"
2026-07-28 16:16:26 +00:00
import {TimeEvent} from "@welshman/domain"
2025-09-10 22:26:39 +00:00
import ClockCircle from "@assets/icons/clock-circle.svg?dataurl"
import Icon from "@lib/components/Icon.svelte"
2026-07-28 16:16:26 +00:00
import {reader} from "@app/core"
import {getEventTitle} from "@app/calendar"
type Props = {
event: TrustedEvent
}
const {event}: Props = $props()
2026-07-28 16:16:26 +00:00
const timeEvent = $derived(reader(TimeEvent)(event))
2026-07-28 16:16:26 +00:00
const title = $derived(getEventTitle(event))
const start = $derived(timeEvent.start())
const end = $derived(timeEvent.end())
</script>
<div class="flex flex-col justify-between gap-1">
2026-07-28 16:16:26 +00:00
<p class="text-lg">{title}</p>
{#if start && end}
{@const isSingleDay = formatTimestampAsDate(start) === formatTimestampAsDate(end)}
<div class="flex flex-wrap gap-2 text-xs">
<div class="flex items-center gap-2">
<Icon icon={ClockCircle} size={4} />
{formatTimestampAsDate(start)}
</div>
2025-10-06 18:23:19 +00:00
{formatTimestampAsTime(start)} — {isSingleDay
? formatTimestampAsTime(end)
: formatTimestamp(end)}
</div>
{/if}
</div>