parent
89a8267fe7
commit
980e1bfcf8
@ -0,0 +1,96 @@ |
||||
const { Component } = require('react') |
||||
const PropTypes = require('prop-types') |
||||
const h = require('react-hyperscript') |
||||
const { connect } = require('react-redux') |
||||
const actions = require('../../actions') |
||||
|
||||
class NewAccountCreateForm extends Component { |
||||
constructor (props) { |
||||
super(props) |
||||
const { numberOfExistingAccounts = 0 } = props |
||||
const newAccountNumber = numberOfExistingAccounts + 1 |
||||
|
||||
this.state = { |
||||
newAccountName: `Account ${newAccountNumber}`, |
||||
} |
||||
} |
||||
|
||||
render () { |
||||
const { newAccountName } = this.state |
||||
|
||||
return h('div.new-account-create-form', [ |
||||
|
||||
h('div.new-account-create-form__input-label', {}, [ |
||||
'Account Name', |
||||
]), |
||||
|
||||
h('div.new-account-create-form__input-wrapper', {}, [ |
||||
h('input.new-account-create-form__input', { |
||||
value: this.state.newAccountName, |
||||
placeholder: 'E.g. My new account', |
||||
onChange: event => this.setState({ newAccountName: event.target.value }), |
||||
}, []), |
||||
]), |
||||
|
||||
h('div.new-account-create-form__buttons', {}, [ |
||||
|
||||
h('button.new-account-create-form__button-cancel', { |
||||
onClick: () => this.props.goHome(), |
||||
}, [ |
||||
'CANCEL', |
||||
]), |
||||
|
||||
h('button.new-account-create-form__button-create', { |
||||
onClick: () => this.props.createAccount(newAccountName), |
||||
}, [ |
||||
'CREATE', |
||||
]), |
||||
|
||||
]), |
||||
|
||||
]) |
||||
} |
||||
} |
||||
|
||||
NewAccountCreateForm.propTypes = { |
||||
hideModal: PropTypes.func, |
||||
showImportPage: PropTypes.func, |
||||
createAccount: PropTypes.func, |
||||
goHome: PropTypes.func, |
||||
numberOfExistingAccounts: PropTypes.number, |
||||
} |
||||
|
||||
const mapStateToProps = state => { |
||||
const { metamask: { network, selectedAddress, identities = {} } } = state |
||||
const numberOfExistingAccounts = Object.keys(identities).length |
||||
|
||||
return { |
||||
network, |
||||
address: selectedAddress, |
||||
numberOfExistingAccounts, |
||||
} |
||||
} |
||||
|
||||
const mapDispatchToProps = dispatch => { |
||||
return { |
||||
toCoinbase: (address) => { |
||||
dispatch(actions.buyEth({ network: '1', address, amount: 0 })) |
||||
}, |
||||
hideModal: () => { |
||||
dispatch(actions.hideModal()) |
||||
}, |
||||
createAccount: (newAccountName) => { |
||||
dispatch(actions.addNewAccount()) |
||||
.then((newAccountAddress) => { |
||||
if (newAccountName) { |
||||
dispatch(actions.saveAccountLabel(newAccountAddress, newAccountName)) |
||||
} |
||||
dispatch(actions.goHome()) |
||||
}) |
||||
}, |
||||
showImportPage: () => dispatch(actions.showImportPage()), |
||||
goHome: () => dispatch(actions.goHome()), |
||||
} |
||||
} |
||||
|
||||
module.exports = connect(mapStateToProps, mapDispatchToProps)(NewAccountCreateForm) |
@ -0,0 +1,82 @@ |
||||
const Component = require('react').Component |
||||
const h = require('react-hyperscript') |
||||
const inherits = require('util').inherits |
||||
const connect = require('react-redux').connect |
||||
const actions = require('../../actions') |
||||
const { getCurrentViewContext } = require('../../selectors') |
||||
const classnames = require('classnames') |
||||
|
||||
const NewAccountCreateForm = require('./create-form') |
||||
const NewAccountImportForm = require('../import') |
||||
|
||||
function mapStateToProps (state) { |
||||
return { |
||||
displayedForm: getCurrentViewContext(state), |
||||
} |
||||
} |
||||
|
||||
function mapDispatchToProps (dispatch) { |
||||
return { |
||||
// Is this supposed to be used somewhere?
|
||||
displayForm: form => dispatch(actions.setNewAccountForm(form)), |
||||
showQrView: (selected, identity) => dispatch(actions.showQrView(selected, identity)), |
||||
showExportPrivateKeyModal: () => { |
||||
dispatch(actions.showModal({ name: 'EXPORT_PRIVATE_KEY' })) |
||||
}, |
||||
hideModal: () => dispatch(actions.hideModal()), |
||||
saveAccountLabel: (address, label) => dispatch(actions.saveAccountLabel(address, label)), |
||||
} |
||||
} |
||||
|
||||
inherits(AccountDetailsModal, Component) |
||||
function AccountDetailsModal (props) { |
||||
Component.call(this) |
||||
|
||||
this.state = { |
||||
displayedForm: props.displayedForm, |
||||
} |
||||
} |
||||
|
||||
module.exports = connect(mapStateToProps, mapDispatchToProps)(AccountDetailsModal) |
||||
|
||||
AccountDetailsModal.prototype.render = function () { |
||||
const { displayedForm, displayForm } = this.props |
||||
|
||||
return h('div.new-account', {}, [ |
||||
|
||||
h('div.new-account__header', [ |
||||
|
||||
h('div.new-account__title', 'New Account'), |
||||
|
||||
h('div.new-account__tabs', [ |
||||
|
||||
h('div.new-account__tabs__tab', { |
||||
className: classnames('new-account__tabs__tab', { |
||||
'new-account__tabs__selected': displayedForm === 'CREATE', |
||||
'new-account__tabs__unselected cursor-pointer': displayedForm !== 'CREATE', |
||||
}), |
||||
onClick: () => displayForm('CREATE'), |
||||
}, 'Create'), |
||||
|
||||
h('div.new-account__tabs__tab', { |
||||
className: classnames('new-account__tabs__tab', { |
||||
'new-account__tabs__selected': displayedForm === 'IMPORT', |
||||
'new-account__tabs__unselected cursor-pointer': displayedForm !== 'IMPORT', |
||||
}), |
||||
onClick: () => displayForm('IMPORT'), |
||||
}, 'Import'), |
||||
|
||||
]), |
||||
|
||||
]), |
||||
|
||||
h('div.new-account__form', [ |
||||
|
||||
displayedForm === 'CREATE' |
||||
? h(NewAccountCreateForm) |
||||
: h(NewAccountImportForm), |
||||
|
||||
]), |
||||
|
||||
]) |
||||
} |
@ -0,0 +1,181 @@ |
||||
.new-account { |
||||
width: 376px; |
||||
background-color: #FFFFFF; |
||||
box-shadow: 0 0 7px 0 rgba(0,0,0,0.08); |
||||
z-index: 25; |
||||
padding-bottom: 31px; |
||||
|
||||
&__header { |
||||
display: flex; |
||||
flex-flow: column; |
||||
border-bottom: 1px solid $geyser; |
||||
} |
||||
|
||||
&__title { |
||||
color: $tundora; |
||||
font-family: Roboto; |
||||
font-size: 32px; |
||||
font-weight: 500; |
||||
line-height: 43px; |
||||
margin-top: 22px; |
||||
margin-left: 29px; |
||||
} |
||||
|
||||
&__tabs { |
||||
margin-left: 22px; |
||||
display: flex; |
||||
margin-top: 10px; |
||||
|
||||
&__tab { |
||||
height: 54px; |
||||
width: 75px; |
||||
padding: 15px 10px; |
||||
color: $dusty-gray; |
||||
font-family: Roboto; |
||||
font-size: 18px; |
||||
line-height: 24px; |
||||
text-align: center; |
||||
} |
||||
|
||||
&__tab:first-of-type { |
||||
margin-right: 20px; |
||||
} |
||||
|
||||
&__unselected:hover { |
||||
color: $black; |
||||
border-bottom: none; |
||||
} |
||||
|
||||
&__selected { |
||||
color: $curious-blue; |
||||
border-bottom: 3px solid $curious-blue; |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
.new-account-import-form { |
||||
&__select-section { |
||||
display: flex; |
||||
justify-content: space-evenly; |
||||
align-items: center; |
||||
margin-top: 29px; |
||||
} |
||||
|
||||
&__select-label { |
||||
color: $scorpion; |
||||
font-family: Roboto; |
||||
font-size: 16px; |
||||
line-height: 21px; |
||||
} |
||||
|
||||
&__select { |
||||
height: 54px; |
||||
width: 210px; |
||||
border: 1px solid #D2D8DD; |
||||
border-radius: 4px; |
||||
background-color: #FFFFFF; |
||||
display: flex; |
||||
align-items: center; |
||||
|
||||
.Select-control, |
||||
.Select-control:hover { |
||||
border: none; |
||||
box-shadow: none; |
||||
} |
||||
} |
||||
|
||||
&__instruction { |
||||
color: $scorpion; |
||||
font-family: Roboto; |
||||
font-size: 16px; |
||||
line-height: 21px; |
||||
align-self: flex-start; |
||||
margin-left: 30px; |
||||
} |
||||
|
||||
&__private-key { |
||||
display: flex; |
||||
flex-flow: column; |
||||
align-items: center; |
||||
margin-top: 34px; |
||||
} |
||||
|
||||
&__input-password { |
||||
height: 54px; |
||||
width: 315px; |
||||
border: 1px solid $geyser; |
||||
border-radius: 4px; |
||||
background-color: $white; |
||||
margin-top: 16px; |
||||
} |
||||
|
||||
&__json { |
||||
display: flex; |
||||
flex-flow: column; |
||||
align-items: center; |
||||
margin-top: 29px; |
||||
} |
||||
} |
||||
|
||||
.new-account-create-form { |
||||
display: flex; |
||||
flex-flow: column; |
||||
align-items: center; |
||||
|
||||
&__input-label { |
||||
color: $scorpion; |
||||
font-family: Roboto; |
||||
font-size: 16px; |
||||
line-height: 21px; |
||||
margin-top: 29px; |
||||
align-self: flex-start; |
||||
margin-left: 30px; |
||||
} |
||||
|
||||
&__input { |
||||
height: 54px; |
||||
width: 315.84px; |
||||
border: 1px solid $geyser; |
||||
border-radius: 4px; |
||||
background-color: $white; |
||||
color: $scorpion; |
||||
font-family: Roboto; |
||||
font-size: 16px; |
||||
line-height: 21px; |
||||
margin-top: 15px; |
||||
} |
||||
|
||||
&__buttons { |
||||
margin-top: 39px; |
||||
display: flex; |
||||
width: 100%; |
||||
justify-content: space-evenly; |
||||
} |
||||
|
||||
&__button-cancel, |
||||
&__button-create { |
||||
height: 55px; |
||||
width: 150px; |
||||
border-radius: 2px; |
||||
background-color: #FFFFFF; |
||||
} |
||||
|
||||
&__button-cancel { |
||||
border: 1px solid $dusty-gray; |
||||
color: $dusty-gray; |
||||
font-family: Roboto; |
||||
font-size: 16px; |
||||
line-height: 21px; |
||||
text-align: center; |
||||
} |
||||
|
||||
&__button-create { |
||||
border: 1px solid $curious-blue; |
||||
color: $curious-blue; |
||||
font-family: Roboto; |
||||
font-size: 16px; |
||||
line-height: 21px; |
||||
text-align: center; |
||||
} |
||||
} |
Loading…
Reference in new issue