2024-05-29 10:17:37 -04:00
|
|
|
import { useRef } from 'react'
|
|
|
|
|
|
|
|
import PdfPageNumberControl from './pdf-page-number-control'
|
|
|
|
import PdfZoomButtons from './pdf-zoom-buttons'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import MaterialIcon from '@/shared/components/material-icon'
|
|
|
|
import useDropdown from '@/shared/hooks/use-dropdown'
|
2024-10-08 10:22:13 -04:00
|
|
|
import OLTooltip from '@/features/ui/components/ol/ol-tooltip'
|
|
|
|
import OLButton from '@/features/ui/components/ol/ol-button'
|
|
|
|
import OLOverlay from '@/features/ui/components/ol/ol-overlay'
|
|
|
|
import OLPopover from '@/features/ui/components/ol/ol-popover'
|
2024-05-29 10:17:37 -04:00
|
|
|
|
|
|
|
type PdfViewerControlsMenuButtonProps = {
|
|
|
|
setZoom: (zoom: string) => void
|
|
|
|
setPage: (page: number) => void
|
|
|
|
page: number
|
|
|
|
totalPages: number
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function PdfViewerControlsMenuButton({
|
|
|
|
setZoom,
|
|
|
|
setPage,
|
|
|
|
page,
|
|
|
|
totalPages,
|
|
|
|
}: PdfViewerControlsMenuButtonProps) {
|
|
|
|
const { t } = useTranslation()
|
|
|
|
|
|
|
|
const {
|
|
|
|
open: popoverOpen,
|
|
|
|
onToggle: togglePopover,
|
|
|
|
ref: popoverRef,
|
|
|
|
} = useDropdown()
|
|
|
|
|
2024-10-08 10:22:13 -04:00
|
|
|
const targetRef = useRef<HTMLButtonElement | null>(null)
|
2024-05-29 10:17:37 -04:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2024-10-08 10:22:13 -04:00
|
|
|
<OLTooltip
|
2024-05-29 10:17:37 -04:00
|
|
|
id="pdf-controls-menu-tooltip"
|
|
|
|
description={t('view_options')}
|
|
|
|
overlayProps={{ placement: 'bottom' }}
|
|
|
|
>
|
2024-10-08 10:22:13 -04:00
|
|
|
<span>
|
|
|
|
<OLButton
|
|
|
|
variant="ghost"
|
|
|
|
className="pdf-toolbar-btn pdfjs-toolbar-popover-button"
|
|
|
|
onClick={togglePopover}
|
|
|
|
ref={targetRef}
|
|
|
|
>
|
|
|
|
<MaterialIcon type="more_horiz" />
|
|
|
|
</OLButton>
|
|
|
|
</span>
|
|
|
|
</OLTooltip>
|
2024-05-29 10:17:37 -04:00
|
|
|
|
2024-10-08 10:22:13 -04:00
|
|
|
<OLOverlay
|
2024-05-29 10:17:37 -04:00
|
|
|
show={popoverOpen}
|
|
|
|
target={targetRef.current}
|
|
|
|
placement="bottom"
|
|
|
|
containerPadding={0}
|
2024-10-08 10:22:13 -04:00
|
|
|
transition
|
2024-05-29 10:17:37 -04:00
|
|
|
rootClose
|
|
|
|
onHide={() => togglePopover(false)}
|
|
|
|
>
|
2024-10-08 10:22:13 -04:00
|
|
|
<OLPopover
|
2024-05-29 10:17:37 -04:00
|
|
|
className="pdfjs-toolbar-popover"
|
|
|
|
id="pdf-toolbar-popover-menu"
|
|
|
|
ref={popoverRef}
|
|
|
|
>
|
|
|
|
<PdfPageNumberControl
|
|
|
|
setPage={setPage}
|
|
|
|
page={page}
|
|
|
|
totalPages={totalPages}
|
|
|
|
/>
|
|
|
|
<div className="pdfjs-zoom-controls">
|
|
|
|
<PdfZoomButtons setZoom={setZoom} />
|
|
|
|
</div>
|
2024-10-08 10:22:13 -04:00
|
|
|
</OLPopover>
|
|
|
|
</OLOverlay>
|
2024-05-29 10:17:37 -04:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|