{"size": 950, "ext": "js", "max_stars_repo_path": "electron/src/components/WebFileSaveButton.js", "max_stars_repo_name": "taoma2011/mxtnote", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "electron/src/components/WebFileSaveButton.js", "max_issues_repo_name": "taoma2011/mxtnote", "max_issues_repo_issues_event_min_datetime": "2021-02-24T07:36:31.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-24T07:36:31.000Z", "max_forks_repo_path": "electron/src/components/WebFileSaveButton.js", "max_forks_repo_name": "taoma2011/mxtnote", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 22.0930232558, "max_line_length": 69, "alphanum_fraction": 0.5957894737}
import React, { Component } from 'react';
import Button from '@material-ui/core/Button';
import { makeStyles } from '@material-ui/core/styles';

const useStyles = makeStyles((theme) => ({
  root: {
    '& > *': {
      margin: theme.spacing(1),
    },
  },
  input: {
    display: 'none',
  },
}));

export const WebFileSaveButton = (props) => {
  // eslint-disable-next-line react/prop-types
  const { label, onFileSelected } = props;
  const fileInput = React.createRef();
  const classes = useStyles();

  const pickFile = async () => {
    const handle = await window.showSaveFilePicker({
      suggestedName: 'notes.tar.gz',
    });
    onFileSelected(handle);
  };
  return (
    <div>
      <Button
        variant="contained"
        style={{ backgroundColor: '#7e949c', textTransform: 'none' }}
        component="span"
        onClick={pickFile}
      >
        {label}
      </Button>
    </div>
  );
};

export default WebFileSaveButton;
