-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1292 from SnowCait/profile-menu
Profile menu
- Loading branch information
Showing
3 changed files
with
54 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<script lang="ts"> | ||
import { Menu } from '@svelteuidev/core'; | ||
import { _ } from 'svelte-i18n'; | ||
import { nip19 } from 'nostr-tools'; | ||
import type { Event } from 'nostr-typedef'; | ||
import { page } from '$app/stores'; | ||
import { copy } from '$lib/Clipboard'; | ||
import { shareUrl } from '$lib/Share'; | ||
import IconClipboard from '@tabler/icons-svelte/dist/svelte/icons/IconClipboard.svelte'; | ||
import IconLink from '@tabler/icons-svelte/dist/svelte/icons/IconLink.svelte'; | ||
export let event: Event; | ||
$: nprofile = nip19.nprofileEncode({ pubkey: event.pubkey }); | ||
$: url = `${$page.url.origin}/${nprofile}`; | ||
</script> | ||
|
||
<Menu placement="center"> | ||
<Menu.Item icon={IconClipboard} on:click={() => copy(nprofile)}> | ||
{$_('actions.copy_id.button')} | ||
</Menu.Item> | ||
|
||
{#if navigator.canShare !== undefined} | ||
<Menu.Item | ||
icon={IconLink} | ||
on:click={async () => { | ||
if (!(await shareUrl(url))) { | ||
await copy(url); | ||
} | ||
}} | ||
> | ||
{$_('actions.share.button')} | ||
</Menu.Item> | ||
{:else} | ||
<Menu.Item icon={IconLink} on:click={() => copy(url)}> | ||
{$_('actions.copy_url.button')} | ||
</Menu.Item> | ||
{/if} | ||
</Menu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters