1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
Brad Decker d5a539e0e5
remove old tooltip component and styles (#9250)
The old tooltip component was only used in two places. Removing those usages
was simple and straight forward. So, instead of colocating the old tooltip
styles with the deprecated tooltip component, I removed all old styles and
made tooltip-v2 now simply 'tooltip' and removed the deprecated component.
2020-08-18 11:13:55 -05:00

124 lines
3.9 KiB
JavaScript

import React, { useContext } from 'react'
import PropTypes from 'prop-types'
import { useDispatch, useSelector } from 'react-redux'
import classnames from 'classnames'
import { useHistory } from 'react-router-dom'
import Button from '../../ui/button'
import Identicon from '../../ui/identicon'
import { I18nContext } from '../../../contexts/i18n'
import WalletOverview from './wallet-overview'
import { SEND_ROUTE } from '../../../helpers/constants/routes'
import { useMetricEvent } from '../../../hooks/useMetricEvent'
import Tooltip from '../../ui/tooltip'
import UserPreferencedCurrencyDisplay from '../user-preferenced-currency-display'
import { PRIMARY, SECONDARY } from '../../../helpers/constants/common'
import { showModal } from '../../../store/actions'
import { isBalanceCached, getSelectedAccount, getShouldShowFiat } from '../../../selectors/selectors'
import PaperAirplane from '../../ui/icon/paper-airplane-icon'
const EthOverview = ({ className }) => {
const dispatch = useDispatch()
const t = useContext(I18nContext)
const sendEvent = useMetricEvent({
eventOpts: {
category: 'Navigation',
action: 'Home',
name: 'Clicked Send: Eth',
},
})
const depositEvent = useMetricEvent({
eventOpts: {
category: 'Navigation',
action: 'Home',
name: 'Clicked Deposit',
},
})
const history = useHistory()
const balanceIsCached = useSelector(isBalanceCached)
const showFiat = useSelector(getShouldShowFiat)
const selectedAccount = useSelector(getSelectedAccount)
const { balance } = selectedAccount
return (
<WalletOverview
balance={(
<Tooltip position="top" title={t('balanceOutdated')} disabled={!balanceIsCached}>
<div className="eth-overview__balance">
<div className="eth-overview__primary-container">
<UserPreferencedCurrencyDisplay
className={classnames('eth-overview__primary-balance', {
'eth-overview__cached-balance': balanceIsCached,
})}
data-testid="eth-overview__primary-currency"
value={balance}
type={PRIMARY}
ethNumberOfDecimals={4}
hideTitle
/>
{
balanceIsCached ? <span className="eth-overview__cached-star">*</span> : null
}
</div>
{
showFiat && (
<UserPreferencedCurrencyDisplay
className={classnames({
'eth-overview__cached-secondary-balance': balanceIsCached,
'eth-overview__secondary-balance': !balanceIsCached,
})}
data-testid="eth-overview__secondary-currency"
value={balance}
type={SECONDARY}
ethNumberOfDecimals={4}
hideTitle
/>
)
}
</div>
</Tooltip>
)}
buttons={(
<>
<Button
type="primary"
className="eth-overview__button"
rounded
onClick={() => {
depositEvent()
dispatch(showModal({ name: 'DEPOSIT_ETHER' }))
}}
>
{ t('buy') }
</Button>
<Button
type="secondary"
className="eth-overview__button"
rounded
icon={<PaperAirplane color="#037DD6" size={20} />}
onClick={() => {
sendEvent()
history.push(SEND_ROUTE)
}}
data-testid="eth-overview-send"
>
{ t('send') }
</Button>
</>
)}
className={className}
icon={<Identicon diameter={32} />}
/>
)
}
EthOverview.propTypes = {
className: PropTypes.string,
}
EthOverview.defaultProps = {
className: undefined,
}
export default EthOverview