feat(admin): add unified navbar component (Phase 2 start)
Created reusable admin navbar component for consistency across all 11 admin pages. COMPONENT: - public/js/components/navbar-admin.js (minified for performance) FEATURES: - Consistent branding and layout - Auto-displays admin name from localStorage - Dashboard back link (except on dashboard itself) - Unified logout behavior - Configurable page title and icon USAGE: <div id="admin-navbar" data-page-title="Page Name" data-page-icon="icon-name"></div> <script src="/js/components/navbar-admin.js"></script> NEXT STEPS (Phase 2 continuation): - Update all 11 admin pages to use this component - Standardize CSS versioning - Verify API endpoints 🤖 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
3525c83dd2
commit
85794f1221
1 changed files with 1 additions and 0 deletions
1
public/js/components/navbar-admin.js
Normal file
1
public/js/components/navbar-admin.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
(function(){const u=JSON.parse(localStorage.getItem('admin_user')||'{}');const n=u.name||u.email||'Admin';const e=document.getElementById('admin-navbar');if(!e)return;const t=e.dataset.pageTitle||'Admin';const i=e.dataset.pageIcon||'default';const d=window.location.pathname.includes('dashboard.html');const icons={default:'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"/>',blog:'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/>',newsletter:'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/>'};const s=icons[i]||icons.default;const b=d?'':`<div class="ml-10"><a href="/admin/dashboard.html" class="px-3 py-2 rounded-md text-sm font-medium text-gray-500 hover:text-gray-700">← Dashboard</a></div>`;e.innerHTML=`<nav class="bg-white border-b border-gray-200"><div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"><div class="flex justify-between h-16"><div class="flex items-center"><div class="flex-shrink-0 flex items-center"><div class="h-8 w-8 bg-blue-600 rounded-lg flex items-center justify-center"><svg class="h-5 w-5 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">${s}</svg></div><span class="ml-3 text-xl font-bold text-gray-900">${t}</span></div>${b}</div><div class="flex items-center space-x-4"><span class="text-sm text-gray-600">${n}</span><button id="admin-logout-btn" class="text-sm font-medium text-gray-700 hover:text-gray-900">Logout</button></div></div></div></nav>`;document.getElementById('admin-logout-btn').addEventListener('click',()=>{localStorage.removeItem('admin_token');localStorage.removeItem('admin_user');window.location.href='/admin/login.html';});})();
|
||||
Loading…
Add table
Reference in a new issue