Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions components/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,22 @@ export function CrosspostDropdownItem ({ item }) {
</Dropdown.Item>
)
}

export function ShareProfileDropdownItem ({ user }) {
const { me } = useMe()
const toaster = useToast()
const url = referrurl(`/${user.name}`, me)

return (
<Dropdown.Item
onClick={async () => {
await share(`@${user.name}'s profile on Stacker News`, url, toaster)
}}
>
<ShareIcon className='me-2' width={16} height={16} />
share profile
</Dropdown.Item>
)
}

export { referrurl, share }
10 changes: 8 additions & 2 deletions components/user-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import GithubIcon from '@/svgs/github-fill.svg'
import TwitterIcon from '@/svgs/twitter-fill.svg'
import { UNKNOWN_LINK_REL } from '@/lib/constants'
import ItemPopover from './item-popover'
import Share, { ShareProfileDropdownItem } from './share'

const MEDIA_URL = process.env.NEXT_PUBLIC_MEDIA_URL || `https://${process.env.NEXT_PUBLIC_MEDIA_DOMAIN}`

Expand Down Expand Up @@ -182,8 +183,12 @@ function NymView ({ user, isMe, setEditting }) {
return (
<div className='d-flex align-items-center mb-2'>
<div className={styles.username}>@{user.name}<Badges className='ms-2' user={user} badgeClassName='fill-grey' /></div>
{isMe &&
<Button className='py-0' style={{ lineHeight: '1.25' }} variant='link' onClick={() => setEditting(true)}>edit nym</Button>}
{isMe && (
<>
<Button className='py-0' style={{ lineHeight: '1.25' }} variant='link' onClick={() => setEditting(true)}>edit nym</Button>
<Share path={`/${user.name}`} title={`@${user.name}'s profile on Stacker News`} />
</>
)}
{!isMe && me && <NymActionDropdown user={user} />}
</div>
)
Expand All @@ -193,6 +198,7 @@ export function NymActionDropdown ({ user, className = 'ms-2' }) {
return (
<div className={className}>
<ActionDropdown>
<ShareProfileDropdownItem user={user} />
<SubscribeUserDropdownItem user={user} target='posts' />
<SubscribeUserDropdownItem user={user} target='comments' />
<MuteDropdownItem user={user} />
Expand Down