2016-12-20 11:44:22 +01:00
|
|
|
import React from 'react'
|
2017-11-06 16:32:04 +01:00
|
|
|
import PropTypes from 'prop-types'
|
2016-12-20 11:44:22 +01:00
|
|
|
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
|
|
|
|
2017-10-11 12:17:02 +02:00
|
|
|
import logoImage from 'maputnik-design/logos/logo-color.svg'
|
2018-01-31 22:04:49 +01:00
|
|
|
import pkgJson from '../../package.json'
|
2016-12-20 11:44:22 +01:00
|
|
|
|
|
|
|
import style from '../libs/style'
|
2016-09-08 19:47:29 +02:00
|
|
|
|
2017-11-08 09:47:36 +01:00
|
|
|
class IconText extends React.Component {
|
|
|
|
static propTypes = {
|
|
|
|
children: PropTypes.node,
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return <span className="maputnik-icon-text">{this.props.children}</span>
|
|
|
|
}
|
2017-01-11 09:35:48 +01:00
|
|
|
}
|
2016-12-04 17:03:36 +01:00
|
|
|
|
2017-11-08 09:47:36 +01:00
|
|
|
class ToolbarLink extends React.Component {
|
|
|
|
static propTypes = {
|
|
|
|
className: PropTypes.string,
|
|
|
|
children: PropTypes.node,
|
2017-11-08 09:51:24 +01:00
|
|
|
href: PropTypes.string,
|
2017-11-08 09:47:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return <a
|
|
|
|
className={classnames('maputnik-toolbar-link', this.props.className)}
|
|
|
|
href={this.props.href}
|
2017-11-08 10:01:35 +01:00
|
|
|
rel="noopener noreferrer"
|
|
|
|
target="_blank"
|
2017-11-08 09:47:36 +01:00
|
|
|
>
|
|
|
|
{this.props.children}
|
|
|
|
</a>
|
|
|
|
}
|
2017-01-11 09:35:48 +01:00
|
|
|
}
|
2016-12-21 14:46:51 +01:00
|
|
|
|
2017-11-08 09:47:36 +01:00
|
|
|
class ToolbarAction extends React.Component {
|
|
|
|
static propTypes = {
|
2017-11-08 09:51:24 +01:00
|
|
|
children: PropTypes.node,
|
2018-04-10 16:15:29 +02:00
|
|
|
onClick: PropTypes.func,
|
|
|
|
wdKey: PropTypes.string
|
2017-11-08 09:47:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2018-05-10 17:50:37 +02:00
|
|
|
return <button
|
2017-11-08 09:47:36 +01:00
|
|
|
className='maputnik-toolbar-action'
|
2018-01-05 18:45:55 +01:00
|
|
|
data-wd-key={this.props.wdKey}
|
2017-11-08 09:47:36 +01:00
|
|
|
onClick={this.props.onClick}
|
|
|
|
>
|
|
|
|
{this.props.children}
|
2018-05-10 17:50:37 +02:00
|
|
|
</button>
|
2017-11-08 09:47:36 +01:00
|
|
|
}
|
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 = {
|
2017-11-06 16:32:04 +01:00
|
|
|
mapStyle: PropTypes.object.isRequired,
|
|
|
|
inspectModeEnabled: PropTypes.bool.isRequired,
|
|
|
|
onStyleChanged: PropTypes.func.isRequired,
|
2016-12-04 17:03:36 +01:00
|
|
|
// A new style has been uploaded
|
2017-11-06 16:32:04 +01:00
|
|
|
onStyleOpen: PropTypes.func.isRequired,
|
2016-12-29 14:44:46 +01:00
|
|
|
// A dict of source id's and the available source layers
|
2017-11-06 16:32:04 +01:00
|
|
|
sources: PropTypes.object.isRequired,
|
2017-11-08 09:47:36 +01:00
|
|
|
onInspectModeToggle: PropTypes.func.isRequired,
|
|
|
|
children: PropTypes.node
|
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:54:22 +01:00
|
|
|
render() {
|
2017-01-10 21:28:30 +01:00
|
|
|
return <div className='maputnik-toolbar'>
|
2017-11-06 11:23:13 +01:00
|
|
|
<div className="maputnik-toolbar__inner">
|
|
|
|
<ToolbarLink
|
|
|
|
href={"https://github.com/maputnik/editor"}
|
|
|
|
className="maputnik-toolbar-logo"
|
|
|
|
>
|
|
|
|
<img src={logoImage} alt="Maputnik" />
|
2018-01-31 22:04:49 +01:00
|
|
|
<h1>Maputnik
|
|
|
|
<span className="maputnik-toolbar-version">v{pkgJson.version}</span>
|
|
|
|
</h1>
|
2017-11-06 11:23:13 +01:00
|
|
|
</ToolbarLink>
|
|
|
|
<div className="maputnik-toolbar__actions">
|
2018-05-29 18:06:00 +02:00
|
|
|
<ToolbarAction wdKey="nav:open" onClick={this.props.onToggleModal.bind(this, 'open')}>
|
2017-11-06 11:23:13 +01:00
|
|
|
<OpenIcon />
|
|
|
|
<IconText>Open</IconText>
|
|
|
|
</ToolbarAction>
|
2018-05-29 18:06:00 +02:00
|
|
|
<ToolbarAction wdKey="nav:export" onClick={this.props.onToggleModal.bind(this, 'export')}>
|
2017-11-06 11:23:13 +01:00
|
|
|
<MdFileDownload />
|
|
|
|
<IconText>Export</IconText>
|
|
|
|
</ToolbarAction>
|
2018-05-29 18:06:00 +02:00
|
|
|
<ToolbarAction wdKey="nav:sources" onClick={this.props.onToggleModal.bind(this, 'sources')}>
|
2017-11-06 11:23:13 +01:00
|
|
|
<SourcesIcon />
|
|
|
|
<IconText>Sources</IconText>
|
|
|
|
</ToolbarAction>
|
2018-05-29 18:06:00 +02:00
|
|
|
<ToolbarAction wdKey="nav:settings" onClick={this.props.onToggleModal.bind(this, 'settings')}>
|
2017-11-06 11:23:13 +01:00
|
|
|
<SettingsIcon />
|
|
|
|
<IconText>Style Settings</IconText>
|
|
|
|
</ToolbarAction>
|
2018-01-05 18:45:55 +01:00
|
|
|
<ToolbarAction wdKey="nav:inspect" onClick={this.props.onInspectModeToggle}>
|
2017-11-06 11:23:13 +01:00
|
|
|
<InspectionIcon />
|
|
|
|
<IconText>
|
|
|
|
{ this.props.inspectModeEnabled && <span>Map Mode</span> }
|
|
|
|
{ !this.props.inspectModeEnabled && <span>Inspect Mode</span> }
|
|
|
|
</IconText>
|
|
|
|
</ToolbarAction>
|
|
|
|
<ToolbarLink href={"https://github.com/maputnik/editor/wiki"}>
|
|
|
|
<HelpIcon />
|
|
|
|
<IconText>Help</IconText>
|
|
|
|
</ToolbarLink>
|
|
|
|
</div>
|
|
|
|
</div>
|
2016-12-04 17:03:36 +01:00
|
|
|
</div>
|
|
|
|
}
|
2016-09-08 19:47:29 +02:00
|
|
|
}
|