footerFileButton.tsx 872 B

123456789101112131415161718192021222324252627282930
  1. import * as React from "react";
  2. import { GlobalState } from '../globalState';
  3. interface IFooterFileButtonProps {
  4. globalState: GlobalState;
  5. enabled: boolean;
  6. icon: any;
  7. label: string;
  8. onFilesPicked: (evt: Event,files: FileList | null) => void;
  9. }
  10. export class FooterFileButton extends React.Component<IFooterFileButtonProps> {
  11. onFilePicked(evt: React.ChangeEvent<HTMLInputElement>) {
  12. this.props.onFilesPicked(evt.nativeEvent, evt.target.files);
  13. }
  14. public render() {
  15. if (!this.props.enabled) {
  16. return null;
  17. }
  18. return (
  19. <div className="custom-upload" title={this.props.label}>
  20. <img src={this.props.icon}/>
  21. <input type="file" id="files" multiple onChange={evt => this.onFilePicked(evt)}/>
  22. </div>
  23. )
  24. }
  25. }