maputnik/src/toolbar.jsx

65 lines
1.5 KiB
React
Raw Normal View History

2016-09-08 19:47:29 +02:00
import React from 'react';
import FileReaderInput from 'react-file-reader-input';
2016-09-08 19:47:29 +02:00
import { Button, Text } from 'rebass';
2016-09-08 19:47:29 +02:00
import { Menu, NavItem, Tooltip, Container, Block, Fixed } from 'rebass'
import {MdSettings, MdPalette, MdLayers, MdSave, MdFolderOpen} from 'react-icons/lib/md';
import theme from './theme.js';
2016-09-08 19:47:29 +02:00
export class Toolbar extends React.Component {
2016-09-08 20:35:21 +02:00
constructor(props) {
super(props);
this.onUpload = this.onUpload.bind(this);
2016-09-08 20:35:21 +02:00
}
onUpload(_, files) {
const [e, file] = files[0];
const reader = new FileReader();
reader.readAsText(file, "UTF-8");
reader.onload = e => {
const style = JSON.parse(e.target.result);
this.props.onStyleUpload(style);
2016-09-08 20:35:21 +02:00
}
reader.onerror = e => console.log(e.target);
}
2016-09-08 19:47:29 +02:00
render() {
return <Container style={{
zIndex: 100,
position: "fixed",
height: "100%",
left: "0",
top: "0",
bottom: "0",
backgroundColor: theme.colors.black }
}>
<Block>
2016-09-08 20:35:21 +02:00
<FileReaderInput onChange={this.onUpload}>
<Button big={true}>
<Tooltip inverted rounded title="Save">
<MdSave />
</Tooltip>
</Button>
</FileReaderInput>
2016-09-08 19:47:29 +02:00
</Block>
<Block>
<Button big={true}><MdFolderOpen /></Button>
</Block>
<Block>
<Button big={true}>
<Tooltip inverted rounded title="Layers">
<MdLayers />
</Tooltip>
</Button>
</Block>
<Block>
<Button big={true}><MdPalette /></Button>
</Block>
<Block>
<Button big={true}><MdSettings /></Button>
</Block>
</Container>
}
}