refine viewer detail panel logic and styling.
This commit is contained in:
@@ -258,6 +258,34 @@ const PdfViewer = ({ src, title, className, viewportRef }: PdfViewerProps): JSX.
|
|||||||
focusTargetRef.current = null;
|
focusTargetRef.current = null;
|
||||||
}, [viewMode, viewportRef]);
|
}, [viewMode, viewportRef]);
|
||||||
|
|
||||||
|
// Auto-detect scrollbar contrast requirement
|
||||||
|
useEffect(() => {
|
||||||
|
const viewportElement = viewportRef?.current || containerRef.current?.closest('.document-viewer__viewport');
|
||||||
|
if (!viewportElement || pages.length === 0 || viewportWidth <= 0 || viewportHeight <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const page = pages[0];
|
||||||
|
const pageAspect = page.width / page.height;
|
||||||
|
const viewportAspect = viewportWidth / viewportHeight;
|
||||||
|
|
||||||
|
// If we are in 'fit-width' mode, the page usually covers the full width (white background).
|
||||||
|
// If we are in 'contain' mode, we check if the page is narrower than the viewport (gray background).
|
||||||
|
const hasHorizontalMargin = viewMode === 'contain' && pageAspect < viewportAspect;
|
||||||
|
|
||||||
|
// If there is no margin (white page), we need the light scheme (dark scrollbar).
|
||||||
|
// If there is a margin (gray background), we use the default scheme (light scrollbar).
|
||||||
|
if (!hasHorizontalMargin) {
|
||||||
|
viewportElement.classList.add('document-viewer__viewport--light-scheme');
|
||||||
|
} else {
|
||||||
|
viewportElement.classList.remove('document-viewer__viewport--light-scheme');
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
viewportElement.classList.remove('document-viewer__viewport--light-scheme');
|
||||||
|
};
|
||||||
|
}, [viewMode, viewportRef, pages, viewportWidth, viewportHeight]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!src || renderWidth <= 0) {
|
if (!src || renderWidth <= 0) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
@@ -90,6 +90,12 @@ const useDetailWorkspace = ({
|
|||||||
};
|
};
|
||||||
}, [detailPanelControlRef, openDetailPanel, closeDetailPanel]);
|
}, [detailPanelControlRef, openDetailPanel, closeDetailPanel]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (detailPanelOpen && activePreviewId) {
|
||||||
|
openDetailPanel(activePreviewId);
|
||||||
|
}
|
||||||
|
}, [detailPanelOpen, activePreviewId, openDetailPanel]);
|
||||||
|
|
||||||
// Prefetch folder ancestors for breadcrumb display
|
// Prefetch folder ancestors for breadcrumb display
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const folderId = detailPanelDocument?.folder_id;
|
const folderId = detailPanelDocument?.folder_id;
|
||||||
|
|||||||
@@ -381,12 +381,15 @@
|
|||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
grid-area: viewport;
|
grid-area: viewport;
|
||||||
background: var(--surface-subtle);
|
|
||||||
padding: 1.5vmin;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
--pdf-viewer-stack-padding: 1.5vmin;
|
--pdf-viewer-stack-padding: 1.5vmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.document-viewer__viewport--light-scheme {
|
||||||
|
/* Force light theme scrollbars (dark handle) for visibility on white content */
|
||||||
|
color-scheme: light;
|
||||||
|
}
|
||||||
|
|
||||||
.document-viewer__object {
|
.document-viewer__object {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border: none;
|
border: none;
|
||||||
|
|||||||
Reference in New Issue
Block a user