mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-29 08:20:28 +01:00
Move change property logic to lib
This commit is contained in:
parent
7b631b0510
commit
bda7ce7390
2 changed files with 23 additions and 27 deletions
|
@ -13,7 +13,7 @@ import LayerSourceLayerBlock from './LayerSourceLayerBlock'
|
||||||
import InputBlock from '../inputs/InputBlock'
|
import InputBlock from '../inputs/InputBlock'
|
||||||
import MultiButtonInput from '../inputs/MultiButtonInput'
|
import MultiButtonInput from '../inputs/MultiButtonInput'
|
||||||
|
|
||||||
import { changeType } from '../../libs/layer'
|
import { changeType, changeProperty } from '../../libs/layer'
|
||||||
import layout from '../../config/layout.json'
|
import layout from '../../config/layout.json'
|
||||||
import { margins, fontSizes } from '../../config/scales'
|
import { margins, fontSizes } from '../../config/scales'
|
||||||
import colors from '../../config/colors'
|
import colors from '../../config/colors'
|
||||||
|
@ -79,32 +79,8 @@ export default class LayerEditor extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A {@property} in either the paint our layout {@group} has changed
|
|
||||||
* to a {@newValue}.
|
|
||||||
*/
|
|
||||||
changeProperty(group, property, newValue) {
|
changeProperty(group, property, newValue) {
|
||||||
if(group) {
|
this.props.onLayerChanged(changeProperty(this.props.layer, group, property, newValue))
|
||||||
this.props.onLayerChanged({
|
|
||||||
...this.props.layer,
|
|
||||||
[group]: {
|
|
||||||
...this.props.layer[group],
|
|
||||||
[property]: newValue
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
this.props.onLayerChanged({
|
|
||||||
...this.props.layer,
|
|
||||||
[property]: newValue
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onFilterChange(newValue) {
|
|
||||||
const changedLayer = {
|
|
||||||
...this.props.layer,
|
|
||||||
filter: newValue
|
|
||||||
}
|
|
||||||
this.props.onLayerChanged(changedLayer)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onGroupToggle(groupTitle, active) {
|
onGroupToggle(groupTitle, active) {
|
||||||
|
@ -134,7 +110,7 @@ export default class LayerEditor extends React.Component {
|
||||||
<FilterEditor
|
<FilterEditor
|
||||||
filter={this.props.layer.filter}
|
filter={this.props.layer.filter}
|
||||||
properties={this.props.vectorLayers[this.props.layer['source-layer']]}
|
properties={this.props.vectorLayers[this.props.layer['source-layer']]}
|
||||||
onChange={f => this.onFilterChange(f)}
|
onChange={f => this.changeProperty(null, 'filter', f)}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
<LayerSourceBlock
|
<LayerSourceBlock
|
||||||
|
|
|
@ -22,3 +22,23 @@ export function changeType(layer, newType) {
|
||||||
type: newType,
|
type: newType,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A {@property} in either the paint our layout {@group} has changed
|
||||||
|
* to a {@newValue}.
|
||||||
|
*/
|
||||||
|
export function changeProperty(layer, group, property, newValue) {
|
||||||
|
if(group) {
|
||||||
|
return {
|
||||||
|
...layer,
|
||||||
|
[group]: {
|
||||||
|
...layer[group],
|
||||||
|
[property]: newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
...layer,
|
||||||
|
[property]: newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue