2016-09-09 17:36:09 +02:00
|
|
|
import React from 'react'
|
|
|
|
import theme from './theme.js'
|
2016-09-15 09:13:23 +02:00
|
|
|
|
|
|
|
import Heading from 'rebass/dist/Heading'
|
|
|
|
import Container from 'rebass/dist/Container'
|
|
|
|
import Input from 'rebass/dist/Input'
|
|
|
|
import Toolbar from 'rebass/dist/Toolbar'
|
|
|
|
import NavItem from 'rebass/dist/NavItem'
|
|
|
|
import Space from 'rebass/dist/Space'
|
|
|
|
|
2016-09-10 14:17:49 +02:00
|
|
|
import Immutable from 'immutable'
|
2016-09-10 21:35:21 +02:00
|
|
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
2016-09-09 17:36:09 +02:00
|
|
|
|
|
|
|
/** Edit global settings within a style such as the name */
|
|
|
|
export class SettingsEditor extends React.Component {
|
|
|
|
static propTypes = {
|
2016-09-10 15:15:17 +02:00
|
|
|
mapStyle: React.PropTypes.instanceOf(Immutable.Map).isRequired,
|
2016-09-10 16:26:39 +02:00
|
|
|
onStyleChanged: React.PropTypes.func.isRequired,
|
|
|
|
accessToken: React.PropTypes.string,
|
|
|
|
onAccessTokenChanged: React.PropTypes.func
|
2016-09-10 15:15:17 +02:00
|
|
|
}
|
2016-09-09 17:36:09 +02:00
|
|
|
|
2016-09-10 21:35:21 +02:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this);
|
|
|
|
}
|
|
|
|
|
2016-09-09 17:36:09 +02:00
|
|
|
onChange(property, e) {
|
2016-09-10 14:17:49 +02:00
|
|
|
const changedStyle = this.props.mapStyle.set(property, e.target.value)
|
|
|
|
this.props.onStyleChanged(changedStyle)
|
2016-09-09 17:36:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return <div>
|
|
|
|
<Toolbar style={{marginRight: 20}}>
|
|
|
|
<NavItem>
|
2016-09-09 18:53:57 +02:00
|
|
|
<Heading>Settings</Heading>
|
2016-09-09 17:36:09 +02:00
|
|
|
</NavItem>
|
|
|
|
</Toolbar>
|
|
|
|
<Container>
|
2016-09-10 16:26:39 +02:00
|
|
|
<Input
|
|
|
|
name="access-token"
|
|
|
|
label="Mapbox GL access token"
|
|
|
|
value={this.props.accessToken}
|
|
|
|
onChange={e => this.props.onAccessTokenChanged(e.target.value)}
|
|
|
|
/>
|
2016-09-09 17:36:09 +02:00
|
|
|
<Input
|
|
|
|
name="name"
|
|
|
|
label="Name"
|
2016-09-10 14:17:49 +02:00
|
|
|
value={this.props.mapStyle.get('name')}
|
2016-09-09 17:36:09 +02:00
|
|
|
onChange={this.onChange.bind(this, "name")}
|
|
|
|
/>
|
|
|
|
<Input
|
|
|
|
name="owner"
|
|
|
|
label="Owner"
|
2016-09-10 14:17:49 +02:00
|
|
|
value={this.props.mapStyle.get('owner')}
|
2016-09-09 17:36:09 +02:00
|
|
|
onChange={this.onChange.bind(this, "owner")}
|
|
|
|
/>
|
|
|
|
<Input
|
|
|
|
name="sprite"
|
|
|
|
label="Sprite URL"
|
2016-09-10 14:17:49 +02:00
|
|
|
value={this.props.mapStyle.get('sprite')}
|
2016-09-09 17:36:09 +02:00
|
|
|
onChange={this.onChange.bind(this, "sprite")}
|
|
|
|
/>
|
|
|
|
<Input
|
|
|
|
name="glyphs"
|
|
|
|
label="Glyphs URL"
|
2016-09-10 14:17:49 +02:00
|
|
|
value={this.props.mapStyle.get('glyphs')}
|
2016-09-09 17:36:09 +02:00
|
|
|
onChange={this.onChange.bind(this, "glyphs")}
|
|
|
|
/>
|
|
|
|
</Container>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
}
|