improve boolean prop for slider

main
Mike Fix 6 years ago committed by Michael Fix
parent fd27b509cd
commit aa52817a39

@ -95,7 +95,8 @@ const WindowSettings = React.memo(
border-right: 1px solid ${COLORS.SECONDARY}; border-right: 1px solid ${COLORS.SECONDARY};
} }
.drop-shadow-options { .drop-shadow-options :global(.slider-bg),
.drop-shadow-options :global(label) {
opacity: 0.5; opacity: 0.5;
} }
`} `}
@ -129,7 +130,7 @@ const TypeSettings = React.memo(
value={lineHeight} value={lineHeight}
minValue={90} minValue={90}
maxValue={250} maxValue={250}
usePercentage={true} unit="%"
onChange={onChange.bind(null, 'lineHeight')} onChange={onChange.bind(null, 'lineHeight')}
/> />
</div> </div>

@ -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 {

Loading…
Cancel
Save