@@ -3,21 +3,27 @@ import { useCaptureCapability } from '@embedpdf/plugin-capture/preact';
33import { useState , useRef , useEffect } from 'preact/hooks' ;
44import { Dialog } from './ui/dialog' ;
55import { Button } from './ui/button' ;
6+ import { useTranslations } from '@embedpdf/plugin-i18n/preact' ;
67
7- interface CaptureData {
8+ export interface CaptureData {
89 pageIndex : number ;
910 rect : any ;
1011 blob : Blob ;
1112}
1213
13- export function Capture ( ) {
14+ export interface CaptureProps {
15+ documentId : string ;
16+ }
17+
18+ export function Capture ( { documentId } : CaptureProps ) {
1419 const { provides : capture } = useCaptureCapability ( ) ;
1520 const [ open , setOpen ] = useState ( false ) ;
1621 const [ captureData , setCaptureData ] = useState < CaptureData | null > ( null ) ;
1722 const [ previewUrl , setPreviewUrl ] = useState < string | null > ( null ) ;
1823 const [ downloadUrl , setDownloadUrl ] = useState < string | null > ( null ) ;
1924 const urlRef = useRef < string | null > ( null ) ;
2025 const downloadLinkRef = useRef < HTMLAnchorElement > ( null ) ;
26+ const { translate } = useTranslations ( documentId ) ;
2127
2228 const handleClose = ( ) => {
2329 // Clean up object URLs
@@ -73,7 +79,12 @@ export function Capture() {
7379
7480 return (
7581 < >
76- < Dialog open = { open } onClose = { handleClose } title = "Capture PDF Area" >
82+ < Dialog
83+ open = { open }
84+ onClose = { handleClose }
85+ title = { translate ( 'capture.title' ) }
86+ className = "md:w-[48rem]"
87+ >
7788 < div className = "space-y-6" >
7889 < div className = "flex justify-center" >
7990 { previewUrl && (
@@ -91,19 +102,19 @@ export function Capture() {
91102 />
92103 ) }
93104 </ div >
94- < div className = "flex justify-end space-x-3 border-t border-gray-200 pt-4" >
105+ < div className = "border-border-subtle flex justify-end space-x-3 border-t pt-4" >
95106 < Button
96107 onClick = { handleClose }
97- className = "rounded-md border border-gray-300 bg-white px-4 py-2 text-sm text-gray-700 hover:bg-gray -50"
108+ className = "border- border-default bg-bg-surface text-fg-secondary hover: bg-interactive-hover rounded-md border px-4 py-2 text-sm disabled:cursor-not-allowed disabled:opacity -50"
98109 >
99- Cancel
110+ { translate ( 'capture.cancel' ) }
100111 </ Button >
101112 < Button
102113 onClick = { handleDownload }
103114 disabled = { ! captureData }
104- className = "rounded-md border border-transparent bg-blue-600 px-4 py-2 text-sm text-white hover:!bg-blue-700 disabled:cursor-not-allowed disabled:opacity-50"
115+ className = "bg-accent text-fg-on-accent hover:!bg-accent-hover flex items-center space-x-2 rounded-md border border-transparent px-4 py-2 text-sm disabled:cursor-not-allowed disabled:opacity-50"
105116 >
106- Download
117+ { translate ( 'capture.download' ) }
107118 </ Button >
108119 </ div >
109120 </ div >
0 commit comments