Spaces:
Running
Running
File size: 1,407 Bytes
3637bbd 1ce4fbf 7c09b39 3637bbd 2c7dc70 5a19572 3637bbd 2c7dc70 5a19572 3637bbd 399829c 3637bbd 5a19572 3637bbd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | import React from "react";
import styles from "./FileViewerPopup.module.css";
import PdfViewer from "../PdfViewer/PdfViewer";
import Button from "../../buttons/MainButton/Button";
import Text from "../../Text/Text";
import TxtViewer from "../TxtViewer/TxtViewer";
interface FileViewerPopupProps {
isOpen: boolean;
onClose: () => void;
fileUrl: string;
fileName: string;
initialPage?: number;
initialLines?: string;
start?: string;
}
const FileViewerPopup = ({
isOpen,
onClose,
fileUrl,
fileName,
initialPage = 0,
initialLines = "",
start = "",
}: FileViewerPopupProps) => {
if (!isOpen) {
return null;
}
return (
<>
<div className={styles.backdrop} onClick={onClose} />
<div className={`${styles.popupContainer} ${isOpen ? styles.open : ""}`}>
<header className={styles.popupHeader}>
<Text className={styles.fileName} fontWeight={"bold"}>
{fileName}
</Text>
<Button onClick={onClose} width="80px" height="40px">
Close
</Button>
</header>
<div className={styles.viewerWrapper}>
{fileUrl.split(".").at(-1) === "pdf" ? <PdfViewer pdfUrl={fileUrl} initialPage={initialPage} /> : <TxtViewer fileUrl={fileUrl} initialPage={initialPage} initialLines={initialLines} start={start}/>}
</div>
</div>
</>
);
};
export default FileViewerPopup;
|