mirror of
https://github.com/maputnik/editor.git
synced 2026-08-24 05:57:25 +00:00
Use min and max from spec in number field
This commit is contained in:
@@ -25,12 +25,20 @@ class NumberField extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
let stepSize = null
|
||||||
|
if(this.props.max && this.props.min) {
|
||||||
|
stepSize = (this.props.max - this.props.min) / 10
|
||||||
|
}
|
||||||
|
|
||||||
return <input
|
return <input
|
||||||
style={{
|
style={{
|
||||||
...input.input,
|
...input.input,
|
||||||
...this.props.style
|
...this.props.style
|
||||||
}}
|
}}
|
||||||
type="number"
|
type="number"
|
||||||
|
min={this.props.min}
|
||||||
|
max={this.props.max}
|
||||||
|
step={stepSize}
|
||||||
name={this.props.name}
|
name={this.props.name}
|
||||||
placeholder={this.props.default}
|
placeholder={this.props.default}
|
||||||
value={this.props.value}
|
value={this.props.value}
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ export default class SpecField extends React.Component {
|
|||||||
<NumberField
|
<NumberField
|
||||||
{...commonProps}
|
{...commonProps}
|
||||||
default={this.props.fieldSpec.default}
|
default={this.props.fieldSpec.default}
|
||||||
min={this.props.fieldSpec.min}
|
min={this.props.fieldSpec.minimum}
|
||||||
max={this.props.fieldSpec.max}
|
max={this.props.fieldSpec.maximum}
|
||||||
unit={this.props.fieldSpec.unit}
|
unit={this.props.fieldSpec.unit}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user