mirror of
https://github.com/maputnik/editor.git
synced 2026-01-06 05:20:01 +00:00
Enable style file upload
This commit is contained in:
@@ -4,8 +4,26 @@ import { Menu, NavItem, Tooltip, Container, Block, Fixed } from 'rebass'
|
||||
import theme from './theme.jsx';
|
||||
import {MdSettings, MdPalette, MdLayers, MdSave, MdFolderOpen} from 'react-icons/lib/md';
|
||||
import { Button, Text } from 'rebass';
|
||||
import FileReaderInput from 'react-file-reader-input';
|
||||
|
||||
export class Toolbar extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
styleFile: null
|
||||
};
|
||||
}
|
||||
|
||||
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);
|
||||
console.log(style);
|
||||
}
|
||||
reader.onerror = e => console.log(e.target);
|
||||
}
|
||||
render() {
|
||||
return <Container style={{
|
||||
zIndex: 100,
|
||||
@@ -17,11 +35,13 @@ export class Toolbar extends React.Component {
|
||||
backgroundColor: theme.colors.black }
|
||||
}>
|
||||
<Block>
|
||||
<Button big={true}>
|
||||
<Tooltip inverted rounded title="Save">
|
||||
<MdSave />
|
||||
</Tooltip>
|
||||
</Button>
|
||||
<FileReaderInput onChange={this.onUpload}>
|
||||
<Button big={true}>
|
||||
<Tooltip inverted rounded title="Save">
|
||||
<MdSave />
|
||||
</Tooltip>
|
||||
</Button>
|
||||
</FileReaderInput>
|
||||
</Block>
|
||||
<Block>
|
||||
<Button big={true}><MdFolderOpen /></Button>
|
||||
|
||||
Reference in New Issue
Block a user