2017-10-06 06:34:00 +02:00
|
|
|
const Component = require('react').Component
|
|
|
|
const h = require('react-hyperscript')
|
|
|
|
const inherits = require('util').inherits
|
|
|
|
const Identicon = require('../identicon')
|
2017-10-10 01:17:52 +02:00
|
|
|
const AccountListItem = require('./account-list-item')
|
2017-10-06 06:34:00 +02:00
|
|
|
|
|
|
|
module.exports = FromDropdown
|
|
|
|
|
|
|
|
inherits(FromDropdown, Component)
|
|
|
|
function FromDropdown () {
|
|
|
|
Component.call(this)
|
|
|
|
}
|
|
|
|
|
2017-10-10 01:17:52 +02:00
|
|
|
FromDropdown.prototype.getListItemIcon = function (currentAccount, selectedAccount) {
|
|
|
|
const listItemIcon = h(`i.fa.fa-check.fa-lg`, { style: { color: '#02c9b1' } })
|
2017-10-06 06:34:00 +02:00
|
|
|
|
2017-10-13 22:19:22 +02:00
|
|
|
return currentAccount.address === selectedAccount.address
|
2017-10-10 01:17:52 +02:00
|
|
|
? listItemIcon
|
|
|
|
: null
|
2017-10-06 06:34:00 +02:00
|
|
|
}
|
|
|
|
|
2017-10-12 19:29:03 +02:00
|
|
|
FromDropdown.prototype.renderDropdown = function () {
|
|
|
|
const {
|
|
|
|
accounts,
|
|
|
|
selectedAccount,
|
|
|
|
closeDropdown,
|
|
|
|
onSelect,
|
|
|
|
} = this.props
|
|
|
|
|
2017-10-06 06:34:00 +02:00
|
|
|
return h('div', {}, [
|
|
|
|
|
|
|
|
h('div.send-v2__from-dropdown__close-area', {
|
|
|
|
onClick: closeDropdown,
|
|
|
|
}),
|
|
|
|
|
|
|
|
h('div.send-v2__from-dropdown__list', {}, [
|
|
|
|
|
2017-10-10 01:17:52 +02:00
|
|
|
...accounts.map(account => h(AccountListItem, {
|
|
|
|
account,
|
2017-10-12 19:29:03 +02:00
|
|
|
handleClick: () => {
|
|
|
|
onSelect(account.address)
|
|
|
|
closeDropdown()
|
|
|
|
},
|
2017-10-10 01:17:52 +02:00
|
|
|
icon: this.getListItemIcon(account, selectedAccount),
|
|
|
|
}))
|
2017-10-06 06:34:00 +02:00
|
|
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
])
|
|
|
|
}
|
|
|
|
|
|
|
|
FromDropdown.prototype.render = function () {
|
|
|
|
const {
|
2017-10-10 01:17:52 +02:00
|
|
|
accounts,
|
|
|
|
selectedAccount,
|
2017-10-06 06:34:00 +02:00
|
|
|
openDropdown,
|
|
|
|
closeDropdown,
|
|
|
|
dropdownOpen,
|
|
|
|
} = this.props
|
|
|
|
|
|
|
|
return h('div.send-v2__from-dropdown', {}, [
|
|
|
|
|
2017-10-10 01:17:52 +02:00
|
|
|
h(AccountListItem, {
|
|
|
|
account: selectedAccount,
|
|
|
|
handleClick: openDropdown,
|
|
|
|
icon: h(`i.fa.fa-caret-down.fa-lg`, { style: { color: '#dedede' } })
|
|
|
|
}),
|
2017-10-06 06:34:00 +02:00
|
|
|
|
2017-10-12 19:29:03 +02:00
|
|
|
dropdownOpen && this.renderDropdown(),
|
2017-10-06 06:34:00 +02:00
|
|
|
|
|
|
|
])
|
|
|
|
|
|
|
|
}
|
|
|
|
|