summaryrefslogtreecommitdiff
path: root/app/client/common/textInput.component.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/client/common/textInput.component.js')
-rw-r--r--app/client/common/textInput.component.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/client/common/textInput.component.js b/app/client/common/textInput.component.js
new file mode 100644
index 0000000..b3c4866
--- /dev/null
+++ b/app/client/common/textInput.component.js
@@ -0,0 +1,34 @@
+import { h, Component } from 'preact'
+
+class TextInput extends Component {
+ constructor(props){
+ super(props)
+ this.handleInput = this.handleInput.bind(this)
+ this.handleKeydown = this.handleKeydown.bind(this)
+ }
+ handleInput(e){
+ this.props.onInput && this.props.onInput(e.target.value)
+ }
+ handleKeydown(e){
+ if (e.keyCode === 13) {
+ this.props.onSave && this.props.onSave(e.target.value)
+ }
+ }
+ render() {
+ return (
+ <div className='textInput param'>
+ <label>
+ <span>{this.props.title}</span>
+ <input
+ type='text'
+ value={this.props.value}
+ onInput={this.handleInput}
+ onKeydown={this.handleKeydown}
+ />
+ </label>
+ </div>
+ )
+ }
+}
+
+export default TextInput