mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Better editable label
This commit is contained in:
parent
b8ee336f0d
commit
c65db9290d
@ -70,7 +70,7 @@ AccountDetailScreen.prototype.render = function () {
|
||||
// large identicon and addresses
|
||||
h('.identicon-wrapper.select-none', [
|
||||
h(Identicon, {
|
||||
diameter: 62,
|
||||
diameter: 48,
|
||||
address: selected,
|
||||
}),
|
||||
]),
|
||||
@ -82,16 +82,12 @@ AccountDetailScreen.prototype.render = function () {
|
||||
}, [
|
||||
h(EditableLabel, {
|
||||
textValue: identity ? identity.name : '',
|
||||
state: {
|
||||
isEditingLabel: false,
|
||||
},
|
||||
saveText: (text) => {
|
||||
props.dispatch(actions.saveAccountLabel(selected, text))
|
||||
},
|
||||
}, [
|
||||
|
||||
// What is shown when not editing + edit text:
|
||||
h('label.editing-label', [h('.edit-text', 'edit')]),
|
||||
h('h2.font-medium.color-forest', {name: 'edit'}, identity && identity.name),
|
||||
]),
|
||||
h('.flex-row', {
|
||||
|
@ -11,40 +11,15 @@ function EditableLabel () {
|
||||
}
|
||||
|
||||
EditableLabel.prototype.render = function () {
|
||||
const props = this.props
|
||||
const state = this.state
|
||||
|
||||
if (state && state.isEditingLabel) {
|
||||
return h('div.editable-label', [
|
||||
h('input.sizing-input', {
|
||||
defaultValue: props.textValue,
|
||||
maxLength: '20',
|
||||
onKeyPress: (event) => {
|
||||
this.saveIfEnter(event)
|
||||
},
|
||||
}),
|
||||
h('button.editable-button', {
|
||||
onClick: () => this.saveText(),
|
||||
}, 'Save'),
|
||||
])
|
||||
} else {
|
||||
return h('div.name-label', {
|
||||
onClick: (event) => {
|
||||
this.setState({ isEditingLabel: true })
|
||||
},
|
||||
}, this.props.children)
|
||||
}
|
||||
}
|
||||
|
||||
EditableLabel.prototype.saveIfEnter = function (event) {
|
||||
if (event.key === 'Enter') {
|
||||
this.saveText()
|
||||
}
|
||||
return h('div.name-label', {
|
||||
contentEditable: true,
|
||||
style: { outline: 'none' },
|
||||
onInput: (event) => this.saveText(),
|
||||
}, this.props.children)
|
||||
}
|
||||
|
||||
EditableLabel.prototype.saveText = function () {
|
||||
var container = findDOMNode(this)
|
||||
var text = container.querySelector('.editable-label input').value
|
||||
var text = findDOMNode(this).textContent.trim()
|
||||
var truncatedText = text.substring(0, 20)
|
||||
this.props.saveText(truncatedText)
|
||||
this.setState({ isEditingLabel: false, textLabel: truncatedText })
|
||||
|
@ -12,7 +12,7 @@ inherits(IdenticonComponent, Component)
|
||||
function IdenticonComponent () {
|
||||
Component.call(this)
|
||||
|
||||
this.defaultDiameter = 46
|
||||
this.defaultDiameter = 32
|
||||
}
|
||||
|
||||
IdenticonComponent.prototype.render = function () {
|
||||
|
@ -67,7 +67,7 @@ button.spaced {
|
||||
}
|
||||
|
||||
button:not([disabled]):hover {
|
||||
transform: scale(1.1);
|
||||
transform: scale(1.05);
|
||||
}
|
||||
button:not([disabled]):active {
|
||||
transform: scale(0.95);
|
||||
|
@ -63,7 +63,10 @@ UnlockScreen.prototype.render = function () {
|
||||
h('button.primary.cursor-pointer', {
|
||||
onClick: this.onSubmit.bind(this),
|
||||
style: {
|
||||
margin: 10,
|
||||
position: 'absolute',
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
width: '100%',
|
||||
},
|
||||
}, 'Unlock'),
|
||||
]),
|
||||
@ -72,11 +75,12 @@ UnlockScreen.prototype.render = function () {
|
||||
h('p.pointer', {
|
||||
onClick: () => this.props.dispatch(actions.goBackToInitView()),
|
||||
style: {
|
||||
marginTop: '1rem',
|
||||
fontSize: '0.8em',
|
||||
color: 'rgb(247, 134, 28)',
|
||||
textDecoration: 'underline',
|
||||
},
|
||||
}, 'I forgot my password.'),
|
||||
}, 'I forgot my password'),
|
||||
]),
|
||||
])
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user