flotilla/src/app/components/GoalItem.svelte

63 lines
2.1 KiB
Svelte
Raw Normal View History

2025-07-07 22:28:36 +00:00
<script lang="ts">
import type {Readable} from "svelte/store"
2025-07-07 22:28:36 +00:00
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"
import type {GoalProgress} from "@app/goals"
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
progress?: Readable<GoalProgress>
2025-07-07 22:28:36 +00:00
}
const {url, event, context, progress}: 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 image = goal.image()
2026-07-28 16:16:26 +00:00
const h = goal.room()
2025-07-07 22:28:36 +00:00
</script>
<Cv tag={Link} class="relative flex flex-col gap-3 card card-interactive w-full" href={path}>
<UnreadDot {path} class="absolute right-3 top-3" />
{#if image}
<img src={image} alt="" class="h-40 w-full max-w-full rounded-2xl object-cover" />
{/if}
<p class="line-clamp-2 wrap-break-word text-xl font-bold">{title}</p>
{#if summary}
<div class="text-sm text-content-muted">
<Content
event={{content: summary, tags: event.tags}}
{url}
expandMode="inline"
minLength={50}
maxLength={180} />
</div>
{/if}
<GoalSummary {url} {event} {progress} />
<div class="flex w-full min-w-0 flex-wrap items-center justify-between gap-2">
<span class="min-w-0 py-1 text-sm text-content-muted">
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>