1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Show fiat balance on token page (#8791)

The token page overview now shows the balance in fiat.
This commit is contained in:
Mark Stacey 2020-06-12 15:47:39 -03:00 committed by GitHub
parent a100c55e64
commit cf08131b49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 3 deletions

View File

@ -102,6 +102,13 @@
justify-content: center; justify-content: center;
} }
&__secondary-balance {
font-size: 16px;
line-height: 23px;
font-weight: 400;
color: $Grey-400;
}
&__button { &__button {
min-width: initial; min-width: initial;
width: 100px; width: 100px;

View File

@ -5,11 +5,13 @@ import { useHistory } from 'react-router-dom'
import Button from '../../ui/button' import Button from '../../ui/button'
import Identicon from '../../ui/identicon' import Identicon from '../../ui/identicon'
import TokenBalance from '../../ui/token-balance' import CurrencyDisplay from '../../ui/currency-display'
import { I18nContext } from '../../../contexts/i18n' import { I18nContext } from '../../../contexts/i18n'
import WalletOverview from './wallet-overview' import WalletOverview from './wallet-overview'
import { SEND_ROUTE } from '../../../helpers/constants/routes' import { SEND_ROUTE } from '../../../helpers/constants/routes'
import { useMetricEvent } from '../../../hooks/useMetricEvent' import { useMetricEvent } from '../../../hooks/useMetricEvent'
import { useTokenTracker } from '../../../hooks/useTokenTracker'
import { useTokenFiatAmount } from '../../../hooks/useTokenFiatAmount'
import { getAssetImages } from '../../../selectors/selectors' import { getAssetImages } from '../../../selectors/selectors'
import { updateSendToken } from '../../../store/actions' import { updateSendToken } from '../../../store/actions'
@ -25,15 +27,30 @@ const TokenOverview = ({ className, token }) => {
}) })
const history = useHistory() const history = useHistory()
const assetImages = useSelector(getAssetImages) const assetImages = useSelector(getAssetImages)
const { tokensWithBalances } = useTokenTracker([token])
const balance = tokensWithBalances[0]?.string
const formattedFiatBalance = useTokenFiatAmount(token.address, balance, token.symbol)
return ( return (
<WalletOverview <WalletOverview
balance={( balance={(
<div className="token-overview__balance"> <div className="token-overview__balance">
<TokenBalance <CurrencyDisplay
className="token-overview__primary-balance" className="token-overview__primary-balance"
token={token} displayValue={balance}
suffix={token.symbol}
/> />
{
formattedFiatBalance
? (
<CurrencyDisplay
className="token-overview__secondary-balance"
displayValue={formattedFiatBalance}
hideLabel
/>
)
: null
}
</div> </div>
)} )}
buttons={( buttons={(