mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-29 08:40:27 +01:00
Improve grouping
This commit is contained in:
parent
fed530f5f2
commit
b72f86a78d
4 changed files with 33 additions and 101 deletions
|
@ -25,6 +25,22 @@ class UnsupportedLayer extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function layoutGroups(layerType) {
|
||||||
|
const layerGroup = {
|
||||||
|
title: 'Layer',
|
||||||
|
type: 'layer'
|
||||||
|
}
|
||||||
|
const filterGroup = {
|
||||||
|
title: 'Filter',
|
||||||
|
type: 'filter'
|
||||||
|
}
|
||||||
|
const editorGroup = {
|
||||||
|
title: 'JSON Editor',
|
||||||
|
type: 'jsoneditor'
|
||||||
|
}
|
||||||
|
return [layerGroup, filterGroup].concat(layout[layerType].groups).concat([editorGroup])
|
||||||
|
}
|
||||||
|
|
||||||
/** Layer editor supporting multiple types of layers. */
|
/** Layer editor supporting multiple types of layers. */
|
||||||
export default class LayerEditor extends React.Component {
|
export default class LayerEditor extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
@ -50,7 +66,7 @@ export default class LayerEditor extends React.Component {
|
||||||
|
|
||||||
//TODO: Clean this up and refactor into function
|
//TODO: Clean this up and refactor into function
|
||||||
const editorGroups = {}
|
const editorGroups = {}
|
||||||
layout[this.props.layer.type].groups.forEach(group => {
|
layoutGroups(this.props.layer.type).forEach(group => {
|
||||||
editorGroups[group.title] = true
|
editorGroups[group.title] = true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -96,17 +112,15 @@ export default class LayerEditor extends React.Component {
|
||||||
|
|
||||||
renderGroupType(type, fields) {
|
renderGroupType(type, fields) {
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case 'settings': return <div>
|
case 'layer': return <div>
|
||||||
<LayerIdBlock
|
<LayerIdBlock
|
||||||
value={this.props.layer.id}
|
value={this.props.layer.id}
|
||||||
onChange={newId => this.props.onLayerIdChange(this.props.layer.id, newId)}
|
onChange={newId => this.props.onLayerIdChange(this.props.layer.id, newId)}
|
||||||
/>
|
/>
|
||||||
<LayerTypeBlock
|
<LayerTypeBlock
|
||||||
value={this.props.layer.type}
|
value={this.props.layer.type}
|
||||||
onChange={newType => this.props.onLayerChanged(changeType(this.props.layer, newType))}
|
onChange={newType => this.props.onLayerChanged(changeType(this.props.layer, newType))}
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
case 'source': return <div>
|
|
||||||
<LayerSourceBlock
|
<LayerSourceBlock
|
||||||
sourceIds={Object.keys(this.props.sources)}
|
sourceIds={Object.keys(this.props.sources)}
|
||||||
value={this.props.layer.source}
|
value={this.props.layer.source}
|
||||||
|
@ -118,6 +132,8 @@ export default class LayerEditor extends React.Component {
|
||||||
onChange={v => this.changeProperty(null, 'source-layer', v)}
|
onChange={v => this.changeProperty(null, 'source-layer', v)}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
</div>
|
||||||
|
case 'filter': return <div>
|
||||||
<div style={input.property}>
|
<div style={input.property}>
|
||||||
<FilterEditor
|
<FilterEditor
|
||||||
filter={this.props.layer.filter}
|
filter={this.props.layer.filter}
|
||||||
|
@ -141,8 +157,8 @@ export default class LayerEditor extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const layerType = this.props.layer.type
|
const layerType = this.props.layer.type
|
||||||
const layoutGroups = layout[layerType].groups.filter(group => {
|
const groups = layoutGroups(layerType).filter(group => {
|
||||||
return !(this.props.layer.type === 'background' && group.type === 'source')
|
return !(layerType === 'background' && group.type === 'source')
|
||||||
}).map(group => {
|
}).map(group => {
|
||||||
return <LayerEditorGroup
|
return <LayerEditorGroup
|
||||||
key={group.title}
|
key={group.title}
|
||||||
|
@ -155,7 +171,7 @@ export default class LayerEditor extends React.Component {
|
||||||
})
|
})
|
||||||
|
|
||||||
return <div>
|
return <div>
|
||||||
{layoutGroups}
|
{groups}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ class LayerIdBlock extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <InputBlock label={"Layer ID"} doc={GlSpec.layer.id.doc}>
|
return <InputBlock label={"ID"} doc={GlSpec.layer.id.doc}>
|
||||||
<StringInput
|
<StringInput
|
||||||
value={this.props.value}
|
value={this.props.value}
|
||||||
onChange={this.props.onChange}
|
onChange={this.props.onChange}
|
||||||
|
|
|
@ -11,7 +11,7 @@ class LayerTypeBlock extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <InputBlock label={"Layer Type"} doc={GlSpec.layer.type.doc}>
|
return <InputBlock label={"Type"} doc={GlSpec.layer.type.doc}>
|
||||||
<SelectInput
|
<SelectInput
|
||||||
options={[
|
options={[
|
||||||
['background', 'Background'],
|
['background', 'Background'],
|
||||||
|
|
|
@ -1,14 +1,6 @@
|
||||||
{
|
{
|
||||||
"line": {
|
"line": {
|
||||||
"groups": [
|
"groups": [
|
||||||
{
|
|
||||||
"title": "Settings",
|
|
||||||
"type": "settings"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Source",
|
|
||||||
"type": "source"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"title": "Paint",
|
"title": "Paint",
|
||||||
"type": "properties",
|
"type": "properties",
|
||||||
|
@ -34,23 +26,11 @@
|
||||||
"line-dasharray",
|
"line-dasharray",
|
||||||
"line-gap-width"
|
"line-gap-width"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "JSON",
|
|
||||||
"type": "jsoneditor"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"background": {
|
"background": {
|
||||||
"groups": [
|
"groups": [
|
||||||
{
|
|
||||||
"title": "Settings",
|
|
||||||
"type": "settings"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Source",
|
|
||||||
"type": "source"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"title": "Basic",
|
"title": "Basic",
|
||||||
"type": "properties",
|
"type": "properties",
|
||||||
|
@ -59,23 +39,11 @@
|
||||||
"background-pattern",
|
"background-pattern",
|
||||||
"background-opacity"
|
"background-opacity"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "JSON",
|
|
||||||
"type": "jsoneditor"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"fill": {
|
"fill": {
|
||||||
"groups": [
|
"groups": [
|
||||||
{
|
|
||||||
"title": "Settings",
|
|
||||||
"type": "settings"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Source",
|
|
||||||
"type": "source"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"title": "Basic",
|
"title": "Basic",
|
||||||
"type": "properties",
|
"type": "properties",
|
||||||
|
@ -88,23 +56,11 @@
|
||||||
"fill-translate",
|
"fill-translate",
|
||||||
"fill-translate-anchor"
|
"fill-translate-anchor"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "JSON",
|
|
||||||
"type": "jsoneditor"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"fill-extrusion": {
|
"fill-extrusion": {
|
||||||
"groups": [
|
"groups": [
|
||||||
{
|
|
||||||
"title": "Settings",
|
|
||||||
"type": "settings"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Source",
|
|
||||||
"type": "source"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"title": "Basic",
|
"title": "Basic",
|
||||||
"type": "properties",
|
"type": "properties",
|
||||||
|
@ -117,23 +73,11 @@
|
||||||
"fill-extrusion-height",
|
"fill-extrusion-height",
|
||||||
"fill-extrusion-base"
|
"fill-extrusion-base"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "JSON",
|
|
||||||
"type": "jsoneditor"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"circle": {
|
"circle": {
|
||||||
"groups": [
|
"groups": [
|
||||||
{
|
|
||||||
"title": "Settings",
|
|
||||||
"type": "settings"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Source",
|
|
||||||
"type": "source"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"title": "Basic",
|
"title": "Basic",
|
||||||
"type": "properties",
|
"type": "properties",
|
||||||
|
@ -161,23 +105,11 @@
|
||||||
"circle-translate",
|
"circle-translate",
|
||||||
"circle-translate-anchor"
|
"circle-translate-anchor"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "JSON",
|
|
||||||
"type": "jsoneditor"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"symbol": {
|
"symbol": {
|
||||||
"groups": [
|
"groups": [
|
||||||
{
|
|
||||||
"title": "Settings",
|
|
||||||
"type": "settings"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Source",
|
|
||||||
"type": "source"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"title": "Basic",
|
"title": "Basic",
|
||||||
"type": "properties",
|
"type": "properties",
|
||||||
|
@ -241,23 +173,11 @@
|
||||||
"icon-keep-upright",
|
"icon-keep-upright",
|
||||||
"icon-offset"
|
"icon-offset"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "JSON",
|
|
||||||
"type": "jsoneditor"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"raster": {
|
"raster": {
|
||||||
"groups": [
|
"groups": [
|
||||||
{
|
|
||||||
"title": "Settings",
|
|
||||||
"type": "settings"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Source",
|
|
||||||
"type": "source"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"title": "Basic",
|
"title": "Basic",
|
||||||
"type": "properties",
|
"type": "properties",
|
||||||
|
@ -270,10 +190,6 @@
|
||||||
"raster-contrast",
|
"raster-contrast",
|
||||||
"raster-fade-duration"
|
"raster-fade-duration"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "JSON",
|
|
||||||
"type": "jsoneditor"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue