nifty-wallet/ui/app/components/network.js

117 lines
3.2 KiB
JavaScript
Raw Normal View History

const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
module.exports = Network
inherits(Network, Component)
2016-06-21 13:18:32 -07:00
function Network () {
Component.call(this)
}
2016-06-21 13:18:32 -07:00
Network.prototype.render = function () {
2016-07-28 10:53:51 -07:00
const props = this.props
const networkNumber = props.network
let providerName
try {
providerName = props.provider.type
} catch (e) {
providerName = null
}
let iconName, hoverText
2016-06-21 13:56:04 -07:00
if (networkNumber === 'loading') {
return h('img.network-indicator', {
title: 'Attempting to connect to blockchain.',
2016-06-21 13:18:32 -07:00
onClick: (event) => this.props.onClick(event),
2016-06-03 13:58:09 -07:00
style: {
width: '27px',
2016-06-21 13:18:32 -07:00
marginRight: '-27px',
2016-06-03 13:58:09 -07:00
},
src: 'images/loading.svg',
})
2016-07-28 10:53:51 -07:00
} else if (providerName === 'mainnet') {
hoverText = 'Main Ethereum Network'
iconName = 'ethereum-network'
2017-05-15 18:05:11 -07:00
} else if (providerName === 'ropsten') {
hoverText = 'Ropsten Test Network'
iconName = 'ropsten-test-network'
} else if (parseInt(networkNumber) === 3) {
hoverText = 'Ropsten Test Network'
iconName = 'ropsten-test-network'
} else if (providerName === 'kovan') {
hoverText = 'Kovan Test Network'
iconName = 'kovan-test-network'
2017-05-15 19:11:16 -07:00
} else if (providerName === 'rinkeby') {
2017-04-25 13:10:33 -07:00
hoverText = 'Rinkeby Test Network'
iconName = 'rinkeby-test-network'
2017-04-25 14:44:25 -07:00
} else {
2016-06-21 13:18:32 -07:00
hoverText = 'Unknown Private Network'
iconName = 'unknown-private-network'
}
return (
h('#network_component.pointer', {
title: hoverText,
2016-06-21 13:18:32 -07:00
onClick: (event) => this.props.onClick(event),
}, [
2016-06-21 13:56:04 -07:00
(function () {
2016-06-21 13:18:32 -07:00
switch (iconName) {
case 'ethereum-network':
2016-06-29 16:31:27 -07:00
return h('.network-indicator', [
h('.menu-icon.diamond'),
h('.network-name', {
style: {
color: '#039396',
}},
2016-08-26 15:08:02 -07:00
'Ethereum Main Net'),
2016-06-29 16:31:27 -07:00
])
case 'ropsten-test-network':
return h('.network-indicator', [
h('.menu-icon.red-dot'),
h('.network-name', {
style: {
color: '#ff6666',
}},
'Ropsten Test Net'),
])
case 'kovan-test-network':
return h('.network-indicator', [
h('.menu-icon.hollow-diamond'),
h('.network-name', {
style: {
color: '#690496',
}},
'Kovan Test Net'),
])
case 'rinkeby-test-network':
return h('.network-indicator', [
h('.menu-icon.golden-square'),
h('.network-name', {
style: {
2017-05-15 18:05:11 -07:00
color: '#e7a218',
}},
'Rinkeby Test Net'),
])
2016-06-21 13:18:32 -07:00
default:
2016-06-29 16:31:27 -07:00
return h('.network-indicator', [
h('i.fa.fa-question-circle.fa-lg', {
style: {
margin: '10px',
color: 'rgb(125, 128, 130)',
},
}),
2016-06-29 16:31:27 -07:00
h('.network-name', {
style: {
color: '#AEAEAE',
}},
'Private Network'),
])
2016-06-21 13:18:32 -07:00
}
2016-06-21 13:56:04 -07:00
})(),
])
)
}