class CustomAdminSidebar extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = ` `; // Mobile sidebar toggle const sidebarToggle = document.querySelector('custom-admin-navbar').shadowRoot.getElementById('sidebar-toggle'); const sidebar = this.shadowRoot.querySelector('.sidebar'); sidebarToggle?.addEventListener('click', () => { sidebar.classList.toggle('open'); }); // Navigation links const navLinks = this.shadowRoot.querySelectorAll('.sidebar-link'); navLinks.forEach(link => { link.addEventListener('click', (e) => { e.preventDefault(); const section = link.getAttribute('data-section'); // Remove active class from all links navLinks.forEach(l => l.classList.remove('active')); // Add active class to clicked link link.classList.add('active'); // Load the appropriate content switch(section) { case 'projects': loadProjectsManagement(); break; case 'clients': loadClientsManagement(); break; case 'contacts': loadContactResponses(); break; case 'subscribers': loadSubscribers(); break; default: adminContent.innerHTML = `

Welcome to Admin Panel

Select a section from the sidebar to manage content.

`; break; } // Close mobile sidebar if open if (sidebar.classList.contains('open')) { sidebar.classList.remove('open'); } }); }); } } customElements.define('custom-admin-sidebar', CustomAdminSidebar);