2016-12-20 11:44:22 +01:00
|
|
|
import React from 'react'
|
|
|
|
import FileReaderInput from 'react-file-reader-input'
|
2017-01-11 09:35:48 +01:00
|
|
|
import classnames from 'classnames'
|
2016-09-08 19:47:29 +02:00
|
|
|
|
2016-09-10 14:47:06 +02:00
|
|
|
import MdFileDownload from 'react-icons/lib/md/file-download'
|
|
|
|
import MdFileUpload from 'react-icons/lib/md/file-upload'
|
2016-12-28 16:23:33 +01:00
|
|
|
import OpenIcon from 'react-icons/lib/md/open-in-browser'
|
|
|
|
import SettingsIcon from 'react-icons/lib/md/settings'
|
2016-09-19 20:49:16 +02:00
|
|
|
import MdInfo from 'react-icons/lib/md/info'
|
2016-12-28 16:23:33 +01:00
|
|
|
import SourcesIcon from 'react-icons/lib/md/layers'
|
2016-09-10 14:47:06 +02:00
|
|
|
import MdSave from 'react-icons/lib/md/save'
|
2016-12-04 17:03:36 +01:00
|
|
|
import MdStyle from 'react-icons/lib/md/style'
|
2016-09-10 22:08:26 +02:00
|
|
|
import MdMap from 'react-icons/lib/md/map'
|
2016-12-04 17:03:36 +01:00
|
|
|
import MdInsertEmoticon from 'react-icons/lib/md/insert-emoticon'
|
|
|
|
import MdFontDownload from 'react-icons/lib/md/font-download'
|
2016-12-28 16:23:33 +01:00
|
|
|
import HelpIcon from 'react-icons/lib/md/help-outline'
|
|
|
|
import InspectionIcon from 'react-icons/lib/md/find-in-page'
|
2016-09-10 22:08:26 +02:00
|
|
|
|
2016-12-31 10:34:32 +01:00
|
|
|
import logoImage from '../img/maputnik.png'
|
2016-12-20 11:44:22 +01:00
|
|
|
import SettingsModal from './modals/SettingsModal'
|
2017-01-12 18:27:44 +01:00
|
|
|
import ExportModal from './modals/ExportModal'
|
2016-12-21 16:11:08 +01:00
|
|
|
import SourcesModal from './modals/SourcesModal'
|
2016-12-22 11:27:53 +01:00
|
|
|
import OpenModal from './modals/OpenModal'
|
2016-12-20 11:44:22 +01:00
|
|
|
|
|
|
|
import style from '../libs/style'
|
2016-09-08 19:47:29 +02:00
|
|
|
|
2017-01-11 09:35:48 +01:00
|
|
|
function IconText(props) {
|
|
|
|
return <span className="maputnik-icon-text">{props.children}</span>
|
|
|
|
}
|
2016-12-04 17:03:36 +01:00
|
|
|
|
2017-01-11 09:35:48 +01:00
|
|
|
function ToolbarLink(props) {
|
|
|
|
return <a
|
|
|
|
className={classnames('maputnik-toolbar-link', props.className)}
|
|
|
|
href={props.href}
|
|
|
|
target={"blank"}
|
2017-01-10 21:28:30 +01:00
|
|
|
>
|
2017-01-11 09:35:48 +01:00
|
|
|
{props.children}
|
|
|
|
</a>
|
|
|
|
}
|
2016-12-21 14:46:51 +01:00
|
|
|
|
2017-01-11 09:35:48 +01:00
|
|
|
function ToolbarAction(props) {
|
|
|
|
return <a
|
|
|
|
className='maputnik-toolbar-action'
|
|
|
|
onClick={props.onClick}
|
|
|
|
>
|
|
|
|
{props.children}
|
|
|
|
</a>
|
2016-12-22 14:18:07 +01:00
|
|
|
}
|
2016-12-22 11:27:53 +01:00
|
|
|
|
2016-12-20 11:44:22 +01:00
|
|
|
export default class Toolbar extends React.Component {
|
2016-12-04 17:03:36 +01:00
|
|
|
static propTypes = {
|
2016-12-20 16:08:49 +01:00
|
|
|
mapStyle: React.PropTypes.object.isRequired,
|
2017-01-11 16:23:33 +01:00
|
|
|
inspectModeEnabled: React.PropTypes.bool.isRequired,
|
2016-12-16 16:52:16 +01:00
|
|
|
onStyleChanged: React.PropTypes.func.isRequired,
|
2016-12-04 17:03:36 +01:00
|
|
|
// A new style has been uploaded
|
2016-12-22 16:51:18 +01:00
|
|
|
onStyleOpen: React.PropTypes.func.isRequired,
|
2016-12-29 14:44:46 +01:00
|
|
|
// A dict of source id's and the available source layers
|
|
|
|
sources: React.PropTypes.object.isRequired,
|
2017-01-08 22:03:21 +01:00
|
|
|
onInspectModeToggle: React.PropTypes.func.isRequired
|
2016-12-16 16:52:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props)
|
|
|
|
this.state = {
|
2016-12-22 16:51:18 +01:00
|
|
|
isOpen: {
|
|
|
|
settings: false,
|
|
|
|
sources: false,
|
|
|
|
open: false,
|
2016-12-29 14:44:46 +01:00
|
|
|
add: false,
|
2017-01-12 18:27:44 +01:00
|
|
|
export: false,
|
2016-12-22 16:51:18 +01:00
|
|
|
}
|
2016-12-16 16:52:16 +01:00
|
|
|
}
|
2016-12-04 17:03:36 +01:00
|
|
|
}
|
|
|
|
|
2016-12-22 16:51:18 +01:00
|
|
|
toggleModal(modalName) {
|
|
|
|
this.setState({
|
|
|
|
isOpen: {
|
|
|
|
...this.state.isOpen,
|
|
|
|
[modalName]: !this.state.isOpen[modalName]
|
|
|
|
}
|
|
|
|
})
|
2016-12-16 17:35:09 +01:00
|
|
|
}
|
|
|
|
|
2016-12-22 16:54:22 +01:00
|
|
|
render() {
|
2017-01-10 21:28:30 +01:00
|
|
|
return <div className='maputnik-toolbar'>
|
2016-12-22 16:51:18 +01:00
|
|
|
<SettingsModal
|
|
|
|
mapStyle={this.props.mapStyle}
|
|
|
|
onStyleChanged={this.props.onStyleChanged}
|
|
|
|
isOpen={this.state.isOpen.settings}
|
|
|
|
onOpenToggle={this.toggleModal.bind(this, 'settings')}
|
2016-12-22 16:54:22 +01:00
|
|
|
/>
|
2017-01-12 18:27:44 +01:00
|
|
|
<ExportModal
|
|
|
|
mapStyle={this.props.mapStyle}
|
2017-01-16 15:07:41 +01:00
|
|
|
onStyleChanged={this.props.onStyleChanged}
|
2017-01-12 18:27:44 +01:00
|
|
|
isOpen={this.state.isOpen.export}
|
|
|
|
onOpenToggle={this.toggleModal.bind(this, 'export')}
|
|
|
|
/>
|
2016-12-22 16:51:18 +01:00
|
|
|
<OpenModal
|
|
|
|
isOpen={this.state.isOpen.open}
|
|
|
|
onStyleOpen={this.props.onStyleOpen}
|
|
|
|
onOpenToggle={this.toggleModal.bind(this, 'open')}
|
2016-12-22 16:54:22 +01:00
|
|
|
/>
|
2016-12-22 16:51:18 +01:00
|
|
|
<SourcesModal
|
|
|
|
mapStyle={this.props.mapStyle}
|
|
|
|
onStyleChanged={this.props.onStyleChanged}
|
|
|
|
isOpen={this.state.isOpen.sources}
|
|
|
|
onOpenToggle={this.toggleModal.bind(this, 'sources')}
|
2016-12-22 16:54:22 +01:00
|
|
|
/>
|
2016-12-22 16:37:53 +01:00
|
|
|
<ToolbarLink
|
|
|
|
href={"https://github.com/maputnik/editor"}
|
2017-01-11 09:35:48 +01:00
|
|
|
className="maputnik-toolbar-logo"
|
2016-12-22 16:37:53 +01:00
|
|
|
>
|
2017-01-11 09:35:48 +01:00
|
|
|
<img src={logoImage} alt="Maputnik" />
|
|
|
|
<h1>Maputnik</h1>
|
2016-12-22 16:37:53 +01:00
|
|
|
</ToolbarLink>
|
2016-12-22 16:51:18 +01:00
|
|
|
<ToolbarAction onClick={this.toggleModal.bind(this, 'open')}>
|
2016-12-28 16:23:33 +01:00
|
|
|
<OpenIcon />
|
2016-12-22 11:27:53 +01:00
|
|
|
<IconText>Open</IconText>
|
2016-12-21 15:08:04 +01:00
|
|
|
</ToolbarAction>
|
2017-01-12 18:27:44 +01:00
|
|
|
<ToolbarAction onClick={this.toggleModal.bind(this, 'export')}>
|
|
|
|
<MdFileDownload />
|
|
|
|
<IconText>Export</IconText>
|
|
|
|
</ToolbarAction>
|
2016-12-22 16:51:18 +01:00
|
|
|
<ToolbarAction onClick={this.toggleModal.bind(this, 'sources')}>
|
2016-12-28 16:23:33 +01:00
|
|
|
<SourcesIcon />
|
2016-12-21 16:11:08 +01:00
|
|
|
<IconText>Sources</IconText>
|
2016-12-21 15:08:04 +01:00
|
|
|
</ToolbarAction>
|
2016-12-22 16:51:18 +01:00
|
|
|
<ToolbarAction onClick={this.toggleModal.bind(this, 'settings')}>
|
2016-12-28 16:23:33 +01:00
|
|
|
<SettingsIcon />
|
2016-12-21 15:08:04 +01:00
|
|
|
<IconText>Style Settings</IconText>
|
|
|
|
</ToolbarAction>
|
2017-01-08 22:03:21 +01:00
|
|
|
<ToolbarAction onClick={this.props.onInspectModeToggle}>
|
2016-12-28 16:23:33 +01:00
|
|
|
<InspectionIcon />
|
2017-01-11 16:23:33 +01:00
|
|
|
<IconText>
|
|
|
|
{ this.props.inspectModeEnabled && <span>Map Mode</span> }
|
|
|
|
{ !this.props.inspectModeEnabled && <span>Inspect Mode</span> }
|
|
|
|
</IconText>
|
2016-12-21 15:08:04 +01:00
|
|
|
</ToolbarAction>
|
2016-12-22 11:37:32 +01:00
|
|
|
<ToolbarLink href={"https://github.com/maputnik/editor/wiki"}>
|
2016-12-28 16:23:33 +01:00
|
|
|
<HelpIcon />
|
2016-12-21 15:08:04 +01:00
|
|
|
<IconText>Help</IconText>
|
2016-12-22 11:37:32 +01:00
|
|
|
</ToolbarLink>
|
2016-12-04 17:03:36 +01:00
|
|
|
</div>
|
|
|
|
}
|
2016-09-08 19:47:29 +02:00
|
|
|
}
|