diff options
author | Luis Iván Cuende <me@luisivan.net> | 2016-12-15 01:38:20 +0800 |
---|---|---|
committer | Luis Iván Cuende <me@luisivan.net> | 2016-12-15 01:38:20 +0800 |
commit | c65db9290dd02b762c0260fe98945f63162f285d (patch) | |
tree | 9706362feb8fce2859364c56cf4592816f6fb2ca /ui/app/components | |
parent | b8ee336f0dd1c0a7d5990ddef22e2d17e09bb1b7 (diff) | |
download | tangerine-wallet-browser-c65db9290dd02b762c0260fe98945f63162f285d.tar tangerine-wallet-browser-c65db9290dd02b762c0260fe98945f63162f285d.tar.gz tangerine-wallet-browser-c65db9290dd02b762c0260fe98945f63162f285d.tar.bz2 tangerine-wallet-browser-c65db9290dd02b762c0260fe98945f63162f285d.tar.lz tangerine-wallet-browser-c65db9290dd02b762c0260fe98945f63162f285d.tar.xz tangerine-wallet-browser-c65db9290dd02b762c0260fe98945f63162f285d.tar.zst tangerine-wallet-browser-c65db9290dd02b762c0260fe98945f63162f285d.zip |
Better editable label
Diffstat (limited to 'ui/app/components')
-rw-r--r-- | ui/app/components/editable-label.js | 37 | ||||
-rw-r--r-- | ui/app/components/identicon.js | 2 |
2 files changed, 7 insertions, 32 deletions
diff --git a/ui/app/components/editable-label.js b/ui/app/components/editable-label.js index 41936f5e0..bc0f9a5b2 100644 --- a/ui/app/components/editable-label.js +++ b/ui/app/components/editable-label.js @@ -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 }) diff --git a/ui/app/components/identicon.js b/ui/app/components/identicon.js index 6d4871d02..8211867cb 100644 --- a/ui/app/components/identicon.js +++ b/ui/app/components/identicon.js @@ -12,7 +12,7 @@ inherits(IdenticonComponent, Component) function IdenticonComponent () { Component.call(this) - this.defaultDiameter = 46 + this.defaultDiameter = 32 } IdenticonComponent.prototype.render = function () { |