Rewrite datasheet PDF sheet overlay.
Right-side Sheet still mounts PdfViewerPanel only while open; shadcn Sheet stays imported.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
"use client";
|
||||
|
||||
import { Sheet, SheetContent, SheetTitle } from "@/components/ui/sheet";
|
||||
import { PdfViewerPanel } from "./pdf-viewer-panel";
|
||||
|
||||
export type PdfViewerSheetProps = {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
projectId: string;
|
||||
mpn: string | null;
|
||||
initialPage: number;
|
||||
highlightQuote?: string;
|
||||
};
|
||||
|
||||
/** Right-side datasheet drawer; mounts the PDF panel only while open. */
|
||||
export function PdfViewerSheet({
|
||||
open,
|
||||
onOpenChange,
|
||||
projectId,
|
||||
mpn,
|
||||
initialPage,
|
||||
highlightQuote,
|
||||
}: PdfViewerSheetProps) {
|
||||
if (!mpn) return null;
|
||||
return (
|
||||
<Sheet open={open} onOpenChange={onOpenChange}>
|
||||
<SheetContent
|
||||
side="right"
|
||||
className="sm:max-w-none p-0 flex flex-col"
|
||||
style={{ maxWidth: "none", width: "fit-content" }}
|
||||
>
|
||||
<SheetTitle className="sr-only">{mpn}</SheetTitle>
|
||||
{open ? (
|
||||
<PdfViewerPanel
|
||||
projectId={projectId}
|
||||
mpn={mpn}
|
||||
initialPage={initialPage}
|
||||
highlightQuote={highlightQuote}
|
||||
/>
|
||||
) : null}
|
||||
</SheetContent>
|
||||
</Sheet>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
"""Datasheet PDF sheet overlay lives under periscope/src."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SRC = ROOT / "periscope" / "src" / "frontend" / "src"
|
||||
|
||||
|
||||
def test_pdf_sheet_is_src():
|
||||
path = SRC / "components/pdf/pdf-viewer-sheet.tsx"
|
||||
text = path.read_text(encoding="utf-8")
|
||||
assert "Native Periscope overlay" not in text[:400]
|
||||
assert "export function PdfViewerSheet" in text
|
||||
assert "PdfViewerPanel" in text
|
||||
assert 'side="right"' in text
|
||||
assert "sr-only" in text
|
||||
Reference in New Issue
Block a user