1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-24 11:01:41 +01:00
metamask-extension/ui/app/components/send/from-dropdown.js

75 lines
1.6 KiB
JavaScript
Raw Normal View History

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