Add string field

This commit is contained in:
lukasmartinelli 2016-09-12 19:54:02 +02:00
parent 4d1609a826
commit 885e31111c
3 changed files with 31 additions and 0 deletions

View file

@ -14,6 +14,7 @@ static propTypes = {
return <Input
label={this.props.name}
name={this.props.name}
value={this.props.value}
/>
}
}

View file

@ -4,6 +4,7 @@ import GlSpec from 'mapbox-gl-style-spec/reference/latest.min.js'
import NumberField from './number'
import EnumField from './enum'
import ColorField from './color'
import StringField from './string'
class SpecField extends React.Component {
static propTypes = {
@ -37,6 +38,13 @@ class SpecField extends React.Component {
doc={this.props.fieldSpec.doc}
/>
)
case 'string': return (
<StringField
value={this.props.value}
name={this.props.fieldName}
doc={this.props.fieldSpec.doc}
/>
)
case 'color': return (
<ColorField
value={this.props.value}

22
src/fields/string.jsx Normal file
View file

@ -0,0 +1,22 @@
import React from 'react'
import { Input } from 'rebass'
/*** Number fields with support for min, max and units and documentation*/
class StringField extends React.Component {
static propTypes = {
name: React.PropTypes.string.isRequired,
value: React.PropTypes.number,
default: React.PropTypes.number,
doc: React.PropTypes.string,
}
render() {
return <Input
label={this.props.name}
name={this.props.name}
value={this.props.value}
/>
}
}
export default StringField