1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +01:00

Finish clean implementation of drop-down menu

This commit is contained in:
Dan Finlay 2016-05-18 17:32:26 -07:00
parent d0b0526765
commit 9d0cad0e16
3 changed files with 57 additions and 52 deletions

View File

@ -37,7 +37,7 @@
"identicon.js": "^1.2.1", "identicon.js": "^1.2.1",
"inject-css": "^0.1.1", "inject-css": "^0.1.1",
"jazzicon": "^1.1.3", "jazzicon": "^1.1.3",
"menu-droppo": "^1.0.3", "menu-droppo": "^1.1.0",
"metamask-logo": "^1.1.5", "metamask-logo": "^1.1.5",
"multiplex": "^6.7.0", "multiplex": "^6.7.0",
"once": "^1.3.3", "once": "^1.3.3",

View File

@ -68,6 +68,7 @@ App.prototype.render = function() {
// app bar // app bar
this.renderAppBar(), this.renderAppBar(),
this.renderDropdown(),
// panel content // panel content
h('.app-primary.flex-grow' + (transForward ? '.from-right' : '.from-left'), { h('.app-primary.flex-grow' + (transForward ? '.from-right' : '.from-left'), {
@ -139,6 +140,8 @@ App.prototype.renderAppBar = function(){
visibility: state.isUnlocked ? 'visibile' : 'none', visibility: state.isUnlocked ? 'visibile' : 'none',
background: state.isUnlocked ? 'white' : 'none', background: state.isUnlocked ? 'white' : 'none',
height: '36px', height: '36px',
position: 'relative',
zIndex: 1,
}, },
}, state.isUnlocked && [ }, state.isUnlocked && [
@ -166,65 +169,67 @@ App.prototype.renderAppBar = function(){
}, },
}), }),
]), ]),
h(MenuDroppo, {
style: {
right: '0px',
},
innerStyle: {
background: 'white',
// This shadow is hidden by the surrounding bounding box.
// Maybe worth revealing in the future:
boxShadow: '1px 1px 2px rgba(0,0,0,0.1)',
float: 'right',
},
isOpen: state.menuOpen,
onClickOutside: (event) => {
this.props.dispatch(actions.closeMenu())
},
}, [ // DROP MENU ITEMS
h('menu', [
h('style', '.drop-menu-item:hover { background:rgb(235, 235, 235); }'),
h(DropMenuItem, {
closeMenu:() => this.props.dispatch(actions.closeMenu()),
action:() => this.props.dispatch(actions.showConfigPage()),
icon: null,
label: 'Settings'
}),
h(DropMenuItem, {
closeMenu:() => this.props.dispatch(actions.closeMenu()),
action:() => this.props.dispatch(actions.lockMetamask()),
icon: null,
label: 'Lock Account'
}),
h(DropMenuItem, {
closeMenu:() => this.props.dispatch(actions.closeMenu()),
action:() => this.props.dispatch(actions.showInfoPage()),
icon: null,
label: 'Help'
}),
]),
]),
]) ])
) )
} }
App.prototype.renderPrimary = function(state){ App.prototype.renderDropdown = function() {
var state = this.props const props = this.props
return h(MenuDroppo, {
isOpen: props.menuOpen,
onClickOutside: (event) => {
this.props.dispatch(actions.closeMenu())
},
style: {
position: 'fixed',
right: 0,
zIndex: 0,
},
innerStyle: {
background: 'white',
boxShadow: '1px 1px 2px rgba(0,0,0,0.1)',
},
}, [ // DROP MENU ITEMS
h('style', `
.drop-menu-item:hover { background:rgb(235, 235, 235); }
.drop-menu-item i { margin: 11px; }
`),
if (state.seedWords) { h(DropMenuItem, {
label: 'Settings',
closeMenu:() => this.props.dispatch(actions.closeMenu()),
action:() => this.props.dispatch(actions.showConfigPage()),
icon: h('i.fa.fa-gear.fa-lg', { ariaHidden: true }),
}),
h(DropMenuItem, {
label: 'Lock Account',
closeMenu:() => this.props.dispatch(actions.closeMenu()),
action:() => this.props.dispatch(actions.lockMetamask()),
icon: h('i.fa.fa-lock.fa-lg', { ariaHidden: true }),
}),
h(DropMenuItem, {
label: 'Help',
closeMenu:() => this.props.dispatch(actions.closeMenu()),
action:() => this.props.dispatch(actions.showInfoPage()),
icon: h('i.fa.fa-question.fa-lg', { ariaHidden: true }),
}),
])
}
App.prototype.renderPrimary = function(){
var props = this.props
if (props.seedWords) {
return h(CreateVaultCompleteScreen, {key: 'createVaultComplete'}) return h(CreateVaultCompleteScreen, {key: 'createVaultComplete'})
} }
// show initialize screen // show initialize screen
if (!state.isInitialized) { if (!props.isInitialized) {
// show current view // show current view
switch (state.currentView.name) { switch (props.currentView.name) {
case 'createVault': case 'createVault':
return h(CreateVaultScreen, {key: 'createVault'}) return h(CreateVaultScreen, {key: 'createVault'})
@ -242,12 +247,12 @@ App.prototype.renderPrimary = function(state){
} }
// show unlock screen // show unlock screen
if (!state.isUnlocked) { if (!props.isUnlocked) {
return h(UnlockScreen, {key: 'locked'}) return h(UnlockScreen, {key: 'locked'})
} }
// show current view // show current view
switch (state.currentView.name) { switch (props.currentView.name) {
case 'accounts': case 'accounts':
return h(AccountsScreen, {key: 'accounts'}) return h(AccountsScreen, {key: 'accounts'})

View File

@ -19,7 +19,7 @@ DropMenuItem.prototype.render = function() {
}, },
style: { style: {
listStyle: 'none', listStyle: 'none',
padding: '6px 10px 6px 17px', padding: '6px 16px 6px 5px',
fontFamily: 'Transat Medium', fontFamily: 'Transat Medium',
color: 'rgb(125, 128, 130)', color: 'rgb(125, 128, 130)',
cursor: 'pointer', cursor: 'pointer',