1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-27 12:56:01 +01:00
metamask-extension/ui/app/components/network-display.js

57 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-03-20 00:12:09 +01:00
const { Component } = require('react')
const h = require('react-hyperscript')
const PropTypes = require('prop-types')
const connect = require('react-redux').connect
2018-03-20 00:12:09 +01:00
const NetworkDropdownIcon = require('./dropdowns/components/network-dropdown-icon')
const networkToColorHash = {
1: '#038789',
3: '#e91550',
42: '#690496',
4: '#ebb33f',
}
class NetworkDisplay extends Component {
renderNetworkIcon () {
const { network } = this.props
const networkColor = networkToColorHash[network]
return networkColor
? h(NetworkDropdownIcon, { backgroundColor: networkColor })
: h('i.fa.fa-question-circle.fa-med', {
style: {
margin: '0 4px',
color: 'rgb(125, 128, 130)',
},
})
}
render () {
const { provider: { type } } = this.props
return h('.network-display__container', [
this.renderNetworkIcon(),
h('.network-name', this.context.t(type)),
2018-03-20 00:12:09 +01:00
])
}
}
NetworkDisplay.propTypes = {
network: PropTypes.string,
provider: PropTypes.object,
2018-03-22 03:18:10 +01:00
t: PropTypes.func,
2018-03-20 00:12:09 +01:00
}
const mapStateToProps = ({ metamask: { network, provider } }) => {
return {
network,
provider,
}
}
NetworkDisplay.contextTypes = {
t: PropTypes.func,
}
2018-03-20 00:12:09 +01:00
module.exports = connect(mapStateToProps)(NetworkDisplay)