- [x] Cleanup Automation output name garbage - [x] Remove Cross button on first two tools - [x] Automation creation name title to make clearer to the user - [x] Colours for dark mode on automation tool settings are bad - [x] Fix tool names not using correct translated ones - [x] suggested Automation Password needs adding to description - [x] Allow different filetypes in automation - [x] Custom Icons for automation - [x] split Tool wasn't working with merge to single pdf --------- Co-authored-by: Connor Yoh <connor@stirlingpdf.com> Co-authored-by: James Brunton <jbrunton96@gmail.com>
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import React, { useRef } from "react";
|
|
import { FileButton, Button } from "@mantine/core";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
interface FileUploadButtonProps {
|
|
file?: File;
|
|
onChange: (file: File | null) => void;
|
|
accept?: string;
|
|
disabled?: boolean;
|
|
placeholder?: string;
|
|
variant?: "outline" | "filled" | "light" | "default" | "subtle" | "gradient";
|
|
fullWidth?: boolean;
|
|
}
|
|
|
|
const FileUploadButton = ({
|
|
file,
|
|
onChange,
|
|
accept = "*/*",
|
|
disabled = false,
|
|
placeholder,
|
|
variant = "outline",
|
|
fullWidth = true
|
|
}: FileUploadButtonProps) => {
|
|
const { t } = useTranslation();
|
|
const resetRef = useRef<() => void>(null);
|
|
|
|
const defaultPlaceholder = t('chooseFile', 'Choose File');
|
|
|
|
return (
|
|
<FileButton
|
|
resetRef={resetRef}
|
|
onChange={onChange}
|
|
accept={accept}
|
|
disabled={disabled}
|
|
|
|
>
|
|
{(props) => (
|
|
<Button {...props} variant={variant} fullWidth={fullWidth} color="blue">
|
|
{file ? file.name : (placeholder || defaultPlaceholder)}
|
|
</Button>
|
|
)}
|
|
</FileButton>
|
|
);
|
|
};
|
|
|
|
export default FileUploadButton;
|