5uck1t's picture
Build a modern, production-ready web application that visually and functionally resembles Google Drive, but is specialized for document management, document collaboration, and document signing.
fcf32b9 verified
Raw History Blame Contribute Delete
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);