Load icons explicit and implement save

This commit is contained in:
lukasmartinelli
2016-09-10 14:47:06 +02:00
parent ab79c632b0
commit d132c09afc
5 changed files with 47 additions and 10 deletions
+16 -4
View File
@@ -3,7 +3,12 @@ import FileReaderInput from 'react-file-reader-input';
import { Button, Text } from 'rebass';
import { Menu, NavItem, Tooltip, Container, Block, Fixed } from 'rebass'
import { MdFileDownload, MdFileUpload, MdSettings, MdPalette, MdLayers, MdSave, MdFolderOpen} from 'react-icons/lib/md';
import MdFileDownload from 'react-icons/lib/md/file-download'
import MdFileUpload from 'react-icons/lib/md/file-upload'
import MdSettings from 'react-icons/lib/md/settings'
import MdLayers from 'react-icons/lib/md/layers'
import MdSave from 'react-icons/lib/md/save'
import theme from './theme.js';
@@ -11,13 +16,13 @@ export class Toolbar extends React.Component {
static propTypes = {
onStyleUpload: React.PropTypes.func.isRequired,
onStyleDownload: React.PropTypes.func.isRequired,
onStyleSave: React.PropTypes.func,
onOpenSettings: React.PropTypes.func,
onOpenLayers: React.PropTypes.func,
}
constructor(props) {
super(props);
this.onUpload = this.onUpload.bind(this);
this.state = {
styleUploaded: false
}
@@ -39,7 +44,7 @@ export class Toolbar extends React.Component {
render() {
let downloadButton = null
if(this.state.styleUploaded) {
if(this.props.styleUploaded) {
downloadButton = <Block>
<Button onClick={this.props.onStyleDownload} big={true}>
<Tooltip inverted rounded title="Download style">
@@ -59,7 +64,7 @@ export class Toolbar extends React.Component {
backgroundColor: theme.colors.black }
}>
<Block>
<FileReaderInput onChange={this.onUpload}>
<FileReaderInput onChange={this.onUpload.bind(this)}>
<Button big={true} theme={this.state.styleUploaded ? "default" : "success"}>
<Tooltip inverted rounded title="Upload style">
<MdFileUpload />
@@ -68,6 +73,13 @@ export class Toolbar extends React.Component {
</FileReaderInput>
</Block>
{downloadButton}
<Block>
<Button onClick={this.props.onStyleSave} big={true}>
<Tooltip inverted rounded title="Save style">
<MdSave />
</Tooltip>
</Button>
</Block>
<Block>
<Button big={true} onClick={this.props.onOpenLayers}>
<Tooltip inverted rounded title="Layers">