eriksaether's picture
Create an online chat forum
e11ebc8 verified
Raw History Blame Contribute Delete
4.08 kB
class CustomSidebar extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
.sidebar-item:hover {
background-color: #f3f4f6;
}
.sidebar-item.active {
background-color: #e5e7eb;
border-left: 4px solid #4f46e5;
}
.category-badge {
font-size: 0.7rem;
}
</style>
<aside class="w-full lg:w-64">
<div class="bg-white rounded-xl shadow-md p-4 sticky top-8">
<h3 class="font-bold text-gray-800 mb-4 flex items-center gap-2">
<i data-feather="hash" class="w-5 h-5 text-gray-500"></i>
Categories
</h3>
<nav class="space-y-1">
<a href="#" class="sidebar-item flex items-center justify-between px-3 py-2 rounded-lg">
<span class="text-gray-700">All Discussions</span>
<span class="bg-gray-100 text-gray-600 px-2 py-0.5 rounded-full text-xs category-badge">128</span>
</a>
<a href="#" class="sidebar-item active flex items-center justify-between px-3 py-2 rounded-lg">
<span class="text-gray-700">Technology</span>
<span class="bg-blue-100 text-blue-600 px-2 py-0.5 rounded-full text-xs category-badge">42</span>
</a>
<a href="#" class="sidebar-item flex items-center justify-between px-3 py-2 rounded-lg">
<span class="text-gray-700">Work & Career</span>
<span class="bg-green-100 text-green-600 px-2 py-0.5 rounded-full text-xs category-badge">28</span>
</a>
<a href="#" class="sidebar-item flex items-center justify-between px-3 py-2 rounded-lg">
<span class="text-gray-700">Lifestyle</span>
<span class="bg-purple-100 text-purple-600 px-2 py-0.5 rounded-full text-xs category-badge">19</span>
</a>
<a href="#" class="sidebar-item flex items-center justify-between px-3 py-2 rounded-lg">
<span class="text-gray-700">Entertainment</span>
<span class="bg-yellow-100 text-yellow-600 px-2 py-0.5 rounded-full text-xs category-badge">15</span>
</a>
<a href="#" class="sidebar-item flex items-center justify-between px-3 py-2 rounded-lg">
<span class="text-gray-700">Health & Fitness</span>
<span class="bg-red-100 text-red-600 px-2 py-0.5 rounded-full text-xs category-badge">12</span>
</a>
<a href="#" class="sidebar-item flex items-center justify-between px-3 py-2 rounded-lg">
<span class="text-gray-700">Education</span>
<span class="bg-indigo-100 text-indigo-600 px-2 py-0.5 rounded-full text-xs category-badge">8</span>
</a>
</nav>
<div class="mt-6 pt-4 border-t border-gray-200">
<h3 class="font-bold text-gray-800 mb-3 flex items-center gap-2">
<i data-feather="users" class="w-5 h-5 text-gray-500"></i>
Online Now
</h3>
<div class="flex flex-wrap gap-2">
<div class="w-8 h-8 rounded-full bg-blue-200 flex items-center justify-center relative">
<span class="w-2 h-2 bg-green-500 rounded-full absolute bottom-0 right-0 border border-white"></span