maputnik/src/workspace.jsx

51 lines
1.3 KiB
React
Raw Normal View History

2016-09-09 17:09:13 +02:00
import React from 'react'
2016-09-10 14:10:25 +02:00
import { LayerList } from './layers/list.jsx'
2016-09-09 18:53:57 +02:00
import { SettingsEditor } from './settings.jsx'
2016-09-09 17:09:13 +02:00
import theme from './theme.js'
2016-09-09 23:25:06 +02:00
/** The workspace drawer contains the editor components depending on the edit
* context chosen in the toolbar. It holds the state of the layers.*/
2016-09-09 17:09:13 +02:00
export class WorkspaceDrawer extends React.Component {
static propTypes = {
2016-09-09 23:25:06 +02:00
mapStyle: React.PropTypes.object.isRequired,
onStyleChanged: React.PropTypes.func.isRequired,
2016-09-09 17:09:13 +02:00
workContext: React.PropTypes.oneOf(['layers', 'settings']).isRequired,
}
onLayersChanged(changedLayers) {
const changedStyle = this.props.mapStyle.set('layers', changedLayers)
2016-09-09 23:25:06 +02:00
this.props.onStyleChanged(changedStyle)
}
2016-09-09 17:09:13 +02:00
render() {
let workspaceContent = null
2016-09-09 23:25:06 +02:00
if(this.props.workContext === "layers") {
2016-09-10 14:10:25 +02:00
workspaceContent = <LayerList
2016-09-09 23:25:06 +02:00
onLayersChanged={this.onLayersChanged.bind(this)}
layers={this.props.mapStyle.get('layers')}
2016-09-09 23:25:06 +02:00
/>
2016-09-09 17:09:13 +02:00
}
2016-09-09 23:25:06 +02:00
if(this.props.workContext === "settings") {
workspaceContent = <SettingsEditor
onStyleChanged={this.props.onStyleChanged}
mapStyle={this.props.mapStyle}
/>
2016-09-09 18:53:57 +02:00
}
2016-09-09 17:09:13 +02:00
return <div style={{
zIndex: 100,
position: "fixed",
left: 60,
width: 300,
top: 0,
bottom: 0,
overflow: "hidden",
backgroundColor: theme.colors.gray}
}>
{workspaceContent}
</div>
}
}