forked from coracle/flotilla
Flesh out EventItem
This commit is contained in:
@@ -1,9 +1,20 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {fromPairs} from "@welshman/lib"
|
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 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 meta = $derived(fromPairs(event.tags) as Record<string, string>)
|
||||||
const end = $derived(parseInt(meta.end))
|
const end = $derived(parseInt(meta.end))
|
||||||
@@ -11,14 +22,30 @@
|
|||||||
const startDateDisplay = $derived(formatTimestampAsDate(start))
|
const startDateDisplay = $derived(formatTimestampAsDate(start))
|
||||||
const endDateDisplay = $derived(formatTimestampAsDate(end))
|
const endDateDisplay = $derived(formatTimestampAsDate(end))
|
||||||
const isSingleDay = $derived(startDateDisplay === endDateDisplay)
|
const isSingleDay = $derived(startDateDisplay === endDateDisplay)
|
||||||
|
|
||||||
|
const openProfile = () => pushModal(ProfileDetail, {pubkey: event.pubkey})
|
||||||
|
|
||||||
|
$inspect(event)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="card2 flex items-center justify-between gap-2">
|
<div class="card2 bg-alt col-2">
|
||||||
<span>{meta.title || meta.name}</span>
|
<div class="flex items-center justify-between gap-2">
|
||||||
<div class="flex items-center gap-2 text-sm">
|
<span>{meta.title || meta.name}</span>
|
||||||
<Icon icon="clock-circle" size={4} />
|
<div class="flex items-center gap-2 text-sm">
|
||||||
{formatTimestampAsTime(start)} — {isSingleDay
|
<Icon icon="clock-circle" size={4} />
|
||||||
? formatTimestampAsTime(end)
|
{formatTimestampAsTime(start)} — {isSingleDay
|
||||||
: formatTimestamp(end)}
|
? 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>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {onMount} from "svelte"
|
import {onMount} from "svelte"
|
||||||
|
import type {Snippet} from "svelte"
|
||||||
import {groupBy, uniq, uniqBy, batch} from "@welshman/lib"
|
import {groupBy, uniq, uniqBy, batch} from "@welshman/lib"
|
||||||
import {REACTION, getTag, REPORT, DELETE} from "@welshman/util"
|
import {REACTION, getTag, REPORT, DELETE} from "@welshman/util"
|
||||||
import type {TrustedEvent} from "@welshman/util"
|
import type {TrustedEvent} from "@welshman/util"
|
||||||
@@ -18,7 +19,7 @@
|
|||||||
url?: string
|
url?: string
|
||||||
reactionClass?: string
|
reactionClass?: string
|
||||||
noTooltip?: boolean
|
noTooltip?: boolean
|
||||||
children?: import("svelte").Snippet
|
children?: Snippet
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
...restProps
|
...restProps
|
||||||
}: {
|
}: {
|
||||||
children: Snippet
|
children: Snippet
|
||||||
onclick?: (...args: unknown[]) => any
|
onclick?: (event: Event) => any
|
||||||
type?: "button" | "submit"
|
type?: "button" | "submit"
|
||||||
class?: string
|
class?: string
|
||||||
style?: string
|
style?: string
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
|
|
||||||
onclick?.()
|
onclick?.(e)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@
|
|||||||
{#if dateDisplay}
|
{#if dateDisplay}
|
||||||
<Divider>{dateDisplay}</Divider>
|
<Divider>{dateDisplay}</Divider>
|
||||||
{/if}
|
{/if}
|
||||||
<EventItem {event} />
|
<EventItem {url} {event} />
|
||||||
{/each}
|
{/each}
|
||||||
<p class="flex h-10 items-center justify-center py-20">
|
<p class="flex h-10 items-center justify-center py-20">
|
||||||
<Spinner {loading}>
|
<Spinner {loading}>
|
||||||
|
|||||||
Reference in New Issue
Block a user