seniorcoder's picture
code All font end
01297e0 verified
Raw History Blame Contribute Delete
5.44 kB
class CustomSidebar extends HTMLElement {
constructor() {
super();
this.activeTab = this.getAttribute('active') || 'dashboard';
}
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
.sidebar {
width: 250px;
height: 100%;
}
.nav-link {
transition: all 0.2s ease;
}
.nav-link:hover {
background-color: rgba(79, 70, 229, 0.1);
}
.nav-link.active {
background-color: rgba(79, 70, 229, 0.1);
color: rgb(79, 70, 229);
}
.nav-link.active .nav-icon {
color: rgb(79, 70, 229);
}
.nav-icon {
color: rgb(107, 114, 128);
}
@media (max-width: 768px) {
.sidebar {
width: 0;
overflow: hidden;
}
.sidebar.open {
width: 250px;
}
}
</style>
<aside class="sidebar bg-white border-r border-gray-200 overflow-y-auto">
<div class="p-4">
<nav class="mt-6">
<div class="space-y-1">
<a href="/" class="nav-link ${this.activeTab === 'dashboard' ? 'active' : ''} group flex items-center px-3 py-2 text-sm font-medium rounded-md">
<span class="nav-icon mr-3">
<i data-feather="home"></i>
</span>
Dashboard
</a>
<a href="/clients" class="nav-link ${this.activeTab === 'clients' ? 'active' : ''} group flex items-center px-3 py-2 text-sm font-medium rounded-md">
<span class="nav-icon mr-3">
<i data-feather="users"></i>
</span>
Clients
</a>
<a href="/invoices" class="nav-link ${this.activeTab === 'invoices' ? 'active' : ''} group flex items-center px-3 py-2 text-sm font-medium rounded-md">
<span class="nav-icon mr-3">
<i data-feather="file-text"></i>
</span>
Invoices
</a>
<a href="/payments" class="nav-link ${this.activeTab === 'payments' ? 'active' : ''} group flex items-center px-3 py-2 text-sm font-medium rounded-md">
<span class="nav-icon mr-3">
<i data-feather="credit-card"></i>
</span>
Payments
</a>
<a href="/expenses" class="nav-link ${this.activeTab === 'expenses' ? 'active' : ''} group flex items-center px-3 py-2 text-sm font-medium rounded-md">
<span class="nav-icon mr-3">
<i data-feather="dollar-sign"></i>
</span>
Expenses
</a>
<a href="/reports" class="nav-link ${this.activeTab === 'reports' ? 'active' : ''} group flex items-center px-3 py-2 text-sm font-medium rounded-md">
<span class="nav-icon mr-3">
<i data-feather="pie-chart"></i>
</span>
Reports
</a>
</div>
<div class="mt-8">
<h3 class="px-3 text-xs font-semibold text-gray-500 uppercase tracking-wider">Settings</h3>
<div class="mt-1 space-y-1">
<a href="/settings" class="nav-link ${this.activeTab === 'settings' ? 'active' : ''} group flex items-center px-3 py-2 text-sm font-medium rounded-md">
<span class="nav-icon mr-3">
<i data-feather="settings"></i>
</span>
App Settings
</a>
<a href="/account" class="nav-link ${this.activeTab === 'account' ? 'active' : ''} group flex items-center px-3 py-2 text-sm font-medium rounded-md">
<span class="nav-icon mr-3">
<i data-feather="user"></i>
</span>
Account
</a>
</div>
</div>
</nav>
</div>
</aside>
<script>
feather.replace();
</script>
`;
}
}
customElements.define('custom-sidebar', CustomSidebar);