Spaces:
Running
Running
File size: 3,393 Bytes
00bd445 37bf153 00bd445 37bf153 00bd445 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | export default function DocumentViewer({ document, onClose }) {
if (!document) {
return (
<div className="card h-full flex flex-col items-center justify-center text-center p-12 border-dashed bg-dark-800/30">
<div className="w-20 h-20 bg-dark-800 rounded-full flex items-center justify-center mb-6">
<svg className="w-10 h-10 text-dark-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
</svg>
</div>
<h3 className="text-xl font-medium text-white mb-2">Select a document</h3>
<p className="text-dark-400">Click on a search result to view the full transcript.</p>
</div>
)
}
const tags = document.tags?.split(',').map(t => t.trim()) || []
return (
<div className="card h-full flex flex-col bg-dark-800 overflow-hidden">
<div className="p-6 border-b border-dark-700 flex justify-between items-start bg-dark-800">
<div>
<h2 className="text-2xl font-bold text-white mb-2">{document.title}</h2>
<div className="flex items-center space-x-4 text-sm text-dark-400">
<span className="flex items-center">
<svg className="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" />
</svg>
{document.date || 'Unknown Date'}
</span>
{document.source_url && (
<a href={document.source_url} target="_blank" rel="noopener noreferrer" className="text-primary-400 hover:underline flex items-center">
<svg className="w-4 h-4 mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
</svg>
Source
</a>
)}
</div>
</div>
<button onClick={onClose} className="text-dark-400 hover:text-white md:hidden">
<svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
<div className="flex-1 overflow-y-auto p-6">
<div className="prose prose-invert prose-blue max-w-none">
<div className="whitespace-pre-wrap text-dark-300 leading-relaxed">
{document.content}
</div>
</div>
</div>
<div className="p-4 border-t border-dark-700 bg-dark-800">
<div className="flex flex-wrap gap-2">
{tags.map((tag, i) => (
<span key={i} className="text-xs font-medium text-primary-300 bg-primary-900/30 px-3 py-1 rounded-full border border-primary-500/30">
#{tag}
</span>
))}
</div>
</div>
</div>
)
} |