Merge pull request #1858 from sdtsui/NewUI

UI Tweaks, Minor Bugfixes, and Dropdown Resizing
feature/default_network_editable
kumavis 7 years ago committed by GitHub
commit 17c9fd450f
  1. 2
      ui/app/account-detail.js
  2. 57
      ui/app/app.js
  3. 74
      ui/app/components/account-dropdowns.js
  4. 5
      ui/app/components/dropdown.js
  5. 2
      ui/app/css/index.css
  6. 9
      ui/app/css/lib.css

@ -128,6 +128,7 @@ AccountDetailScreen.prototype.render = function () {
selected, selected,
network, network,
identities: props.identities, identities: props.identities,
enableAccountOptions: true,
}, },
), ),
] ]
@ -152,7 +153,6 @@ AccountDetailScreen.prototype.render = function () {
fontSize: '13px', fontSize: '13px',
fontFamily: 'Montserrat Light', fontFamily: 'Montserrat Light',
textRendering: 'geometricPrecision', textRendering: 'geometricPrecision',
marginTop: '10px',
marginBottom: '15px', marginBottom: '15px',
color: '#AEAEAE', color: '#AEAEAE',
}, },

@ -30,6 +30,7 @@ const QrView = require('./components/qr-code')
const HDCreateVaultComplete = require('./keychains/hd/create-vault-complete') const HDCreateVaultComplete = require('./keychains/hd/create-vault-complete')
const HDRestoreVaultScreen = require('./keychains/hd/restore-vault') const HDRestoreVaultScreen = require('./keychains/hd/restore-vault')
const RevealSeedConfirmation = require('./keychains/hd/recover-seed/confirmation') const RevealSeedConfirmation = require('./keychains/hd/recover-seed/confirmation')
const AccountDropdowns = require('./components/account-dropdowns').AccountDropdowns
module.exports = connect(mapStateToProps)(App) module.exports = connect(mapStateToProps)(App)
@ -37,6 +38,13 @@ inherits(App, Component)
function App () { Component.call(this) } function App () { Component.call(this) }
function mapStateToProps (state) { function mapStateToProps (state) {
const {
identities,
accounts,
address,
} = state.metamask
const selected = address || Object.keys(accounts)[0]
return { return {
// state from plugin // state from plugin
isLoading: state.appState.isLoading, isLoading: state.appState.isLoading,
@ -57,6 +65,10 @@ function mapStateToProps (state) {
lastUnreadNotice: state.metamask.lastUnreadNotice, lastUnreadNotice: state.metamask.lastUnreadNotice,
lostAccounts: state.metamask.lostAccounts, lostAccounts: state.metamask.lostAccounts,
frequentRpcList: state.metamask.frequentRpcList || [], frequentRpcList: state.metamask.frequentRpcList || [],
// state needed to get account dropdown temporarily rendering from app bar
identities,
selected,
} }
} }
@ -169,17 +181,27 @@ App.prototype.renderAppBar = function () {
}, },
}, [ }, [
props.isUnlocked && h(AccountDropdowns, {
style: {},
enableAccountsSelector: true,
identities: this.props.identities,
selected: this.props.selected,
network: this.props.network,
}, []),
// hamburger // hamburger
props.isUnlocked && h(SandwichExpando, { props.isUnlocked && h(SandwichExpando, {
className: 'sandwich-expando',
width: 16, width: 16,
barHeight: 2, barHeight: 2,
padding: 0, padding: 0,
isOpen: state.isMainMenuOpen, isOpen: state.isMainMenuOpen,
color: 'rgb(247,146,30)', color: 'rgb(247,146,30)',
onClick: (event) => { onClick: () => {
event.preventDefault()
event.stopPropagation() event.stopPropagation()
this.setState({ isMainMenuOpen: !state.isMainMenuOpen }) this.setState({
isMainMenuOpen: !state.isMainMenuOpen,
})
}, },
}), }),
]), ]),
@ -227,6 +249,9 @@ App.prototype.renderNetworkDropdown = function () {
key: 'main', key: 'main',
closeMenu: () => this.setState({ isNetworkMenuOpen: !isOpen }), closeMenu: () => this.setState({ isNetworkMenuOpen: !isOpen }),
onClick: () => props.dispatch(actions.setProviderType('mainnet')), onClick: () => props.dispatch(actions.setProviderType('mainnet')),
style: {
fontSize: '18px',
},
}, },
[ [
h('.menu-icon.diamond'), h('.menu-icon.diamond'),
@ -241,6 +266,9 @@ App.prototype.renderNetworkDropdown = function () {
key: 'ropsten', key: 'ropsten',
closeMenu: () => this.setState({ isNetworkMenuOpen: !isOpen }), closeMenu: () => this.setState({ isNetworkMenuOpen: !isOpen }),
onClick: () => props.dispatch(actions.setProviderType('ropsten')), onClick: () => props.dispatch(actions.setProviderType('ropsten')),
style: {
fontSize: '18px',
},
}, },
[ [
h('.menu-icon.red-dot'), h('.menu-icon.red-dot'),
@ -255,6 +283,9 @@ App.prototype.renderNetworkDropdown = function () {
key: 'kovan', key: 'kovan',
closeMenu: () => this.setState({ isNetworkMenuOpen: !isOpen }), closeMenu: () => this.setState({ isNetworkMenuOpen: !isOpen }),
onClick: () => props.dispatch(actions.setProviderType('kovan')), onClick: () => props.dispatch(actions.setProviderType('kovan')),
style: {
fontSize: '18px',
},
}, },
[ [
h('.menu-icon.hollow-diamond'), h('.menu-icon.hollow-diamond'),
@ -269,6 +300,9 @@ App.prototype.renderNetworkDropdown = function () {
key: 'rinkeby', key: 'rinkeby',
closeMenu: () => this.setState({ isNetworkMenuOpen: !isOpen }), closeMenu: () => this.setState({ isNetworkMenuOpen: !isOpen }),
onClick: () => props.dispatch(actions.setProviderType('rinkeby')), onClick: () => props.dispatch(actions.setProviderType('rinkeby')),
style: {
fontSize: '18px',
},
}, },
[ [
h('.menu-icon.golden-square'), h('.menu-icon.golden-square'),
@ -283,6 +317,9 @@ App.prototype.renderNetworkDropdown = function () {
key: 'default', key: 'default',
closeMenu: () => this.setState({ isNetworkMenuOpen: !isOpen }), closeMenu: () => this.setState({ isNetworkMenuOpen: !isOpen }),
onClick: () => props.dispatch(actions.setDefaultRpcTarget()), onClick: () => props.dispatch(actions.setDefaultRpcTarget()),
style: {
fontSize: '18px',
},
}, },
[ [
h('i.fa.fa-question-circle.fa-lg.menu-icon'), h('i.fa.fa-question-circle.fa-lg.menu-icon'),
@ -299,6 +336,9 @@ App.prototype.renderNetworkDropdown = function () {
{ {
closeMenu: () => this.setState({ isNetworkMenuOpen: !isOpen }), closeMenu: () => this.setState({ isNetworkMenuOpen: !isOpen }),
onClick: () => this.props.dispatch(actions.showConfigPage()), onClick: () => this.props.dispatch(actions.showConfigPage()),
style: {
fontSize: '18px',
},
}, },
[ [
h('i.fa.fa-question-circle.fa-lg.menu-icon'), h('i.fa.fa-question-circle.fa-lg.menu-icon'),
@ -318,9 +358,13 @@ App.prototype.renderDropdown = function () {
isOpen: isOpen, isOpen: isOpen,
zIndex: 11, zIndex: 11,
onClickOutside: (event) => { onClickOutside: (event) => {
const { classList } = event.target const classList = event.target.classList
const isNotToggleElement = !classList.contains('sandwich-expando') const parentClassList = event.target.parentElement.classList
if (isNotToggleElement) {
const isToggleElement = classList.contains('sandwich-expando') ||
parentClassList.contains('sandwich-expando')
if (isOpen && !isToggleElement) {
this.setState({ isMainMenuOpen: false }) this.setState({ isMainMenuOpen: false })
} }
}, },
@ -579,7 +623,6 @@ App.prototype.renderCommonRpc = function (rpcList, provider) {
if ((rpc === 'http://localhost:8545') || (rpc === rpcTarget)) { if ((rpc === 'http://localhost:8545') || (rpc === rpcTarget)) {
return null return null
} else { } else {
return h( return h(
DropdownMenuItem, DropdownMenuItem,
{ {

@ -17,14 +17,14 @@ class AccountDropdowns extends Component {
accountSelectorActive: false, accountSelectorActive: false,
optionsMenuActive: false, optionsMenuActive: false,
} }
this.accountSelectorToggleClassName = 'fa-angle-down' this.accountSelectorToggleClassName = 'accounts-selector'
this.optionsMenuToggleClassName = 'fa-ellipsis-h' this.optionsMenuToggleClassName = 'fa-ellipsis-h'
} }
renderAccounts () { renderAccounts () {
const { identities, selected } = this.props const { identities, selected } = this.props
return Object.keys(identities).map((key) => { return Object.keys(identities).map((key, index) => {
const identity = identities[key] const identity = identities[key]
const isSelected = identity.address === selected const isSelected = identity.address === selected
@ -35,17 +35,24 @@ class AccountDropdowns extends Component {
onClick: () => { onClick: () => {
this.props.actions.showAccountDetail(identity.address) this.props.actions.showAccountDetail(identity.address)
}, },
style: {
marginTop: index === 0 ? '5px' : '',
fontSize: '24px',
},
}, },
[ [
h( h(
Identicon, Identicon,
{ {
address: identity.address, address: identity.address,
diameter: 16, diameter: 32,
style: {
marginLeft: '10px',
},
}, },
), ),
h('span', { style: { marginLeft: '10px' } }, identity.name || ''), h('span', { style: { marginLeft: '20px', fontSize: '24px' } }, identity.name || ''),
h('span', { style: { marginLeft: '10px' } }, isSelected ? h('.check', '✓') : null), h('span', { style: { marginLeft: '20px', fontSize: '24px' } }, isSelected ? h('.check', '✓') : null),
] ]
) )
}) })
@ -59,10 +66,15 @@ class AccountDropdowns extends Component {
Dropdown, Dropdown,
{ {
style: { style: {
marginLeft: '-125px', marginLeft: '-238px',
marginTop: '38px',
minWidth: '180px', minWidth: '180px',
overflowY: 'auto', overflowY: 'auto',
maxHeight: '300px', maxHeight: '300px',
width: '300px',
},
innerStyle: {
padding: '8px 25px',
}, },
isOpen: accountSelectorActive, isOpen: accountSelectorActive,
onClickOutside: (event) => { onClickOutside: (event) => {
@ -85,10 +97,13 @@ class AccountDropdowns extends Component {
h( h(
Identicon, Identicon,
{ {
diameter: 16, style: {
marginLeft: '10px',
},
diameter: 32,
}, },
), ),
h('span', { style: { marginLeft: '10px' } }, 'Create Account'), h('span', { style: { marginLeft: '20px', fontSize: '24px' } }, 'Create Account'),
], ],
), ),
h( h(
@ -101,10 +116,19 @@ class AccountDropdowns extends Component {
h( h(
Identicon, Identicon,
{ {
diameter: 16, style: {
marginLeft: '10px',
},
diameter: 32,
}, },
), ),
h('span', { style: { marginLeft: '10px' } }, 'Import Account'), h('span', {
style: {
marginLeft: '20px',
fontSize: '24px',
marginBottom: '5px',
},
}, 'Import Account'),
] ]
), ),
] ]
@ -119,7 +143,7 @@ class AccountDropdowns extends Component {
Dropdown, Dropdown,
{ {
style: { style: {
marginLeft: '-162px', marginLeft: '-215px',
minWidth: '180px', minWidth: '180px',
}, },
isOpen: optionsMenuActive, isOpen: optionsMenuActive,
@ -183,7 +207,7 @@ class AccountDropdowns extends Component {
} }
render () { render () {
const { style } = this.props const { style, enableAccountsSelector, enableAccountOptions } = this.props
const { optionsMenuActive, accountSelectorActive } = this.state const { optionsMenuActive, accountSelectorActive } = this.state
return h( return h(
@ -192,10 +216,18 @@ class AccountDropdowns extends Component {
style: style, style: style,
}, },
[ [
h( enableAccountsSelector && h(
'i.fa.fa-angle-down', // 'i.fa.fa-angle-down',
'div.cursor-pointer.color-orange.accounts-selector',
{ {
style: {}, style: {
// fontSize: '1.8em',
background: 'url(images/switch_acc.svg) white center center no-repeat',
height: '25px',
width: '25px',
transform: 'scale(0.75)',
marginRight: '3px',
},
onClick: (event) => { onClick: (event) => {
event.stopPropagation() event.stopPropagation()
this.setState({ this.setState({
@ -206,10 +238,13 @@ class AccountDropdowns extends Component {
}, },
this.renderAccountSelector(), this.renderAccountSelector(),
), ),
h( enableAccountOptions && h(
'i.fa.fa-ellipsis-h', 'i.fa.fa-ellipsis-h',
{ {
style: { 'marginLeft': '10px'}, style: {
marginRight: '0.5em',
fontSize: '1.8em',
},
onClick: (event) => { onClick: (event) => {
event.stopPropagation() event.stopPropagation()
this.setState({ this.setState({
@ -225,6 +260,11 @@ class AccountDropdowns extends Component {
} }
} }
AccountDropdowns.defaultProps = {
enableAccountsSelector: false,
enableAccountOptions: false,
}
AccountDropdowns.propTypes = { AccountDropdowns.propTypes = {
identities: PropTypes.objectOf(PropTypes.object), identities: PropTypes.objectOf(PropTypes.object),
selected: PropTypes.string, selected: PropTypes.string,

@ -54,7 +54,7 @@ Dropdown.propTypes = {
class DropdownMenuItem extends Component { class DropdownMenuItem extends Component {
render () { render () {
const { onClick, closeMenu, children } = this.props const { onClick, closeMenu, children, style } = this.props
return h( return h(
'li.dropdown-menu-item', 'li.dropdown-menu-item',
@ -66,13 +66,14 @@ class DropdownMenuItem extends Component {
style: { style: {
listStyle: 'none', listStyle: 'none',
padding: '8px 0px 8px 0px', padding: '8px 0px 8px 0px',
fontSize: '12px', fontSize: '18px',
fontStyle: 'normal', fontStyle: 'normal',
fontFamily: 'Montserrat Regular', fontFamily: 'Montserrat Regular',
cursor: 'pointer', cursor: 'pointer',
display: 'flex', display: 'flex',
justifyContent: 'flex-start', justifyContent: 'flex-start',
alignItems: 'center', alignItems: 'center',
...style,
}, },
}, },
children children

@ -201,7 +201,7 @@ textarea.twelve-word-phrase {
} }
.check { .check {
margin-left: 7px; margin-left: 12px;
color: #F7861C; color: #F7861C;
flex: 1 0 auto; flex: 1 0 auto;
display: flex; display: flex;

@ -238,10 +238,15 @@ hr.horizontal-line {
.menu-icon { .menu-icon {
display: inline-block; display: inline-block;
height: 9px; height: 12px;
min-width: 9px; min-width: 12px;
margin: 13px; margin: 13px;
} }
i.fa.fa-question-circle.fa-lg.menu-icon {
font-size: 18px;
}
.ether-icon { .ether-icon {
background: rgb(0, 163, 68); background: rgb(0, 163, 68);
border-radius: 20px; border-radius: 20px;

Loading…
Cancel
Save