Pass everything down as props

This commit is contained in:
lukasmartinelli
2016-09-09 23:25:06 +02:00
parent 416cf7e0af
commit b6dff4aa58
8 changed files with 214 additions and 167 deletions

View File

@@ -3,23 +3,36 @@ import { LayerEditor } from './layers.jsx'
import { SettingsEditor } from './settings.jsx'
import theme from './theme.js'
/** The workspace drawer contains the editor components depending on the context
* chosen in the toolbar. */
/** The workspace drawer contains the editor components depending on the edit
* context chosen in the toolbar. It holds the state of the layers.*/
export class WorkspaceDrawer extends React.Component {
static propTypes = {
mapStyle: React.PropTypes.object.isRequired,
onStyleChanged: React.PropTypes.func.isRequired,
workContext: React.PropTypes.oneOf(['layers', 'settings']).isRequired,
styleManager: React.PropTypes.object.isRequired
}
onLayersChanged(layers) {
const changedStyle = this.props.mapStyle
changedStyle.layers = layers
this.props.onStyleChanged(changedStyle)
}
render() {
let workspaceContent = null
if(this.props.workContext === "layers" && this.props.styleManager.mapStyle) {
workspaceContent = <LayerEditor styleManager={this.props.styleManager}/>
if(this.props.workContext === "layers") {
workspaceContent = <LayerEditor
onLayersChanged={this.onLayersChanged.bind(this)}
layers={this.props.mapStyle.layers}
/>
}
if(this.props.workContext === "settings" && this.props.styleManager.mapStyle) {
workspaceContent = <SettingsEditor styleManager={this.props.styleManager}/>
if(this.props.workContext === "settings") {
workspaceContent = <SettingsEditor
onStyleChanged={this.props.onStyleChanged}
mapStyle={this.props.mapStyle}
/>
}
return <div style={{