maputnik/src/app.jsx

75 lines
1.6 KiB
React
Raw Normal View History

import React from 'react'
2016-09-08 19:47:29 +02:00
import { Drawer, Container, Block, Fixed } from 'rebass'
import {Map} from './map.jsx'
import {Toolbar} from './toolbar.jsx'
2016-09-08 19:47:29 +02:00
import { LayerEditor } from './layers.jsx'
2016-09-09 15:49:23 +02:00
import { StyleManager } from './style.js'
import theme from './theme.js'
import layout from './layout.scss'
2016-09-09 15:49:23 +02:00
import 'react-virtualized/styles.css'
2015-06-15 15:21:19 +02:00
2016-09-08 21:42:18 +02:00
export class WorkspaceDrawer extends React.Component {
2016-09-09 15:49:23 +02:00
static propTypes = {
styleManager: React.PropTypes.object.isRequired
}
2016-09-08 21:42:18 +02:00
render() {
let editor = null
2016-09-09 15:49:23 +02:00
if(this.props.styleManager.mapStyle) {
editor = <LayerEditor styleManager={this.props.styleManager}/>
}
2016-09-09 00:55:50 +02:00
return <div style={{
2016-09-08 21:42:18 +02:00
zIndex: 100,
position: "fixed",
2016-09-09 12:08:33 +02:00
left: 60,
2016-09-08 21:42:18 +02:00
width: 300,
2016-09-09 12:08:33 +02:00
top: 0,
bottom: 0,
overflow: "hidden",
2016-09-08 21:42:18 +02:00
backgroundColor: theme.colors.gray}
2016-09-09 12:08:33 +02:00
}>
{editor}
2016-09-09 00:55:50 +02:00
</div>
2016-09-08 21:42:18 +02:00
}
}
2015-06-15 15:21:19 +02:00
export default class App extends React.Component {
2016-09-08 19:47:29 +02:00
static childContextTypes = {
rebass: React.PropTypes.object,
reactIconBase: React.PropTypes.object
}
constructor(props) {
super(props)
this.state = {
2016-09-09 15:49:23 +02:00
styleManager: new StyleManager(),
}
}
2016-09-09 15:49:23 +02:00
onStyleUpload(newStyle) {
this.setState({ styleManager: new StyleManager(newStyle) })
}
2016-09-08 19:47:29 +02:00
getChildContext () {
return {
rebass: theme,
reactIconBase: {
size: 20,
}
}
}
2015-06-15 15:21:19 +02:00
render() {
2016-09-09 11:29:18 +02:00
return <div style={{ fontFamily: theme.fontFamily, color: theme.color }}>
2016-09-09 15:49:23 +02:00
<Toolbar onStyleUpload={this.onStyleUpload.bind(this)} />
<WorkspaceDrawer styleManager={this.state.styleManager}/>
<div className={layout.map}>
2016-09-09 15:49:23 +02:00
<Map styleManager={this.state.styleManager} />
</div>
</div>
2015-06-15 15:21:19 +02:00
}
2016-09-08 19:47:29 +02:00
}