mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-30 23:30:33 +01:00
Added range slider to <NumberInput />
This commit is contained in:
parent
3d2a1d5d19
commit
cdd5d27908
3 changed files with 38 additions and 8 deletions
|
@ -68,14 +68,42 @@ class NumberInput extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <input
|
let rangeEl;
|
||||||
spellCheck="false"
|
|
||||||
className="maputnik-number"
|
if(
|
||||||
placeholder={this.props.default}
|
this.props.hasOwnProperty("min") && this.props.hasOwnProperty("max") &&
|
||||||
value={this.state.value}
|
this.props.min !== undefined && this.props.max !== undefined &&
|
||||||
onChange={e => this.changeValue(e.target.value)}
|
this.props.allowRange
|
||||||
onBlur={this.resetValue}
|
) {
|
||||||
/>
|
rangeEl = (
|
||||||
|
<input
|
||||||
|
style={{width: "calc(100% - 4em)", flexShrink: "0"}}
|
||||||
|
key="range"
|
||||||
|
type="range"
|
||||||
|
step="0.01"
|
||||||
|
max={this.props.max}
|
||||||
|
min={this.props.min}
|
||||||
|
spellCheck="false"
|
||||||
|
className="maputnik-number"
|
||||||
|
value={this.state.value || this.props.default}
|
||||||
|
onChange={e => this.changeValue(e.target.value)}
|
||||||
|
onBlur={this.resetValue}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return <div style={{display: "flex"}}>
|
||||||
|
{rangeEl}
|
||||||
|
<input
|
||||||
|
key="text"
|
||||||
|
spellCheck="false"
|
||||||
|
className="maputnik-number"
|
||||||
|
placeholder={this.props.default}
|
||||||
|
value={this.state.value}
|
||||||
|
onChange={e => this.changeValue(e.target.value)}
|
||||||
|
onBlur={this.resetValue}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ class MaxZoomBlock extends React.Component {
|
||||||
data-wd-key="max-zoom"
|
data-wd-key="max-zoom"
|
||||||
>
|
>
|
||||||
<NumberInput
|
<NumberInput
|
||||||
|
allowRange={true}
|
||||||
value={this.props.value}
|
value={this.props.value}
|
||||||
onChange={this.props.onChange}
|
onChange={this.props.onChange}
|
||||||
min={latest.layer.maxzoom.minimum}
|
min={latest.layer.maxzoom.minimum}
|
||||||
|
|
|
@ -16,6 +16,7 @@ class MinZoomBlock extends React.Component {
|
||||||
data-wd-key="min-zoom"
|
data-wd-key="min-zoom"
|
||||||
>
|
>
|
||||||
<NumberInput
|
<NumberInput
|
||||||
|
allowRange={true}
|
||||||
value={this.props.value}
|
value={this.props.value}
|
||||||
onChange={this.props.onChange}
|
onChange={this.props.onChange}
|
||||||
min={latest.layer.minzoom.minimum}
|
min={latest.layer.minzoom.minimum}
|
||||||
|
|
Loading…
Reference in a new issue