mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-29 05:50:30 +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() {
|
||||
return <input
|
||||
spellCheck="false"
|
||||
className="maputnik-number"
|
||||
placeholder={this.props.default}
|
||||
value={this.state.value}
|
||||
onChange={e => this.changeValue(e.target.value)}
|
||||
onBlur={this.resetValue}
|
||||
/>
|
||||
let rangeEl;
|
||||
|
||||
if(
|
||||
this.props.hasOwnProperty("min") && this.props.hasOwnProperty("max") &&
|
||||
this.props.min !== undefined && this.props.max !== undefined &&
|
||||
this.props.allowRange
|
||||
) {
|
||||
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"
|
||||
>
|
||||
<NumberInput
|
||||
allowRange={true}
|
||||
value={this.props.value}
|
||||
onChange={this.props.onChange}
|
||||
min={latest.layer.maxzoom.minimum}
|
||||
|
|
|
@ -16,6 +16,7 @@ class MinZoomBlock extends React.Component {
|
|||
data-wd-key="min-zoom"
|
||||
>
|
||||
<NumberInput
|
||||
allowRange={true}
|
||||
value={this.props.value}
|
||||
onChange={this.props.onChange}
|
||||
min={latest.layer.minzoom.minimum}
|
||||
|
|
Loading…
Reference in a new issue