Added Slider component for input range
• Added: - Slider component for input range
This commit is contained in:
46
app/javascript/gabsocial/components/slider.js
Normal file
46
app/javascript/gabsocial/components/slider.js
Normal file
@@ -0,0 +1,46 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
class Slider extends React.PureComponent {
|
||||
|
||||
handleOnInput = (e) => {
|
||||
this.props.onInput(e.target.value)
|
||||
}
|
||||
|
||||
handleOnChange = (e) => {
|
||||
this.props.onChange(e.target.value)
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
className,
|
||||
min,
|
||||
max,
|
||||
value,
|
||||
} = this.props
|
||||
|
||||
return (
|
||||
<input
|
||||
type='range'
|
||||
min={min}
|
||||
value={value}
|
||||
max={max}
|
||||
onInput={this.handleOnInput}
|
||||
onChange={this.handleOnChange}
|
||||
className={className}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Slider.propTypes = {
|
||||
className: PropTypes.string,
|
||||
min: PropTypes.number,
|
||||
max: PropTypes.number,
|
||||
onChange: PropTypes.func,
|
||||
onInput: PropTypes.func,
|
||||
value: PropTypes.number,
|
||||
}
|
||||
|
||||
export default Slider
|
||||
Reference in New Issue
Block a user