maputnik/src/components/modals/SettingsModal.jsx

80 lines
2.2 KiB
React
Raw Normal View History

2016-12-16 16:52:16 +01:00
import React from 'react'
import InputBlock from '../inputs/InputBlock'
import StringInput from '../inputs/StringInput'
import SelectInput from '../inputs/SelectInput'
import Modal from './Modal'
import colors from '../../config/colors'
2016-12-16 16:52:16 +01:00
class SettingsModal extends React.Component {
static propTypes = {
2016-12-20 16:08:49 +01:00
mapStyle: React.PropTypes.object.isRequired,
2016-12-16 16:52:16 +01:00
onStyleChanged: React.PropTypes.func.isRequired,
2016-12-21 16:11:08 +01:00
isOpen: React.PropTypes.bool.isRequired,
2016-12-22 16:35:31 +01:00
onOpenToggle: React.PropTypes.func.isRequired,
2016-12-16 16:52:16 +01:00
}
constructor(props) {
super(props);
}
onChange(property, e) {
const changedStyle = this.props.mapStyle.set(property, e.target.value)
this.props.onStyleChanged(changedStyle)
}
onRendererChange(e) {
const changedStyle = this.props.mapStyle.setIn(['metadata', 'maputnik:renderer'], e.target.value)
this.props.onStyleChanged(changedStyle)
}
2016-12-16 16:52:16 +01:00
render() {
2016-12-21 16:50:34 +01:00
const inputProps = { }
return <Modal
2016-12-21 16:11:08 +01:00
isOpen={this.props.isOpen}
2016-12-22 16:35:31 +01:00
onOpenToggle={this.props.onOpenToggle}
title={'StyleSettings'}
>
<InputBlock label={"Name"}>
<StringInput {...inputProps}
2016-12-20 16:08:49 +01:00
value={this.props.mapStyle.name}
2016-12-16 16:52:16 +01:00
onChange={this.onChange.bind(this, "name")}
/>
</InputBlock>
<InputBlock label={"Owner"}>
<StringInput {...inputProps}
2016-12-20 16:08:49 +01:00
value={this.props.mapStyle.owner}
2016-12-16 16:52:16 +01:00
onChange={this.onChange.bind(this, "owner")}
/>
</InputBlock>
<InputBlock label={"Sprite URL"}>
<StringInput {...inputProps}
2016-12-20 16:08:49 +01:00
value={this.props.mapStyle.sprite}
2016-12-16 16:52:16 +01:00
onChange={this.onChange.bind(this, "sprite")}
/>
</InputBlock>
<InputBlock label={"Glyphs URL"}>
<StringInput {...inputProps}
2016-12-20 16:08:49 +01:00
value={this.props.mapStyle.glyphs}
onChange={this.onChange.bind(this, "glyphs")}
/>
</InputBlock>
<InputBlock label={"Style Renderer"}>
<SelectInput {...inputProps}
options={[
['mbgljs', 'MapboxGL JS'],
['ol3', 'Open Layers 3']
]}
2016-12-22 16:54:13 +01:00
value={(this.props.mapStyle.metadata || {})['maputnik:renderer'] || 'mbgljs'}
onChange={this.onRendererChange.bind(this)}
/>
</InputBlock>
</Modal>
2016-12-16 16:52:16 +01:00
}
}
export default SettingsModal