mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 02:45:26 +01:00
Settings supports immutable map
This commit is contained in:
parent
d527f3cd1c
commit
ab79c632b0
1 changed files with 9 additions and 16 deletions
|
@ -1,25 +1,18 @@
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import theme from './theme.js'
|
import theme from './theme.js'
|
||||||
import { Heading, Container, Input, Toolbar, NavItem, Space } from 'rebass'
|
import { Heading, Container, Input, Toolbar, NavItem, Space } from 'rebass'
|
||||||
|
import Immutable from 'immutable'
|
||||||
|
|
||||||
/** Edit global settings within a style such as the name */
|
/** Edit global settings within a style such as the name */
|
||||||
export class SettingsEditor extends React.Component {
|
export class SettingsEditor extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
mapStyle: React.PropTypes.object.isRequired
|
mapStyle: React.PropTypes.instanceOf(Immutable.Map).isRequired,
|
||||||
}
|
onStyleChanged: React.PropTypes.func.isRequired
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props)
|
|
||||||
this.state = {
|
|
||||||
settings: this.props.styleManager.settings()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange(property, e) {
|
onChange(property, e) {
|
||||||
let settings = this.state.settings
|
const changedStyle = this.props.mapStyle.set(property, e.target.value)
|
||||||
settings[property] = e.target.value
|
this.props.onStyleChanged(changedStyle)
|
||||||
this.props.styleManager[property] = settings[property]
|
|
||||||
this.setState(settings)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -33,25 +26,25 @@ export class SettingsEditor extends React.Component {
|
||||||
<Input
|
<Input
|
||||||
name="name"
|
name="name"
|
||||||
label="Name"
|
label="Name"
|
||||||
value={this.state.settings.name}
|
value={this.props.mapStyle.get('name')}
|
||||||
onChange={this.onChange.bind(this, "name")}
|
onChange={this.onChange.bind(this, "name")}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
name="owner"
|
name="owner"
|
||||||
label="Owner"
|
label="Owner"
|
||||||
value={this.state.settings.owner}
|
value={this.props.mapStyle.get('owner')}
|
||||||
onChange={this.onChange.bind(this, "owner")}
|
onChange={this.onChange.bind(this, "owner")}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
name="sprite"
|
name="sprite"
|
||||||
label="Sprite URL"
|
label="Sprite URL"
|
||||||
value={this.state.settings.sprite}
|
value={this.props.mapStyle.get('sprite')}
|
||||||
onChange={this.onChange.bind(this, "sprite")}
|
onChange={this.onChange.bind(this, "sprite")}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
name="glyphs"
|
name="glyphs"
|
||||||
label="Glyphs URL"
|
label="Glyphs URL"
|
||||||
value={this.state.settings.glyphs}
|
value={this.props.mapStyle.get('glyphs')}
|
||||||
onChange={this.onChange.bind(this, "glyphs")}
|
onChange={this.onChange.bind(this, "glyphs")}
|
||||||
/>
|
/>
|
||||||
</Container>
|
</Container>
|
||||||
|
|
Loading…
Reference in a new issue