Skip to content

Commit bccfcb3

Browse files
committed
Show wallet indicator
1 parent 54d3b11 commit bccfcb3

File tree

3 files changed

+59
-18
lines changed

3 files changed

+59
-18
lines changed

components/nav/common.js

+40-12
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import SearchIcon from '../../svgs/search-line.svg'
2121
import classNames from 'classnames'
2222
import SnIcon from '@/svgs/sn.svg'
2323
import { useHasNewNotes } from '../use-has-new-notes'
24-
import { useWallets } from '@/wallets/index'
24+
import { useConfiguredWallets, useWallets } from '@/wallets/index'
2525
import SwitchAccountList, { useAccounts } from '@/components/account'
2626
import { useShowModal } from '@/components/modal'
2727
import { numWithUnits } from '@/lib/format'
@@ -164,21 +164,49 @@ export function NavWalletSummary ({ className }) {
164164
)
165165
}
166166

167+
export const Indicator = ({ superscript }) => {
168+
if (superscript) {
169+
return (
170+
<span className='d-inline-block p-1'>
171+
<span
172+
className='position-absolute p-1 bg-secondary'
173+
style={{
174+
top: '5px',
175+
right: '0px',
176+
height: '5px',
177+
width: '5px'
178+
}}
179+
>
180+
<span className='invisible'>{' '}</span>
181+
</span>
182+
</span>
183+
)
184+
}
185+
186+
return (
187+
<div className='p-1 d-inline-block bg-secondary ms-1'>
188+
<span className='invisible'>{' '}</span>
189+
</div>
190+
)
191+
}
192+
167193
export function MeDropdown ({ me, dropNavKey }) {
168194
if (!me) return null
195+
196+
const wallets = useConfiguredWallets()
197+
198+
const profileIndicator = !me.bioId
199+
const walletIndicator = wallets.length === 0
200+
const indicator = profileIndicator || walletIndicator
201+
169202
return (
170203
<div className=''>
171204
<Dropdown className={styles.dropdown} align='end'>
172205
<Dropdown.Toggle className='nav-link nav-item fw-normal' id='profile' variant='custom'>
173206
<div className='d-flex align-items-center'>
174207
<Nav.Link eventKey={me.name} as='span' className='p-0 position-relative'>
175208
{`@${me.name}`}
176-
{!me.bioId &&
177-
<span className='d-inline-block p-1'>
178-
<span className='position-absolute p-1 bg-secondary' style={{ top: '5px', right: '0px', height: '5px', width: '5px' }}>
179-
<span className='invisible'>{' '}</span>
180-
</span>
181-
</span>}
209+
{indicator && <Indicator superscript />}
182210
</Nav.Link>
183211
<Badges user={me} />
184212
</div>
@@ -187,17 +215,17 @@ export function MeDropdown ({ me, dropNavKey }) {
187215
<Link href={'/' + me.name} passHref legacyBehavior>
188216
<Dropdown.Item active={me.name === dropNavKey}>
189217
profile
190-
{me && !me.bioId &&
191-
<div className='p-1 d-inline-block bg-secondary ms-1'>
192-
<span className='invisible'>{' '}</span>
193-
</div>}
218+
{profileIndicator && <Indicator />}
194219
</Dropdown.Item>
195220
</Link>
196221
<Link href={'/' + me.name + '/bookmarks'} passHref legacyBehavior>
197222
<Dropdown.Item active={me.name + '/bookmarks' === dropNavKey}>bookmarks</Dropdown.Item>
198223
</Link>
199224
<Link href='/wallets' passHref legacyBehavior>
200-
<Dropdown.Item eventKey='wallets'>wallets</Dropdown.Item>
225+
<Dropdown.Item eventKey='wallets'>
226+
wallets
227+
{walletIndicator && <Indicator />}
228+
</Dropdown.Item>
201229
</Link>
202230
<Link href='/credits' passHref legacyBehavior>
203231
<Dropdown.Item eventKey='credits'>credits</Dropdown.Item>

components/nav/mobile/offcanvas.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import { useState } from 'react'
22
import { Dropdown, Image, Nav, Navbar, Offcanvas } from 'react-bootstrap'
33
import { MEDIA_URL } from '@/lib/constants'
44
import Link from 'next/link'
5-
import { LoginButtons, LogoutDropdownItem, NavWalletSummary } from '../common'
5+
import { LoginButtons, LogoutDropdownItem, NavWalletSummary, Indicator } from '../common'
66
import AnonIcon from '@/svgs/spy-fill.svg'
77
import styles from './footer.module.css'
88
import canvasStyles from './offcanvas.module.css'
99
import classNames from 'classnames'
10+
import { useConfiguredWallets } from '@/wallets'
1011

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

29+
const wallets = useConfiguredWallets()
30+
31+
const profileIndicator = me && !me.bioId
32+
const walletIndicator = wallets.length === 0
33+
2834
return (
2935
<>
3036
<MeImage onClick={handleShow} />
@@ -50,17 +56,17 @@ export default function OffCanvas ({ me, dropNavKey }) {
5056
<Link href={'/' + me.name} passHref legacyBehavior>
5157
<Dropdown.Item active={me.name === dropNavKey}>
5258
profile
53-
{me && !me.bioId &&
54-
<div className='p-1 d-inline-block bg-secondary ms-1'>
55-
<span className='invisible'>{' '}</span>
56-
</div>}
59+
{profileIndicator && <Indicator />}
5760
</Dropdown.Item>
5861
</Link>
5962
<Link href={'/' + me.name + '/bookmarks'} passHref legacyBehavior>
6063
<Dropdown.Item active={me.name + '/bookmarks' === dropNavKey}>bookmarks</Dropdown.Item>
6164
</Link>
6265
<Link href='/wallets' passHref legacyBehavior>
63-
<Dropdown.Item eventKey='wallets'>wallets</Dropdown.Item>
66+
<Dropdown.Item eventKey='wallets'>
67+
wallets
68+
{walletIndicator && <Indicator />}
69+
</Dropdown.Item>
6470
</Link>
6571
<Link href='/credits' passHref legacyBehavior>
6672
<Dropdown.Item eventKey='credits'>credits</Dropdown.Item>

wallets/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,13 @@ export function useWallet (name) {
223223
return wallets.find(w => w.def.name === name)
224224
}
225225

226+
export function useConfiguredWallets () {
227+
const { wallets } = useWallets()
228+
return useMemo(() => wallets
229+
.filter(w => isConfigured(w)),
230+
[wallets])
231+
}
232+
226233
export function useSendWallets () {
227234
const { wallets } = useWallets()
228235
// return all enabled wallets that are available and can send

0 commit comments

Comments
 (0)