import clsx from 'clsx' import { useRouter } from 'next/router' import { useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import { TokenCardInfo, TokenLineProps } from '@dao-dao/types' import { getDisplayNameForChainId, getFallbackImage, shortenTokenSymbol, toAccessibleImageUrl, } from '@dao-dao/utils' import { ChainLogo } from '../chain' import { Modal } from '../modals' import { Tooltip } from '../tooltip' import { TokenAmountDisplay } from './TokenAmountDisplay' export const TokenLine = ( props: TokenLineProps ) => { const { TokenCard, token, transparentBackground, lazyInfo, color, hideChainIcon, } = props const { t } = useTranslation() const { tokenSymbol } = shortenTokenSymbol(token.symbol) const [cardVisible, setCardVisible] = useState(false) // On route change, close the card. const { asPath } = useRouter() useEffect(() => { setCardVisible(false) }, [asPath]) return ( <>
setCardVisible(true)} >
{!hideChainIcon && ( <> {/* Large screen */} {/* Small screen */} )}

{tokenSymbol}

{color && (
)}
{/* Only show on larger screen. */} {lazyInfo.loading || lazyInfo.data.usdUnitPrice?.usdPrice ? (
) : (
)}
setCardVisible(false)} visible={cardVisible} > ) }