mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2025-01-14 17:43:29 +01:00
Tabs to spaces in input fields
This commit is contained in:
parent
8e92984d48
commit
95b2dad2a3
3 changed files with 61 additions and 61 deletions
|
@ -2,34 +2,34 @@ import React from 'react'
|
||||||
import inputStyle from './input.js'
|
import inputStyle from './input.js'
|
||||||
|
|
||||||
class EnumField extends React.Component {
|
class EnumField extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
onChange: React.PropTypes.func.isRequired,
|
onChange: React.PropTypes.func.isRequired,
|
||||||
name: React.PropTypes.string.isRequired,
|
name: React.PropTypes.string.isRequired,
|
||||||
value: React.PropTypes.string,
|
value: React.PropTypes.string,
|
||||||
allowedValues: React.PropTypes.array.isRequired,
|
allowedValues: React.PropTypes.array.isRequired,
|
||||||
doc: React.PropTypes.string,
|
doc: React.PropTypes.string,
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange(e) {
|
onChange(e) {
|
||||||
return this.props.onChange(e.target.value)
|
return this.props.onChange(e.target.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const options = this.props.allowedValues.map(val => {
|
const options = this.props.allowedValues.map(val => {
|
||||||
return <option key={val} value={val}>{val}</option>
|
return <option key={val} value={val}>{val}</option>
|
||||||
})
|
})
|
||||||
|
|
||||||
return <div style={inputStyle.property}>
|
return <div style={inputStyle.property}>
|
||||||
<label style={inputStyle.label}>{this.props.name}</label>
|
<label style={inputStyle.label}>{this.props.name}</label>
|
||||||
<select
|
<select
|
||||||
style={inputStyle.select}
|
style={inputStyle.select}
|
||||||
value={this.props.value}
|
value={this.props.value}
|
||||||
onChange={this.onChange.bind(this)}
|
onChange={this.onChange.bind(this)}
|
||||||
>
|
>
|
||||||
{options}
|
{options}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default EnumField
|
export default EnumField
|
||||||
|
|
|
@ -3,9 +3,9 @@ import inputStyle from './input.js'
|
||||||
|
|
||||||
/*** Number fields with support for min, max and units and documentation*/
|
/*** Number fields with support for min, max and units and documentation*/
|
||||||
class NumberField extends React.Component {
|
class NumberField extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
onChange: React.PropTypes.func.isRequired,
|
onChange: React.PropTypes.func.isRequired,
|
||||||
name: React.PropTypes.string.isRequired,
|
name: React.PropTypes.string.isRequired,
|
||||||
value: React.PropTypes.number,
|
value: React.PropTypes.number,
|
||||||
default: React.PropTypes.number,
|
default: React.PropTypes.number,
|
||||||
unit: React.PropTypes.string,
|
unit: React.PropTypes.string,
|
||||||
|
@ -14,28 +14,28 @@ class NumberField extends React.Component {
|
||||||
doc: React.PropTypes.string,
|
doc: React.PropTypes.string,
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange(e) {
|
onChange(e) {
|
||||||
const value = parseFloat(e.target.value)
|
const value = parseFloat(e.target.value)
|
||||||
/*TODO: we can do range validation already here?
|
/*TODO: we can do range validation already here?
|
||||||
if(this.props.min && value < this.props.min) return
|
if(this.props.min && value < this.props.min) return
|
||||||
if(this.props.max && value > this.props.max) return
|
if(this.props.max && value > this.props.max) return
|
||||||
*/
|
*/
|
||||||
this.props.onChange(value)
|
this.props.onChange(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <div style={inputStyle.property}>
|
return <div style={inputStyle.property}>
|
||||||
<label style={inputStyle.label}>{this.props.name}</label>
|
<label style={inputStyle.label}>{this.props.name}</label>
|
||||||
<input
|
<input
|
||||||
style={inputStyle.input}
|
style={inputStyle.input}
|
||||||
type="number"
|
type="number"
|
||||||
name={this.props.name}
|
name={this.props.name}
|
||||||
placeholder={this.props.default}
|
placeholder={this.props.default}
|
||||||
value={this.props.value}
|
value={this.props.value}
|
||||||
onChange={this.onChange.bind(this)}
|
onChange={this.onChange.bind(this)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default NumberField
|
export default NumberField
|
||||||
|
|
|
@ -3,31 +3,31 @@ import inputStyle from './input.js'
|
||||||
|
|
||||||
/*** Number fields with support for min, max and units and documentation*/
|
/*** Number fields with support for min, max and units and documentation*/
|
||||||
class StringField extends React.Component {
|
class StringField extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
onChange: React.PropTypes.func.isRequired,
|
onChange: React.PropTypes.func.isRequired,
|
||||||
name: React.PropTypes.string.isRequired,
|
name: React.PropTypes.string.isRequired,
|
||||||
value: React.PropTypes.string,
|
value: React.PropTypes.string,
|
||||||
default: React.PropTypes.number,
|
default: React.PropTypes.number,
|
||||||
doc: React.PropTypes.string,
|
doc: React.PropTypes.string,
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange(e) {
|
onChange(e) {
|
||||||
const value = e.target.value
|
const value = e.target.value
|
||||||
return this.props.onChange(value === "" ? null: value)
|
return this.props.onChange(value === "" ? null: value)
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <div style={inputStyle.property}>
|
return <div style={inputStyle.property}>
|
||||||
<label style={inputStyle.label}>{this.props.name}</label>
|
<label style={inputStyle.label}>{this.props.name}</label>
|
||||||
<input
|
<input
|
||||||
style={inputStyle.input}
|
style={inputStyle.input}
|
||||||
name={this.props.name}
|
name={this.props.name}
|
||||||
placeholder={this.props.default}
|
placeholder={this.props.default}
|
||||||
value={this.props.value ? this.props.value : ""}
|
value={this.props.value ? this.props.value : ""}
|
||||||
onChange={this.onChange.bind(this)}
|
onChange={this.onChange.bind(this)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default StringField
|
export default StringField
|
||||||
|
|
Loading…
Reference in a new issue