Spaces:
Running
Running
Download components/DocumentViewer.js from powerllm/anycoder-cf48624d: direct link, hf CLI and curl.
- Browser
- Download file 3.39 kB
-
https://huggingface.co/spaces/powerllm/anycoder-cf48624d/resolve/main/components/DocumentViewer.js
- Command line
-
hf download hf://spaces/powerllm/anycoder-cf48624d/components/DocumentViewer.js
-
curl -L -o DocumentViewer.js https://huggingface.co/spaces/powerllm/anycoder-cf48624d/resolve/main/components/DocumentViewer.js
3.39 kB
| 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> | |
| ) | |
| } |