mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-24 02:58:09 +01:00
30 lines
797 B
JavaScript
30 lines
797 B
JavaScript
const Component = require('react').Component
|
|
const h = require('react-hyperscript')
|
|
const inherits = require('util').inherits
|
|
const findDOMNode = require('react-dom').findDOMNode
|
|
|
|
module.exports = EditableLabel
|
|
|
|
inherits(EditableLabel, Component)
|
|
function EditableLabel () {
|
|
Component.call(this)
|
|
}
|
|
|
|
EditableLabel.prototype.render = function () {
|
|
return h('div.name-label', {
|
|
contentEditable: true,
|
|
style: {
|
|
outline: 'none',
|
|
marginTop: '0.5rem',
|
|
},
|
|
onInput: (event) => this.saveText(),
|
|
}, this.props.children)
|
|
}
|
|
|
|
EditableLabel.prototype.saveText = function () {
|
|
var text = findDOMNode(this).textContent.trim()
|
|
var truncatedText = text.substring(0, 20)
|
|
this.props.saveText(truncatedText)
|
|
this.setState({ isEditingLabel: false, textLabel: truncatedText })
|
|
}
|