diff options
author | Alexander Tseung <alextsg@users.noreply.github.com> | 2018-06-05 00:33:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-05 00:33:25 +0800 |
commit | 5a2771dd470161f5678e3245f90aeb3a1ce1b89c (patch) | |
tree | 532ad66d97408da9b9c58fc3b98e81f83cd44266 /ui/app/components/selected-account | |
parent | 83c7de21693dc44e59d255607d9fcdf3870ca1f1 (diff) | |
download | tangerine-wallet-browser-5a2771dd470161f5678e3245f90aeb3a1ce1b89c.tar tangerine-wallet-browser-5a2771dd470161f5678e3245f90aeb3a1ce1b89c.tar.gz tangerine-wallet-browser-5a2771dd470161f5678e3245f90aeb3a1ce1b89c.tar.bz2 tangerine-wallet-browser-5a2771dd470161f5678e3245f90aeb3a1ce1b89c.tar.lz tangerine-wallet-browser-5a2771dd470161f5678e3245f90aeb3a1ce1b89c.tar.xz tangerine-wallet-browser-5a2771dd470161f5678e3245f90aeb3a1ce1b89c.tar.zst tangerine-wallet-browser-5a2771dd470161f5678e3245f90aeb3a1ce1b89c.zip |
Indicate the current selected account on the popup account view (#4445)
Diffstat (limited to 'ui/app/components/selected-account')
4 files changed, 113 insertions, 0 deletions
diff --git a/ui/app/components/selected-account/index.js b/ui/app/components/selected-account/index.js new file mode 100644 index 000000000..eb342181f --- /dev/null +++ b/ui/app/components/selected-account/index.js @@ -0,0 +1,2 @@ +import SelectedAccount from './selected-account.container' +module.exports = SelectedAccount diff --git a/ui/app/components/selected-account/index.scss b/ui/app/components/selected-account/index.scss new file mode 100644 index 000000000..5339a228b --- /dev/null +++ b/ui/app/components/selected-account/index.scss @@ -0,0 +1,38 @@ +.selected-account { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + flex: 1; + + &__name { + max-width: 200px; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + text-align: center; + } + + &__address { + font-size: .75rem; + color: $silver-chalice; + } + + &__clickable { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + padding: 5px 15px; + border-radius: 10px; + cursor: pointer; + + &:hover { + background-color: #e8e6e8; + } + + &:active { + background-color: #d9d7da; + } + } +} diff --git a/ui/app/components/selected-account/selected-account.component.js b/ui/app/components/selected-account/selected-account.component.js new file mode 100644 index 000000000..3386a4196 --- /dev/null +++ b/ui/app/components/selected-account/selected-account.component.js @@ -0,0 +1,60 @@ +import React, { Component } from 'react' +import PropTypes from 'prop-types' +import copyToClipboard from 'copy-to-clipboard' + +const Tooltip = require('../tooltip-v2.js') + +const addressStripper = (address = '') => { + if (address.length < 4) { + return address + } + + return `${address.slice(0, 4)}...${address.slice(-4)}` +} + +class SelectedAccount extends Component { + state = { + copied: false, + } + + static contextTypes = { + t: PropTypes.func, + } + + static propTypes = { + selectedAddress: PropTypes.string, + selectedIdentity: PropTypes.object, + } + + render () { + const { t } = this.context + const { selectedAddress, selectedIdentity } = this.props + + return ( + <div className="selected-account"> + <Tooltip + position="bottom" + title={this.state.copied ? t('copiedExclamation') : t('copyToClipboard')} + > + <div + className="selected-account__clickable" + onClick={() => { + this.setState({ copied: true }) + setTimeout(() => this.setState({ copied: false }), 3000) + copyToClipboard(selectedAddress) + }} + > + <div className="selected-account__name"> + { selectedIdentity.name } + </div> + <div className="selected-account__address"> + { addressStripper(selectedAddress) } + </div> + </div> + </Tooltip> + </div> + ) + } +} + +export default SelectedAccount diff --git a/ui/app/components/selected-account/selected-account.container.js b/ui/app/components/selected-account/selected-account.container.js new file mode 100644 index 000000000..f9e061d15 --- /dev/null +++ b/ui/app/components/selected-account/selected-account.container.js @@ -0,0 +1,13 @@ +import { connect } from 'react-redux' +import SelectedAccount from './selected-account.component' + +const selectors = require('../../selectors') + +const mapStateToProps = state => { + return { + selectedAddress: selectors.getSelectedAddress(state), + selectedIdentity: selectors.getSelectedIdentity(state), + } +} + +export default connect(mapStateToProps)(SelectedAccount) |