commit
e1cd3562ce
@ -0,0 +1,22 @@ |
||||
class BugNotifier { |
||||
notify (uri, message) { |
||||
return postData(uri, message) |
||||
} |
||||
} |
||||
|
||||
function postData(uri, data) { |
||||
return fetch(uri, { |
||||
body: JSON.stringify(data), // must match 'Content-Type' header
|
||||
credentials: 'same-origin', // include, same-origin, *omit
|
||||
headers: { |
||||
'content-type': 'application/json', |
||||
}, |
||||
method: 'POST', // *GET, POST, PUT, DELETE, etc.
|
||||
mode: 'cors', // no-cors, cors, *same-origin
|
||||
}) |
||||
} |
||||
|
||||
const notifier = new BugNotifier() |
||||
|
||||
module.exports = notifier |
||||
|
@ -0,0 +1,2 @@ |
||||
import SelectedAccount from './selected-account.container' |
||||
module.exports = SelectedAccount |
@ -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; |
||||
} |
||||
} |
||||
} |
@ -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 |
@ -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) |
Loading…
Reference in new issue