Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wallet indicators #2002

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
52 changes: 40 additions & 12 deletions components/nav/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import SearchIcon from '../../svgs/search-line.svg'
import classNames from 'classnames'
import SnIcon from '@/svgs/sn.svg'
import { useHasNewNotes } from '../use-has-new-notes'
import { useWallets } from '@/wallets/index'
import { useConfiguredWallets, useWallets } from '@/wallets/index'
import SwitchAccountList, { useAccounts } from '@/components/account'
import { useShowModal } from '@/components/modal'
import { numWithUnits } from '@/lib/format'
Expand Down Expand Up @@ -164,21 +164,49 @@ export function NavWalletSummary ({ className }) {
)
}

export const Indicator = ({ superscript }) => {
if (superscript) {
return (
<span className='d-inline-block p-1'>
<span
className='position-absolute p-1 bg-secondary'
style={{
top: '5px',
right: '0px',
height: '5px',
width: '5px'
}}
>
<span className='invisible'>{' '}</span>
</span>
</span>
)
}

return (
<div className='p-1 d-inline-block bg-secondary ms-1'>
<span className='invisible'>{' '}</span>
</div>
)
}

export function MeDropdown ({ me, dropNavKey }) {
if (!me) return null

const wallets = useConfiguredWallets()

const profileIndicator = !me.bioId
const walletIndicator = wallets.length === 0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If one removes all wallets, the indicator will show up again. Not sure if that's good.

Copy link
Member

@Soxasora Soxasora Mar 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be an encouragement to attach back a wallet ⚡️
do you see it getting old over time?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you see it getting old over time?

Yes. Some people don't want to attach a wallet so they should have the option to remove this indicator / keep it removed in some way.

const indicator = profileIndicator || walletIndicator

return (
<div className=''>
<Dropdown className={styles.dropdown} align='end'>
<Dropdown.Toggle className='nav-link nav-item fw-normal' id='profile' variant='custom'>
<div className='d-flex align-items-center'>
<Nav.Link eventKey={me.name} as='span' className='p-0 position-relative'>
{`@${me.name}`}
{!me.bioId &&
<span className='d-inline-block p-1'>
<span className='position-absolute p-1 bg-secondary' style={{ top: '5px', right: '0px', height: '5px', width: '5px' }}>
<span className='invisible'>{' '}</span>
</span>
</span>}
{indicator && <Indicator superscript />}
</Nav.Link>
<Badges user={me} />
</div>
Expand All @@ -187,17 +215,17 @@ export function MeDropdown ({ me, dropNavKey }) {
<Link href={'/' + me.name} passHref legacyBehavior>
<Dropdown.Item active={me.name === dropNavKey}>
profile
{me && !me.bioId &&
<div className='p-1 d-inline-block bg-secondary ms-1'>
<span className='invisible'>{' '}</span>
</div>}
{profileIndicator && <Indicator />}
</Dropdown.Item>
</Link>
<Link href={'/' + me.name + '/bookmarks'} passHref legacyBehavior>
<Dropdown.Item active={me.name + '/bookmarks' === dropNavKey}>bookmarks</Dropdown.Item>
</Link>
<Link href='/wallets' passHref legacyBehavior>
<Dropdown.Item eventKey='wallets'>wallets</Dropdown.Item>
<Dropdown.Item eventKey='wallets'>
wallets
{walletIndicator && <Indicator />}
</Dropdown.Item>
</Link>
<Link href='/credits' passHref legacyBehavior>
<Dropdown.Item eventKey='credits'>credits</Dropdown.Item>
Expand Down
18 changes: 12 additions & 6 deletions components/nav/mobile/offcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { useState } from 'react'
import { Dropdown, Image, Nav, Navbar, Offcanvas } from 'react-bootstrap'
import { MEDIA_URL } from '@/lib/constants'
import Link from 'next/link'
import { LoginButtons, LogoutDropdownItem, NavWalletSummary } from '../common'
import { LoginButtons, LogoutDropdownItem, NavWalletSummary, Indicator } from '../common'
import AnonIcon from '@/svgs/spy-fill.svg'
import styles from './footer.module.css'
import canvasStyles from './offcanvas.module.css'
import classNames from 'classnames'
import { useConfiguredWallets } from '@/wallets'

export default function OffCanvas ({ me, dropNavKey }) {
const [show, setShow] = useState(false)
Expand All @@ -25,6 +26,11 @@ export default function OffCanvas ({ me, dropNavKey }) {
)
: <span className='text-muted pointer'><AnonIcon onClick={onClick} width='22' height='22' /></span>

const wallets = useConfiguredWallets()

const profileIndicator = me && !me.bioId
const walletIndicator = wallets.length === 0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here


return (
<>
<MeImage onClick={handleShow} />
Expand All @@ -50,17 +56,17 @@ export default function OffCanvas ({ me, dropNavKey }) {
<Link href={'/' + me.name} passHref legacyBehavior>
<Dropdown.Item active={me.name === dropNavKey}>
profile
{me && !me.bioId &&
<div className='p-1 d-inline-block bg-secondary ms-1'>
<span className='invisible'>{' '}</span>
</div>}
{profileIndicator && <Indicator />}
</Dropdown.Item>
</Link>
<Link href={'/' + me.name + '/bookmarks'} passHref legacyBehavior>
<Dropdown.Item active={me.name + '/bookmarks' === dropNavKey}>bookmarks</Dropdown.Item>
</Link>
<Link href='/wallets' passHref legacyBehavior>
<Dropdown.Item eventKey='wallets'>wallets</Dropdown.Item>
<Dropdown.Item eventKey='wallets'>
wallets
{walletIndicator && <Indicator />}
</Dropdown.Item>
</Link>
<Link href='/credits' passHref legacyBehavior>
<Dropdown.Item eventKey='credits'>credits</Dropdown.Item>
Expand Down
7 changes: 7 additions & 0 deletions wallets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,13 @@ export function useWallet (name) {
return wallets.find(w => w.def.name === name)
}

export function useConfiguredWallets () {
const { wallets } = useWallets()
return useMemo(() => wallets
.filter(w => isConfigured(w)),
[wallets])
}

export function useSendWallets () {
const { wallets } = useWallets()
// return all enabled wallets that are available and can send
Expand Down