mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
badebe017f
* Add UnitInput component * Add CurrencyInput component * Add UserPreferencedCurrencyInput component * Add UserPreferencedCurrencyDisplay component * Add updatePreferences action * Add styles for CurrencyInput, CurrencyDisplay, and UnitInput * Update SettingsTab page with Primary Currency toggle * Refactor currency displays and inputs to use UserPreferenced displays and inputs * Add TokenInput component * Add UserPreferencedTokenInput component * Use TokenInput in the send screen * Fix unit tests * Fix e2e and integration tests * Remove send/CurrencyDisplay component * Replace diamond unicode character with Eth logo. Fix typos
46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
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()}
|
|
/>
|
|
)
|
|
}
|
|
}
|