overleaf/services/web/frontend/js/features/pdf-preview/components/pdf-preview-pane.js
Alf Eaton e26d47cb41 Add hybrid toolbar to migrated PDF preview (#5414)
GitOrigin-RevId: 6266028091229c819aee3c8d4bd3bff2e2417125
2021-10-13 08:03:01 +00:00

37 lines
1 KiB
JavaScript

import { memo, Suspense } from 'react'
import PdfLogsViewer from './pdf-logs-viewer'
import PdfViewer from './pdf-viewer'
import { usePdfPreviewContext } from '../contexts/pdf-preview-context'
import LoadingSpinner from '../../../shared/components/loading-spinner'
import PdfHybridPreviewToolbar from './pdf-preview-hybrid-toolbar'
import PdfPreviewToolbar from './pdf-preview-toolbar'
const newPreviewToolbar = new URLSearchParams(window.location.search).has(
'new_preview_toolbar'
)
function PdfPreviewPane() {
const { showLogs } = usePdfPreviewContext()
return (
<div className="pdf full-size">
{newPreviewToolbar ? <PdfPreviewToolbar /> : <PdfHybridPreviewToolbar />}
<Suspense fallback={<LoadingPreview />}>
<div className="pdf-viewer">
<PdfViewer />
</div>
</Suspense>
{showLogs && <PdfLogsViewer />}
</div>
)
}
function LoadingPreview() {
return (
<div className="pdf-loading-spinner-container">
<LoadingSpinner />
</div>
)
}
export default memo(PdfPreviewPane)