2024-04-17 22:21:56 +00:00
|
|
|
import { useState, useMemo } from 'react'
|
2024-03-20 00:37:31 +00:00
|
|
|
import { abbrNum, numWithUnits } from '@/lib/format'
|
2023-09-12 17:19:26 +00:00
|
|
|
import { useMe } from './me'
|
|
|
|
|
|
|
|
export default function HiddenWalletSummary ({ abbreviate, fixedWidth }) {
|
|
|
|
const me = useMe()
|
|
|
|
const [hover, setHover] = useState(false)
|
|
|
|
|
2024-04-17 22:21:56 +00:00
|
|
|
const fixedWidthAbbrSats = useMemo(() => {
|
|
|
|
const abbr = abbrNum(me.privates?.sats).toString()
|
|
|
|
if (abbr.length >= 6) return abbr
|
|
|
|
|
|
|
|
// add leading spaces if abbr is shorter than 6 characters
|
|
|
|
return ' '.repeat(6 - abbr.length) + abbr
|
|
|
|
}, [me.privates?.sats])
|
2023-09-12 17:19:26 +00:00
|
|
|
|
|
|
|
return (
|
2023-09-12 19:50:06 +00:00
|
|
|
<span
|
2024-04-17 22:21:56 +00:00
|
|
|
className='text-monospace' style={{ whiteSpace: 'pre-wrap' }} align='right' onPointerEnter={() => setHover(true)} onPointerLeave={() => setHover(false)}
|
2023-09-12 19:50:06 +00:00
|
|
|
>
|
2024-04-17 22:21:56 +00:00
|
|
|
{hover ? (abbreviate ? fixedWidthAbbrSats : numWithUnits(me.privates?.sats, { abbreviate: false, format: true })) : '******'}
|
2023-09-12 17:19:26 +00:00
|
|
|
</span>
|
|
|
|
)
|
|
|
|
}
|