flotilla/src/app/components/EventInfo.svelte

56 lines
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
export let event
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>
<div slot="title">Event Details</div>
2024-10-15 22:52:30 +00:00
<div slot="info">The full details of this event are shown below.</div>
2024-10-15 21:00:15 +00:00
</ModalHeader>
2024-10-17 23:17:49 +00:00
<FieldInline>
<p slot="label">Event Link</p>
2024-10-17 23:17:49 +00:00
<label class="input input-bordered flex w-full items-center gap-2" slot="input">
<Icon icon="file" />
<input type="text" class="ellipsize min-w-0 grow" value={nevent1} />
<Button on:click={copyLink} class="flex items-center">
2024-10-17 23:17:49 +00:00
<Icon icon="copy" />
</Button>
</label>
</FieldInline>
<FieldInline>
<p slot="label">Author Pubkey</p>
<label class="input input-bordered flex w-full items-center gap-2" slot="input">
<Icon icon="user-circle" />
2024-10-24 23:28:56 +00:00
<input type="text" class="ellipsize min-w-0 grow" value={npub1} />
2024-10-17 23:17:49 +00:00
<Button on:click={copyPubkey} class="flex items-center">
<Icon icon="copy" />
</Button>
</label>
</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>