Flesh out EventItem

This commit is contained in:
Jon Staab
2025-02-05 13:02:51 -08:00
parent 5909b593ab
commit 131cc99c47
4 changed files with 41 additions and 13 deletions

View File

@@ -1,9 +1,20 @@
<script lang="ts">
import {fromPairs} from "@welshman/lib"
import {formatTimestamp, formatTimestampAsDate, formatTimestampAsTime} from "@welshman/app"
import {
formatTimestamp,
formatTimestampAsDate,
formatTimestampAsTime,
} from "@welshman/app"
import {preventDefault} from "@lib/html"
import Icon from "@lib/components/Icon.svelte"
import Button from "@lib/components/Button.svelte"
import Content from "@app/components/Content.svelte"
import ThreadActions from "@app/components/ThreadActions.svelte"
import ProfileName from "@app/components/ProfileName.svelte"
import ProfileDetail from "@app/components/ProfileDetail.svelte"
import {pushModal} from "@app/modal"
const {event} = $props()
const {url, event} = $props()
const meta = $derived(fromPairs(event.tags) as Record<string, string>)
const end = $derived(parseInt(meta.end))
@@ -11,14 +22,30 @@
const startDateDisplay = $derived(formatTimestampAsDate(start))
const endDateDisplay = $derived(formatTimestampAsDate(end))
const isSingleDay = $derived(startDateDisplay === endDateDisplay)
const openProfile = () => pushModal(ProfileDetail, {pubkey: event.pubkey})
$inspect(event)
</script>
<div class="card2 flex items-center justify-between gap-2">
<span>{meta.title || meta.name}</span>
<div class="flex items-center gap-2 text-sm">
<Icon icon="clock-circle" size={4} />
{formatTimestampAsTime(start)} {isSingleDay
? formatTimestampAsTime(end)
: formatTimestamp(end)}
<div class="card2 bg-alt col-2">
<div class="flex items-center justify-between gap-2">
<span>{meta.title || meta.name}</span>
<div class="flex items-center gap-2 text-sm">
<Icon icon="clock-circle" size={4} />
{formatTimestampAsTime(start)}{isSingleDay
? formatTimestampAsTime(end)
: formatTimestamp(end)}
</div>
</div>
<Content {event} />
<div class="flex w-full flex-col items-end justify-between gap-2 sm:flex-row">
<span class="whitespace-nowrap py-1 text-sm opacity-75">
Posted by
<Button onclick={preventDefault(openProfile)} class="link-content">
@<ProfileName pubkey={event.pubkey} />
</Button>
</span>
<ThreadActions {url} {event} />
</div>
</div>

View File

@@ -1,5 +1,6 @@
<script lang="ts">
import {onMount} from "svelte"
import type {Snippet} from "svelte"
import {groupBy, uniq, uniqBy, batch} from "@welshman/lib"
import {REACTION, getTag, REPORT, DELETE} from "@welshman/util"
import type {TrustedEvent} from "@welshman/util"
@@ -18,7 +19,7 @@
url?: string
reactionClass?: string
noTooltip?: boolean
children?: import("svelte").Snippet
children?: Snippet
}
const {

View File

@@ -8,7 +8,7 @@
...restProps
}: {
children: Snippet
onclick?: (...args: unknown[]) => any
onclick?: (event: Event) => any
type?: "button" | "submit"
class?: string
style?: string
@@ -22,7 +22,7 @@
e.preventDefault()
e.stopPropagation()
onclick?.()
onclick?.(e)
}
</script>

View File

@@ -93,7 +93,7 @@
{#if dateDisplay}
<Divider>{dateDisplay}</Divider>
{/if}
<EventItem {event} />
<EventItem {url} {event} />
{/each}
<p class="flex h-10 items-center justify-center py-20">
<Spinner {loading}>