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
4.13 kB
class CustomSidebar extends HTMLElement {
connectedCallback() {
const currentFolder = this.getAttribute('currentFolder') || 'my-documents';
const onChangeFolder = this.getAttribute('onChangeFolder');
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
.sidebar-item {
transition: all 0.2s ease;
}
.sidebar-item:hover {
background-color: rgba(66, 133, 244, 0.1);
}
.sidebar-item.active {
background-color: rgba(66, 133, 244, 0.1);
color: #4285F4;
font-weight: 500;
}
.sidebar-item.active svg {
color: #4285F4;
}
</style>
<aside class="w-64 h-full bg-white border-r border-gray-200 overflow-y-auto">
<div class="p-4">
<button class="w-full flex items-center justify-center space-x-2 bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg mb-6">
<i data-feather="plus" class="w-4 h-4"></i>
<span>New Document</span>
</button>
<nav>
<ul class="space-y-1">
<li>
<a
href="#"
onclick="${onChangeFolder}('my-documents')"
class="sidebar-item flex items-center px-4 py-2 text-sm rounded-lg ${currentFolder === 'my-documents' ? 'active' : ''}"
>
<i data-feather="folder" class="w-4 h-4 mr-3"></i>
My Documents
</a>
</li>
<li>
<a
href="#"
onclick="${onChangeFolder}('shared')"
class="sidebar-item flex items-center px-4 py-2 text-sm rounded-lg ${currentFolder === 'shared' ? 'active' : ''}"
>
<i data-feather="users" class="w-4 h-4 mr-3"></i>
Shared with Me
</a>
</li>
<li>
<a
href="#"
onclick="${onChangeFolder}('pending')"
class="sidebar-item flex items-center px-4 py-2 text-sm rounded-lg ${currentFolder === 'pending' ? 'active' : ''}"
>
<i data-feather="edit" class="w-4 h-4 mr-3"></i>
Pending Signatures
<span class="ml-auto bg-red-100 text-red-800 text-xs font-medium px-2 py-0.5 rounded-full">3</span>
</a>
</li>
<li>
<a
href="#"
onclick="${onChangeFolder}('completed')"
class="sidebar-item flex items-center px-4 py-2 text-sm rounded-lg ${currentFolder === 'completed' ? 'active' : ''}"
>
<i data-feather="check-circle" class="w-4 h-4 mr-3"></i>
Completed
</a>
</li>
<li>
<a
href="#"
onclick="${onChangeFolder}('trash')"
class="sidebar-item flex items-center px-4 py-2 text-sm rounded-lg ${currentFolder === 'trash' ? 'active' : ''}"
>
<i data-feather="trash-2" class="w-4 h-4 mr-3"></i>
Trash
</a>
</li>
</ul>
</nav>
<div class="mt-8">
<h3 class="text-xs font-semibold text-gray-500 uppercase tracking-wider px-4 py-2">Storage</h3>
<div class="px-4 py-2">
<div class="flex justify-between text-sm mb-1">
<span class="text-gray-600">15.2 GB of 100 GB used</span>
<span class="text-gray-600">15%</span>
</div>
<div class="w-full bg-gray-200 rounded-full h-2">
<div class="bg-blue-600 h-2 rounded-full" style="width: 15%"></div>
</div>
</div>
</div>
</div>
</aside>
`;
// Initialize feather icons
feather.replace();
}
}
customElements.define('custom-sidebar', CustomSidebar);