Newer
Older
Jacopo Gasparetto
committed
import { ChangeEvent, ReactNode } from "react";
import { Button } from "./Button";
interface InputFileProps {
onChange: (e: ChangeEvent<HTMLInputElement>) => void;
Jacopo Gasparetto
committed
icon?: ReactNode
Jacopo Gasparetto
committed
export const InputFile = ({ onChange, icon }: InputFileProps) => {
const openFileSelector = () => {
const fileSelector = document.getElementById("fileSelector");
if (fileSelector) {
fileSelector.click();
}
}
return (
<div className="">
<input
onChange={onChange}
Jacopo Gasparetto
committed
className="hidden"
Jacopo Gasparetto
committed
id="fileSelector"
/>
<Button
title="Upload File"
icon={icon}
onClick={openFileSelector}