flotilla/src/app/components/CalendarEventItem.svelte

44 lines
1.6 KiB
Svelte
Raw Normal View History

2024-09-20 18:00:41 +00:00
<script lang="ts">
import {fromPairs} from "@welshman/lib"
2025-02-06 17:53:50 +00:00
import type {TrustedEvent} from "@welshman/util"
2025-02-05 23:05:58 +00:00
import {formatTimestamp, formatTimestampAsDate, formatTimestampAsTime} from "@welshman/app"
2024-09-20 18:00:41 +00:00
import Icon from "@lib/components/Icon.svelte"
2025-02-06 17:29:30 +00:00
import Link from "@lib/components/Link.svelte"
import CalendarEventActions from "@app/components/CalendarEventActions.svelte"
2025-02-06 19:12:15 +00:00
import ProfileLink from "@app/components/ProfileLink.svelte"
2025-02-06 17:29:30 +00:00
import {makeCalendarPath} from "@app/routes"
2024-09-20 18:00:41 +00:00
2025-02-06 17:53:50 +00:00
const {
url,
event,
}: {
url: string
event: TrustedEvent
} = $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>
2025-02-06 19:12:15 +00:00
<Link class="col-3 card2 bg-alt w-full cursor-pointer" href={makeCalendarPath(url, event.id)}>
2025-02-05 21:02:51 +00:00
<div class="flex items-center justify-between gap-2">
2025-02-06 19:12:15 +00:00
<p class="text-xl">{meta.title || meta.name}</p>
2025-02-05 21:02:51 +00:00
<div class="flex items-center gap-2 text-sm">
<Icon icon="clock-circle" size={4} />
{formatTimestampAsTime(start)} — {isSingleDay
? formatTimestampAsTime(end)
: formatTimestamp(end)}
</div>
</div>
<div class="flex w-full flex-col items-end justify-between gap-2 sm:flex-row">
2025-02-06 19:12:15 +00:00
<span class="whitespace-nowrap py-1 text-sm opacity-75">
Posted by <ProfileLink pubkey={event.pubkey} />
</span>
2025-02-06 18:24:31 +00:00
<CalendarEventActions showActivity {url} {event} />
2024-09-20 18:00:41 +00:00
</div>
2025-02-06 17:29:30 +00:00
</Link>