2016-09-09 17:36:09 +02:00
|
|
|
import React from 'react'
|
|
|
|
import theme from './theme.js'
|
2016-09-09 18:53:57 +02:00
|
|
|
import { Heading, Container, Input, Toolbar, NavItem, Space } from 'rebass'
|
2016-09-10 14:17:49 +02:00
|
|
|
import Immutable from 'immutable'
|
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
|
|
|
|
|
|
|
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>
|
|
|
|
}
|
|
|
|
}
|