|
|
@ -5,11 +5,12 @@ import { COLORS } from '../lib/constants'
|
|
|
|
class Slider extends React.Component {
|
|
|
|
class Slider extends React.Component {
|
|
|
|
static defaultProps = {
|
|
|
|
static defaultProps = {
|
|
|
|
onMouseDown: () => {},
|
|
|
|
onMouseDown: () => {},
|
|
|
|
onMouseUp: () => {}
|
|
|
|
onMouseUp: () => {},
|
|
|
|
|
|
|
|
unit: 'px'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
handleChange = e => {
|
|
|
|
handleChange = e => {
|
|
|
|
this.props.onChange(`${e.target.value}${this.props.usePercentage ? '%' : 'px'}`)
|
|
|
|
this.props.onChange(`${e.target.value}${this.props.unit}`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
render() {
|
|
|
@ -27,7 +28,7 @@ class Slider extends React.Component {
|
|
|
|
100}%, 0px, 0px)`
|
|
|
|
100}%, 0px, 0px)`
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
<span className="label">{this.props.label}</span>
|
|
|
|
<label>{this.props.label}</label>
|
|
|
|
<input
|
|
|
|
<input
|
|
|
|
type="range"
|
|
|
|
type="range"
|
|
|
|
defaultValue={this.props.value}
|
|
|
|
defaultValue={this.props.value}
|
|
|
@ -47,23 +48,28 @@ class Slider extends React.Component {
|
|
|
|
user-select: none;
|
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.slider:focus-within {
|
|
|
|
|
|
|
|
outline: -webkit-focus-ring-color auto 5px;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.slider:last-of-type {
|
|
|
|
.slider:last-of-type {
|
|
|
|
border-bottom: 0;
|
|
|
|
border-bottom: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.label {
|
|
|
|
label {
|
|
|
|
position: absolute;
|
|
|
|
position: absolute;
|
|
|
|
left: 8px;
|
|
|
|
left: 8px;
|
|
|
|
height: 33px;
|
|
|
|
height: 33px;
|
|
|
|
line-height: 33px;
|
|
|
|
line-height: 33px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.slider input {
|
|
|
|
input {
|
|
|
|
opacity: 0;
|
|
|
|
opacity: 0;
|
|
|
|
cursor: ew-resize;
|
|
|
|
cursor: ew-resize;
|
|
|
|
position: relative;
|
|
|
|
position: relative;
|
|
|
|
height: 100%;
|
|
|
|
height: 100%;
|
|
|
|
width: 100%;
|
|
|
|
width: 100%;
|
|
|
|
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.slider-bg {
|
|
|
|
.slider-bg {
|
|
|
|