flotilla/src/app/components/EventInfo.svelte

68 lines
2.2 KiB
Svelte
Raw Normal View History

2024-10-15 21:00:15 +00:00
<script lang="ts">
2024-10-18 23:09:17 +00:00
import {nip19} from "nostr-tools"
import {ctx} from "@welshman/lib"
2024-10-17 23:17:49 +00:00
import Icon from "@lib/components/Icon.svelte"
import FieldInline from "@lib/components/FieldInline.svelte"
2024-10-15 22:52:30 +00:00
import Button from "@lib/components/Button.svelte"
2024-10-15 21:00:15 +00:00
import ModalHeader from "@lib/components/ModalHeader.svelte"
2024-10-18 23:09:17 +00:00
import {clip} from "@app/toast"
2024-10-15 21:00:15 +00:00
2025-02-04 00:37:14 +00:00
let {event} = $props()
2024-10-17 23:17:49 +00:00
const relays = ctx.app.router.Event(event).getUrls()
const nevent1 = nip19.neventEncode({...event, relays})
2024-10-17 23:17:49 +00:00
const npub1 = nip19.npubEncode(event.pubkey)
const json = JSON.stringify(event, null, 2)
const copyLink = () => clip(nevent1)
2024-10-17 23:17:49 +00:00
const copyPubkey = () => clip(npub1)
const copyJson = () => clip(json)
2024-10-15 21:00:15 +00:00
</script>
<div class="column gap-4">
<ModalHeader>
2025-02-04 00:37:14 +00:00
{#snippet title()}
<div>Event Details</div>
{/snippet}
{#snippet info()}
<div>The full details of this event are shown below.</div>
{/snippet}
2024-10-15 21:00:15 +00:00
</ModalHeader>
2024-10-17 23:17:49 +00:00
<FieldInline>
2025-02-04 00:37:14 +00:00
{#snippet label()}
<p>Event Link</p>
{/snippet}
{#snippet input()}
<label class="input input-bordered flex w-full items-center gap-2">
<Icon icon="file" />
<input type="text" class="ellipsize min-w-0 grow" value={nevent1} />
<Button on:click={copyLink} class="flex items-center">
<Icon icon="copy" />
</Button>
</label>
{/snippet}
2024-10-17 23:17:49 +00:00
</FieldInline>
<FieldInline>
2025-02-04 00:37:14 +00:00
{#snippet label()}
<p>Author Pubkey</p>
{/snippet}
{#snippet input()}
<label class="input input-bordered flex w-full items-center gap-2">
<Icon icon="user-circle" />
<input type="text" class="ellipsize min-w-0 grow" value={npub1} />
<Button on:click={copyPubkey} class="flex items-center">
<Icon icon="copy" />
</Button>
</label>
{/snippet}
2024-10-17 23:17:49 +00:00
</FieldInline>
<div class="relative">
2024-10-24 23:28:56 +00:00
<pre class="card2 card2-sm bg-alt overflow-auto text-xs"><code>{json}</code></pre>
2024-10-18 23:09:17 +00:00
<p class="absolute right-2 top-2 flex flex-grow items-center justify-between">
<Button on:click={copyJson} class="btn btn-neutral btn-sm flex items-center">
2024-10-17 23:17:49 +00:00
<Icon icon="copy" /> Copy
</Button>
</p>
</div>
2024-10-15 21:00:15 +00:00
<Button class="btn btn-primary" on:click={() => history.back()}>Got it</Button>
</div>