Docker tweaks and PDF width fix
All checks were successful
Publish Docker Image / Publish Docker Image (push) Successful in 4s
All checks were successful
Publish Docker Image / Publish Docker Image (push) Successful in 4s
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { useState } from 'react'
|
||||
import { useState, useRef, useEffect } from 'react'
|
||||
|
||||
import { mdiOpenInNew } from '@mdi/js'
|
||||
import Icon from '@mdi/react'
|
||||
import { Document, Page as PdfPage, pdfjs } from 'react-pdf'
|
||||
|
||||
import 'react-pdf/dist/Page/AnnotationLayer.css'
|
||||
import 'react-pdf/dist/Page/TextLayer.css'
|
||||
|
||||
@@ -22,9 +23,24 @@ const PDF = ({ url, form = false }: PDFProps) => {
|
||||
setNumPages(numPages)
|
||||
}
|
||||
|
||||
const containerRef = useRef<HTMLDivElement>(null)
|
||||
const [containerWidth, setContainerWidth] = useState<number>(0)
|
||||
|
||||
useEffect(() => {
|
||||
function updateWidth() {
|
||||
if (containerRef.current) {
|
||||
setContainerWidth(containerRef.current.clientWidth)
|
||||
}
|
||||
}
|
||||
updateWidth()
|
||||
window.addEventListener('resize', updateWidth)
|
||||
return () => window.removeEventListener('resize', updateWidth)
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div
|
||||
className="overflow-y-auto flex justify-center"
|
||||
ref={containerRef}
|
||||
className="overflow-auto flex justify-center"
|
||||
style={{
|
||||
width: 'calc(100vw - 1rem)',
|
||||
height: `calc(100vh - ${form ? '8.5rem' : '6rem'})`,
|
||||
@@ -40,7 +56,11 @@ const PDF = ({ url, form = false }: PDFProps) => {
|
||||
</a>
|
||||
<Document file={url} onLoadSuccess={onLoadSuccess}>
|
||||
{Array.from({ length: numPages }, (_, i) => (
|
||||
<PdfPage key={i} pageNumber={i + 1} width={800} />
|
||||
<PdfPage
|
||||
key={i}
|
||||
pageNumber={i + 1}
|
||||
width={Math.min(containerWidth, 800)}
|
||||
/>
|
||||
))}
|
||||
</Document>
|
||||
</div>
|
||||
|
||||
@@ -76,7 +76,7 @@ const HomePage = () => (
|
||||
rel="noreferrer"
|
||||
className="btn btn-square"
|
||||
>
|
||||
{getLogoComponent('github')}
|
||||
{getLogoComponent('gitea')}
|
||||
</a>
|
||||
</div>
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user