Skip to content

Commit

Permalink
Merge pull request #1292 from SnowCait/profile-menu
Browse files Browse the repository at this point in the history
Profile menu
  • Loading branch information
SnowCait authored Jun 29, 2024
2 parents 20a3a91 + b22ae6a commit 0b08607
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 9 deletions.
39 changes: 39 additions & 0 deletions web/src/lib/components/ProfileMenuButton.svelte
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>
2 changes: 1 addition & 1 deletion web/src/routes/(app)/[slug=npub]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import { replaceableEvents, replaceableEventsReqEmit } from '$lib/Profile';
import type { LayoutData } from './$types';
import { developerMode } from '$lib/stores/Preference';
import Profile from '$lib/components/Profile.svelte';
import Profile from './Profile.svelte';
import TimelineView from '../TimelineView.svelte';
export let data: LayoutData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@
import { developerMode } from '$lib/stores/Preference';
import ZapButton from '$lib/components/ZapButton.svelte';
import Nip21QrcodeButton from '$lib/components/Nip21QrcodeButton.svelte';
import Badges from './Badges.svelte';
import ExternalLink from './ExternalLink.svelte';
import FollowButton from './FollowButton.svelte';
import MuteButton from './MuteButton.svelte';
import NostrAddress from './NostrAddress.svelte';
import UserStatus from './UserStatus.svelte';
import ReplaceableEventsJson from './ReplaceableEventsJson.svelte';
import Content from './Content.svelte';
import Badges from '$lib/components/Badges.svelte';
import ExternalLink from '$lib/components/ExternalLink.svelte';
import FollowButton from '$lib/components/FollowButton.svelte';
import MuteButton from '$lib/components/MuteButton.svelte';
import NostrAddress from '$lib/components/NostrAddress.svelte';
import UserStatus from '$lib/components/UserStatus.svelte';
import ReplaceableEventsJson from '$lib/components/ReplaceableEventsJson.svelte';
import Content from '$lib/components/Content.svelte';
import IconTool from '@tabler/icons-svelte/dist/svelte/icons/IconTool.svelte';
import IconLink from '@tabler/icons-svelte/dist/svelte/icons/IconLink.svelte';
import ProfileMenuButton from '$lib/components/ProfileMenuButton.svelte';
export let slug: string;
export let pubkey: string;
Expand Down Expand Up @@ -106,6 +107,11 @@
<div class="mute">
<ZapButton {pubkey} />
</div>
{#if metadata !== undefined}
<div>
<ProfileMenuButton event={metadata.event} />
</div>
{/if}
<FollowButton {pubkey} />
{/if}
</div>
Expand Down

0 comments on commit 0b08607

Please sign in to comment.