From 25815ab4916dc8c9e3256cbfe53bea0535930f30 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 4 Sep 2018 13:53:30 +0200 Subject: fix loading bars --- app/client/common/numberInput.component.js | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 app/client/common/numberInput.component.js (limited to 'app/client/common/numberInput.component.js') diff --git a/app/client/common/numberInput.component.js b/app/client/common/numberInput.component.js new file mode 100644 index 0000000..c3ad24c --- /dev/null +++ b/app/client/common/numberInput.component.js @@ -0,0 +1,49 @@ +import { h, Component } from 'preact' + +class NumberInput extends Component { + constructor(props){ + super(props) + this.state = { value: null, changed: false } + this.handleInput = this.handleInput.bind(this) + this.handleKeydown = this.handleKeydown.bind(this) + } + handleInput(e){ + this.setState({ + value: e.target.value, + changed: true, + }) + this.props.onInput && this.props.onInput(e.target.value, e.target.name) + } + handleKeydown(e){ + if (e.keyCode === 13) { + this.setState({ + value: e.target.value, + changed: false, + }) + this.props.onSave && this.props.onSave(e.target.value, e.target.name) + } + } + render() { + return ( +
+ +
+ ) + } +} + +export default NumberInput -- cgit v1.2.3-70-g09d2