Add layout JSON defined property groups

This commit is contained in:
Lukas Martinelli
2016-12-19 20:15:30 +01:00
parent f9f7be1cad
commit 965b2d6e05
4 changed files with 189 additions and 80 deletions
+1 -28
View File
@@ -24,7 +24,7 @@ const specFieldProps = {
/** Supports displaying spec field for zoom function objects
* https://www.mapbox.com/mapbox-gl-style-spec/#types-function-zoom-property
*/
class ZoomSpecField extends React.Component {
export class ZoomSpecField extends React.Component {
static propTypes = {
...specFieldProps,
value: React.PropTypes.oneOfType([
@@ -167,30 +167,3 @@ class SpecField extends React.Component {
}
}
}
export class PropertyGroup extends React.Component {
static propTypes = {
onChange: React.PropTypes.func.isRequired,
properties: React.PropTypes.instanceOf(Immutable.Map).isRequired,
layerType: React.PropTypes.oneOf(['fill', 'background', 'line', 'symbol']).isRequired,
groupType: React.PropTypes.oneOf(['paint', 'layout']).isRequired,
}
render() {
const layerTypeSpec = GlSpec[this.props.groupType + "_" + this.props.layerType]
const specFields = Object.keys(layerTypeSpec).filter(propName => propName !== 'visibility').map(propName => {
const fieldSpec = layerTypeSpec[propName]
const propValue = this.props.properties.get(propName)
return <ZoomSpecField
onChange={this.props.onChange}
key={propName}
value={propValue}
fieldName={propName}
fieldSpec={fieldSpec}
/>
})
return <div>
{specFields}
</div>
}
}