Add manifest.json, icons and install button, flatten client/src
This commit is contained in:
parent
a219e689c1
commit
474afda9c2
105 changed files with 338 additions and 283 deletions
48
client/js/components/ui/FileInput.js
Normal file
48
client/js/components/ui/FileInput.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
import React, { PureComponent } from 'react';
|
||||
import Button from 'components/ui/Button';
|
||||
|
||||
export default class FileInput extends PureComponent {
|
||||
static defaultProps = {
|
||||
type: 'text'
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.input = window.document.createElement('input');
|
||||
this.input.setAttribute('type', 'file');
|
||||
|
||||
this.input.addEventListener('change', e => {
|
||||
const file = e.target.files[0];
|
||||
const reader = new FileReader();
|
||||
const { onChange, type } = this.props;
|
||||
|
||||
reader.onload = () => {
|
||||
onChange(file.name, reader.result);
|
||||
};
|
||||
|
||||
switch (type) {
|
||||
case 'binary':
|
||||
reader.readAsArrayBuffer(file);
|
||||
break;
|
||||
|
||||
case 'text':
|
||||
reader.readAsText(file);
|
||||
break;
|
||||
|
||||
default:
|
||||
reader.readAsText(file);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
handleClick = () => this.input.click();
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Button className="input-file" onClick={this.handleClick}>
|
||||
{this.props.name}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue