2016-09-09 00:10:54 +02:00
|
|
|
import React from 'react'
|
2016-09-09 16:58:48 +02:00
|
|
|
import {saveAs} from 'file-saver'
|
2016-09-09 00:10:54 +02:00
|
|
|
|
2016-09-08 19:47:29 +02:00
|
|
|
import { Drawer, Container, Block, Fixed } from 'rebass'
|
2016-09-09 00:10:54 +02:00
|
|
|
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'
|
2016-09-09 00:10:54 +02:00
|
|
|
|
|
|
|
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() {
|
2016-09-09 00:10:54 +02:00
|
|
|
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:10:54 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}>
|
2016-09-09 00:10:54 +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
|
|
|
|
}
|
|
|
|
|
2016-09-09 00:10:54 +02:00
|
|
|
constructor(props) {
|
|
|
|
super(props)
|
|
|
|
this.state = {
|
2016-09-09 15:49:23 +02:00
|
|
|
styleManager: new StyleManager(),
|
2016-09-09 00:10:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-09 16:58:48 +02:00
|
|
|
onStyleDownload() {
|
|
|
|
const mapStyle = this.state.styleManager.exportStyle()
|
|
|
|
const blob = new Blob([mapStyle], {type: "application/json;charset=utf-8"});
|
|
|
|
saveAs(blob, "glstyle.json");
|
|
|
|
}
|
|
|
|
|
2016-09-09 15:49:23 +02:00
|
|
|
onStyleUpload(newStyle) {
|
|
|
|
this.setState({ styleManager: new StyleManager(newStyle) })
|
2016-09-09 00:10:54 +02:00
|
|
|
}
|
|
|
|
|
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 16:58:48 +02:00
|
|
|
<Toolbar onStyleUpload={this.onStyleUpload.bind(this)} onStyleDownload={this.onStyleDownload.bind(this)} />
|
2016-09-09 15:49:23 +02:00
|
|
|
<WorkspaceDrawer styleManager={this.state.styleManager}/>
|
2016-09-09 00:10:54 +02:00
|
|
|
<div className={layout.map}>
|
2016-09-09 15:49:23 +02:00
|
|
|
<Map styleManager={this.state.styleManager} />
|
2016-09-09 00:10:54 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2015-06-15 15:21:19 +02:00
|
|
|
}
|
2016-09-08 19:47:29 +02:00
|
|
|
}
|