Seth0330 commited on
Commit
525e60d
·
verified ·
1 Parent(s): 4ad4050

Create frontend/src/components/ocr/DocumentPreview.jsx

Browse files
frontend/src/components/ocr/DocumentPreview.jsx ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from "react";
2
+ import { motion } from "framer-motion";
3
+ import { FileText, ZoomIn, ZoomOut, RotateCw, Maximize2 } from "lucide-react";
4
+ import { Button } from "@/components/ui/button";
5
+
6
+ export default function DocumentPreview({ file, isProcessing }) {
7
+ // Mock preview - in real app would show actual document
8
+ const mockPages = [1, 2, 3];
9
+
10
+ return (
11
+ <div className="h-full flex flex-col bg-white rounded-2xl border border-slate-200 overflow-hidden">
12
+ {/* Header */}
13
+ <div className="flex items-center justify-between px-5 py-4 border-b border-slate-100">
14
+ <div className="flex items-center gap-3">
15
+ <div className="h-8 w-8 rounded-lg bg-indigo-50 flex items-center justify-center">
16
+ <FileText className="h-4 w-4 text-indigo-600" />
17
+ </div>
18
+ <div>
19
+ <h3 className="font-semibold text-slate-800 text-sm">Document Preview</h3>
20
+ <p className="text-xs text-slate-400">{file?.name || "No file selected"}</p>
21
+ </div>
22
+ </div>
23
+
24
+ {file && (
25
+ <div className="flex items-center gap-1">
26
+ <Button
27
+ variant="ghost"
28
+ size="icon"
29
+ className="h-8 w-8 text-slate-400 hover:text-slate-600"
30
+ >
31
+ <ZoomOut className="h-4 w-4" />
32
+ </Button>
33
+ <span className="text-xs text-slate-500 w-12 text-center">100%</span>
34
+ <Button
35
+ variant="ghost"
36
+ size="icon"
37
+ className="h-8 w-8 text-slate-400 hover:text-slate-600"
38
+ >
39
+ <ZoomIn className="h-4 w-4" />
40
+ </Button>
41
+ <div className="w-px h-4 bg-slate-200 mx-2" />
42
+ <Button
43
+ variant="ghost"
44
+ size="icon"
45
+ className="h-8 w-8 text-slate-400 hover:text-slate-600"
46
+ >
47
+ <RotateCw className="h-4 w-4" />
48
+ </Button>
49
+ <Button
50
+ variant="ghost"
51
+ size="icon"
52
+ className="h-8 w-8 text-slate-400 hover:text-slate-600"
53
+ >
54
+ <Maximize2 className="h-4 w-4" />
55
+ </Button>
56
+ </div>
57
+ )}
58
+ </div>
59
+
60
+ {/* Preview Area */}
61
+ <div className="flex-1 p-6 bg-slate-50/50 overflow-auto">
62
+ {!file ? (
63
+ <div className="h-full flex items-center justify-center">
64
+ <div className="text-center">
65
+ <div className="h-20 w-20 mx-auto rounded-2xl bg-slate-100 flex items-center justify-center mb-4">
66
+ <FileText className="h-10 w-10 text-slate-300" />
67
+ </div>
68
+ <p className="text-slate-400 text-sm">Upload a document to preview</p>
69
+ </div>
70
+ </div>
71
+ ) : (
72
+ <div className="space-y-4">
73
+ {mockPages.map((page, index) => (
74
+ <motion.div
75
+ key={page}
76
+ initial={{ opacity: 0, y: 20 }}
77
+ animate={{ opacity: 1, y: 0 }}
78
+ transition={{ delay: index * 0.1 }}
79
+ className="relative bg-white rounded-xl shadow-sm border border-slate-200 aspect-[8.5/11] overflow-hidden"
80
+ >
81
+ {/* Mock document content */}
82
+ <div className="absolute inset-0 p-8">
83
+ {/* Header simulation */}
84
+ <div className="flex items-center gap-4 mb-8">
85
+ <div className="h-12 w-12 rounded-lg bg-slate-100" />
86
+ <div className="space-y-2">
87
+ <div className="h-3 w-32 bg-slate-100 rounded" />
88
+ <div className="h-2 w-24 bg-slate-50 rounded" />
89
+ </div>
90
+ </div>
91
+
92
+ {/* Text lines simulation */}
93
+ <div className="space-y-3">
94
+ {[...Array(12)].map((_, i) => (
95
+ <div
96
+ key={i}
97
+ className="h-2 bg-slate-100 rounded"
98
+ style={{ width: `${Math.random() * 40 + 60}%` }}
99
+ />
100
+ ))}
101
+ </div>
102
+
103
+ {/* Table simulation */}
104
+ <div className="mt-6 border border-slate-100 rounded-lg overflow-hidden">
105
+ {[...Array(4)].map((_, i) => (
106
+ <div key={i} className="flex border-b border-slate-50 last:border-0">
107
+ {[...Array(3)].map((_, j) => (
108
+ <div
109
+ key={j}
110
+ className="flex-1 p-3 border-r border-slate-50 last:border-0"
111
+ >
112
+ <div className="h-2 bg-slate-100 rounded w-3/4" />
113
+ </div>
114
+ ))}
115
+ </div>
116
+ ))}
117
+ </div>
118
+ </div>
119
+
120
+ {/* Processing overlay */}
121
+ {isProcessing && (
122
+ <motion.div
123
+ initial={{ opacity: 0 }}
124
+ animate={{ opacity: 1 }}
125
+ className="absolute inset-0 bg-indigo-600/5 backdrop-blur-[1px]"
126
+ >
127
+ <motion.div
128
+ initial={{ top: 0 }}
129
+ animate={{ top: "100%" }}
130
+ transition={{
131
+ duration: 2,
132
+ repeat: Infinity,
133
+ ease: "linear",
134
+ }}
135
+ className="absolute left-0 right-0 h-1 bg-gradient-to-r from-transparent via-indigo-500 to-transparent"
136
+ />
137
+ </motion.div>
138
+ )}
139
+
140
+ {/* Page number */}
141
+ <div className="absolute bottom-3 right-3 text-xs text-slate-400 bg-white/90 px-2 py-1 rounded">
142
+ Page {page}
143
+ </div>
144
+ </motion.div>
145
+ ))}
146
+ </div>
147
+ )}
148
+ </div>
149
+ </div>
150
+ );
151
+ }