You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.3 KiB
46 lines
1.3 KiB
6 years ago
|
import React, { PureComponent } from 'react'
|
||
|
import PropTypes from 'prop-types'
|
||
|
import { PRIMARY, SECONDARY, ETH } from '../../constants/common'
|
||
|
import CurrencyDisplay from '../currency-display'
|
||
|
|
||
|
export default class UserPreferencedCurrencyDisplay extends PureComponent {
|
||
|
static propTypes = {
|
||
|
className: PropTypes.string,
|
||
|
prefix: PropTypes.string,
|
||
|
value: PropTypes.string,
|
||
|
numberOfDecimals: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||
|
hideLabel: PropTypes.bool,
|
||
|
style: PropTypes.object,
|
||
|
showEthLogo: PropTypes.bool,
|
||
|
ethLogoHeight: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||
|
// Used in container
|
||
|
type: PropTypes.oneOf([PRIMARY, SECONDARY]),
|
||
|
ethNumberOfDecimals: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||
|
fiatNumberOfDecimals: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
||
|
ethPrefix: PropTypes.string,
|
||
|
fiatPrefix: PropTypes.string,
|
||
|
// From container
|
||
|
currency: PropTypes.string,
|
||
|
}
|
||
|
|
||
|
renderEthLogo () {
|
||
|
const { currency, showEthLogo, ethLogoHeight = 12 } = this.props
|
||
|
|
||
|
return currency === ETH && showEthLogo && (
|
||
|
<img
|
||
|
src="/images/eth.svg"
|
||
|
height={ethLogoHeight}
|
||
|
/>
|
||
|
)
|
||
|
}
|
||
|
|
||
|
render () {
|
||
|
return (
|
||
|
<CurrencyDisplay
|
||
|
{...this.props}
|
||
|
prefixComponent={this.renderEthLogo()}
|
||
|
/>
|
||
|
)
|
||
|
}
|
||
|
}
|