Download components/document-card.js from 5uck1t/docusync-smart-digital-document-hub: direct link, hf CLI and curl.
- Browser
- Download file 3.31 kB
-
https://huggingface.co/spaces/5uck1t/docusync-smart-digital-document-hub/resolve/main/components/document-card.js
- Command line
-
hf download hf://spaces/5uck1t/docusync-smart-digital-document-hub/components/document-card.js
-
curl -L -o document-card.js https://huggingface.co/spaces/5uck1t/docusync-smart-digital-document-hub/resolve/main/components/document-card.js
3.31 kB
| class CustomDocumentCard extends HTMLElement { | |
| connectedCallback() { | |
| const document = JSON.parse(this.getAttribute('document')); | |
| const onClick = this.getAttribute('onClick'); | |
| const onSign = this.getAttribute('onSign'); | |
| const onDelete = this.getAttribute('onDelete'); | |
| const onShare = this.getAttribute('onShare'); | |
| this.attachShadow({ mode: 'open' }); | |
| this.shadowRoot.innerHTML = ` | |
| <style> | |
| .document-card { | |
| transition: all 0.2s ease; | |
| } | |
| .document-actions { | |
| opacity: 0; | |
| transition: opacity 0.2s ease; | |
| } | |
| .document-card:hover .document-actions { | |
| opacity: 1; | |
| } | |
| </style> | |
| <div | |
| class="document-card bg-white rounded-lg border border-gray-200 overflow-hidden cursor-pointer" | |
| onclick="${onClick}()" | |
| > | |
| <div class="relative"> | |
| <img | |
| src="${document.thumbnail}" | |
| alt="${document.name}" | |
| class="w-full h-40 object-cover" | |
| onerror="this.onerror=null; this.src='https://via.placeholder.com/320x240?text=Document'" | |
| > | |
| <div class="absolute top-2 right-2 document-actions flex space-x-1"> | |
| <button | |
| onclick="event.stopPropagation(); ${onSign}()" | |
| class="p-2 bg-white rounded-full shadow-sm text-blue-600 hover:bg-blue-50" | |
| > | |
| <i data-feather="edit-2" class="w-4 h-4"></i> | |
| </button> | |
| <button | |
| onclick="event.stopPropagation(); ${onShare}()" | |
| class="p-2 bg-white rounded-full shadow-sm text-green-600 hover:bg-green-50" | |
| > | |
| <i data-feather="share-2" class="w-4 h-4"></i> | |
| </button> | |
| <button | |
| onclick="event.stopPropagation(); ${onDelete}()" | |
| class="p-2 bg-white rounded-full shadow-sm text-red-600 hover:bg-red-50" | |
| > | |
| <i data-feather="trash-2" class="w-4 h-4"></i> | |
| </button> | |
| </div> | |
| ${document.status === 'pending' ? ` | |
| <div class="absolute top-2 left-2 bg-yellow-100 text-yellow-800 text-xs font-medium px-2 py-0.5 rounded-full"> | |
| Pending | |
| </div> | |
| ` : ''} | |
| ${document.status === 'signed' ? ` | |
| <div class="absolute top-2 left-2 bg-green-100 text-green-800 text-xs font-medium px-2 py-0.5 rounded-full"> | |
| Signed | |
| </div> | |
| ` : ''} | |
| </div> | |
| <div class="p-4"> | |
| <div class="flex items-start"> | |
| <div class="flex-shrink-0 mr-3"> | |
| ${document.type === 'pdf' ? ` | |
| <i data-feather="file-text" class="text-red-500"></i> | |
| ` : ` | |
| <i data-feather="file" class="text-blue-500"></i> | |
| `} | |
| </div> | |
| <div class="flex-1 min-w-0"> | |
| <h3 class="text-sm font-medium text-gray-900 truncate">${document.name}</h3> | |
| <p class="text-xs text-gray-500">${document.size} • ${document.lastModified}</p> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| `; | |
| // Initialize feather icons | |
| feather.replace(); | |
| } | |
| } | |
| customElements.define('custom-document-card', CustomDocumentCard); |