diff options
author | Alexander Tseung <alextsg@users.noreply.github.com> | 2019-01-17 06:50:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-17 06:50:24 +0800 |
commit | 3fe78a8f48c0820b76f5d0fbf2f82d16d7e10751 (patch) | |
tree | 9d0844a6e5c47d65b64b8129fdb0580d80989a8c /ui/app/components/account-dropdown-mini/account-dropdown-mini.component.js | |
parent | 13463309dce281ee6264d3d5a4399d0cc49c1f8f (diff) | |
download | tangerine-wallet-browser-3fe78a8f48c0820b76f5d0fbf2f82d16d7e10751.tar tangerine-wallet-browser-3fe78a8f48c0820b76f5d0fbf2f82d16d7e10751.tar.gz tangerine-wallet-browser-3fe78a8f48c0820b76f5d0fbf2f82d16d7e10751.tar.bz2 tangerine-wallet-browser-3fe78a8f48c0820b76f5d0fbf2f82d16d7e10751.tar.lz tangerine-wallet-browser-3fe78a8f48c0820b76f5d0fbf2f82d16d7e10751.tar.xz tangerine-wallet-browser-3fe78a8f48c0820b76f5d0fbf2f82d16d7e10751.tar.zst tangerine-wallet-browser-3fe78a8f48c0820b76f5d0fbf2f82d16d7e10751.zip |
Disable account dropdown on signing screens (#6024)
Diffstat (limited to 'ui/app/components/account-dropdown-mini/account-dropdown-mini.component.js')
-rw-r--r-- | ui/app/components/account-dropdown-mini/account-dropdown-mini.component.js | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/ui/app/components/account-dropdown-mini/account-dropdown-mini.component.js b/ui/app/components/account-dropdown-mini/account-dropdown-mini.component.js new file mode 100644 index 000000000..8a171d0c6 --- /dev/null +++ b/ui/app/components/account-dropdown-mini/account-dropdown-mini.component.js @@ -0,0 +1,84 @@ +import React, { PureComponent } from 'react' +import PropTypes from 'prop-types' +import AccountListItem from '../send/account-list-item/account-list-item.component' + +export default class AccountDropdownMini extends PureComponent { + static propTypes = { + accounts: PropTypes.array.isRequired, + closeDropdown: PropTypes.func, + disabled: PropTypes.bool, + dropdownOpen: PropTypes.bool, + onSelect: PropTypes.func, + openDropdown: PropTypes.func, + selectedAccount: PropTypes.object.isRequired, + } + + static defaultProps = { + closeDropdown: () => {}, + disabled: false, + dropdownOpen: false, + onSelect: () => {}, + openDropdown: () => {}, + } + + getListItemIcon (currentAccount, selectedAccount) { + return currentAccount.address === selectedAccount.address && ( + <i + className="fa fa-check fa-lg" + style={{ color: '#02c9b1' }} + /> + ) + } + + renderDropdown () { + const { accounts, selectedAccount, closeDropdown, onSelect } = this.props + + return ( + <div> + <div + className="account-dropdown-mini__close-area" + onClick={closeDropdown} + /> + <div className="account-dropdown-mini__list"> + { + accounts.map(account => ( + <AccountListItem + key={account.address} + account={account} + displayBalance={false} + displayAddress={false} + handleClick={() => { + onSelect(account) + closeDropdown() + }} + icon={this.getListItemIcon(account, selectedAccount)} + /> + )) + } + </div> + </div> + ) + } + + render () { + const { disabled, selectedAccount, openDropdown, dropdownOpen } = this.props + + return ( + <div className="account-dropdown-mini"> + <AccountListItem + account={selectedAccount} + handleClick={() => !disabled && openDropdown()} + displayBalance={false} + displayAddress={false} + icon={ + !disabled && <i + className="fa fa-caret-down fa-lg" + style={{ color: '#dedede' }} + /> + } + /> + { !disabled && dropdownOpen && this.renderDropdown() } + </div> + ) + } +} |