40 lines
1.0 KiB
JavaScript
40 lines
1.0 KiB
JavaScript
import React from 'react';
|
|
|
|
|
|
class Input extends React.Component {
|
|
|
|
read(e){
|
|
this.props.update(this.props.id, e.target.value)
|
|
}
|
|
|
|
render(){
|
|
switch (this.props.type) {
|
|
case 'submit':
|
|
return <input
|
|
key={this.props.key}
|
|
type="submit"
|
|
value={this.props.lable}
|
|
onClick={this.props.submit} />
|
|
case 'range':
|
|
let range = this.props.range.split(':')
|
|
return <input
|
|
key={this.props.key}
|
|
type="range"
|
|
min={range[0]}
|
|
max={range[1]}
|
|
step={range[2]}
|
|
onChange={this.read.bind(this)}
|
|
value={this.props.value} />
|
|
default:
|
|
return <input
|
|
key={this.props.key}
|
|
type={this.props.type}
|
|
placeholder={this.props.lable}
|
|
onChange={this.read.bind(this)}
|
|
value={this.props.value} />
|
|
}
|
|
}
|
|
}
|
|
|
|
export default Input;
|