flotilla/src/app/components/GoalItem.svelte

52 lines
1.7 KiB
Svelte
Raw Normal View History

2025-07-07 22:28:36 +00:00
<script lang="ts">
import type {TrustedEvent} from "@welshman/util"
2026-07-28 16:16:26 +00:00
import {ZapGoal} from "@welshman/domain"
2025-07-07 22:28:36 +00:00
import Link from "@lib/components/Link.svelte"
import Cv from "@lib/components/Cv.svelte"
2026-07-28 16:16:26 +00:00
import {reader} from "@app/core"
2025-07-07 22:28:36 +00:00
import Content from "@app/components/Content.svelte"
import ProfileLink from "@app/components/ProfileLink.svelte"
import GoalActions from "@app/components/GoalActions.svelte"
import type {FeedContext} from "@app/feeds"
2025-07-07 22:28:36 +00:00
import GoalSummary from "@app/components/GoalSummary.svelte"
2025-10-30 22:36:14 +00:00
import RoomLink from "@app/components/RoomLink.svelte"
import UnreadDot from "@app/components/UnreadDot.svelte"
2026-06-08 21:14:40 +00:00
import {makeGoalPath} from "@app/routes"
2025-07-07 22:28:36 +00:00
type Props = {
url: string
event: TrustedEvent
context: FeedContext
2025-07-07 22:28:36 +00:00
}
const {url, event, context}: Props = $props()
2025-07-07 22:28:36 +00:00
2026-07-28 16:16:26 +00:00
const goal = reader(ZapGoal)(event)
const path = makeGoalPath(url, event.id)
2026-07-28 16:16:26 +00:00
const title = goal.title()
const summary = goal.summary()
const h = goal.room()
2025-07-07 22:28:36 +00:00
</script>
<Cv tag={Link} class="relative flex flex-col gap-2 card card-interactive w-full" href={path}>
<UnreadDot {path} class="absolute right-3 top-3" />
2026-07-28 16:16:26 +00:00
<p class="text-2xl">{title}</p>
2025-07-07 22:28:36 +00:00
<Content
event={{content: summary, tags: event.tags}}
{url}
expandMode="inline"
minLength={50}
maxLength={300} />
<GoalSummary {url} {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 <ProfileLink pubkey={event.pubkey} {url} />
2025-10-30 22:33:34 +00:00
{#if h}
2025-10-30 22:36:14 +00:00
in <RoomLink {url} {h} />
2025-10-06 18:23:19 +00:00
{/if}
2025-07-07 22:28:36 +00:00
</span>
<GoalActions showActivity {url} {event} {context} />
2025-07-07 22:28:36 +00:00
</div>
</Cv>