diff --git a/apps/portal/src/components/resumes/ResumePdf.tsx b/apps/portal/src/components/resumes/ResumePdf.tsx index 668d0f6f..563571c5 100644 --- a/apps/portal/src/components/resumes/ResumePdf.tsx +++ b/apps/portal/src/components/resumes/ResumePdf.tsx @@ -1,4 +1,5 @@ -import { useState } from 'react'; +import clsx from 'clsx'; +import { useEffect, useState } from 'react'; import { Document, Page, pdfjs } from 'react-pdf'; import type { PDFDocumentProxy } from 'react-pdf/node_modules/pdfjs-dist'; import { @@ -18,14 +19,30 @@ type Props = Readonly<{ export default function ResumePdf({ url }: Props) { const [numPages, setNumPages] = useState(0); const [pageNumber, setPageNumber] = useState(1); - const [scale, setScale] = useState(1); + const [pageWidth, setPageWidth] = useState(750); + const [componentWidth, setComponentWidth] = useState(780); const onPdfLoadSuccess = (pdf: PDFDocumentProxy) => { setNumPages(pdf.numPages); }; + useEffect(() => { + const onPageResize = () => { + setComponentWidth( + document.querySelector('#pdfView')?.getBoundingClientRect().width ?? + 780, + ); + }; + + window.addEventListener('resize', onPageResize); + + return () => { + window.removeEventListener('resize', onPageResize); + }; + }, []); + return ( -
+
} noData="" onLoadSuccess={onPdfLoadSuccess}> - +
componentWidth + ? `${pageWidth - componentWidth}px` + : '', + ), + }}> + +