flotilla/src/app/components/NoteContentMinimalGoal.svelte

30 lines
1 KiB
Svelte
Raw Normal View History

2025-10-06 18:23:19 +00:00
<script lang="ts">
import type {ComponentProps} from "svelte"
import {removeUndefined} from "@welshman/lib"
import {fromMsats} from "@welshman/util"
2026-07-28 16:16:26 +00:00
import {ZapGoal} from "@welshman/domain"
import {ZapGoals} from "@welshman/app"
2025-10-06 18:23:19 +00:00
import Bolt from "@assets/icons/bolt.svg?dataurl"
import Icon from "@lib/components/Icon.svelte"
import ContentMinimal from "@app/components/ContentMinimal.svelte"
2026-07-28 16:16:26 +00:00
import {app, reader} from "@app/core"
2025-10-06 18:23:19 +00:00
const props: ComponentProps<typeof ContentMinimal> = $props()
2026-07-28 16:16:26 +00:00
const goal = reader(ZapGoal)(props.event)
2025-10-06 18:23:19 +00:00
2026-07-28 16:16:26 +00:00
const title = goal.title()
const summaryEvent = $derived({content: goal.summary(), tags: props.event.tags})
const progress = $app.use(ZapGoals).progress(props.event, removeUndefined([props.url])).$
2025-10-06 18:23:19 +00:00
</script>
<div class="flex justify-between">
2026-07-28 16:16:26 +00:00
<span class="text-sm">{title}</span>
2025-10-06 18:23:19 +00:00
<div class="flex items-center gap-1">
<Icon icon={Bolt} size={4} />
{fromMsats($progress.amount)}/{fromMsats($progress.target)} sats funded
2025-10-06 18:23:19 +00:00
</div>
</div>
2026-07-28 16:16:26 +00:00
<ContentMinimal {...props} event={summaryEvent} />