tractatus/public/js/components/navbar-admin.js
TheFlow 8667088c5f feat(admin): Phase 2 - standardize admin UI with unified navbar component
SUMMARY:
Completed Phase 2 of admin UI overhaul: Created unified navbar component
for simple pages, standardized CSS versioning across all pages, and fixed
broken navigation. Pragmatic approach preserves valuable cross-page navigation
while ensuring consistency.

CHANGES - Simple Pages (Unified Navbar Component):
- newsletter-management.html: Replaced custom navbar with component
- hooks-dashboard.html: Replaced custom navbar with component
- audit-analytics.html: Fixed wrong navbar (was using public site component)

CHANGES - Complex Pages (Standardized CSS Only):
- case-moderation.html: Added CSS version v=1759833751
- media-triage.html: Added CSS version v=1759833751
- project-manager.html: Updated CSS version to v=1759833751
- rule-manager.html: Updated CSS version to v=1759833751
(These pages retained custom navbars to preserve cross-page navigation UX)

COMPONENT ENHANCEMENTS:
- navbar-admin.js: Added 'hooks' icon for Framework Hooks Dashboard
- Newsletter management JS: Removed manual admin-name and logout handling

CSS STANDARDIZATION:
Target version: /css/tailwind.css?v=1759833751
- 7 pages now use standardized version (was 3 different versions + missing)

RESULTS:
- All admin pages now have consistent navbar styling
- Simple pages use unified component (3 pages)
- Complex pages use standardized custom navbars (6 pages)
- All pages have correct CSS versioning
- audit-analytics.html fixed (was using wrong component)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-20 21:51:09 +13:00

1 line
2.2 KiB
JavaScript

(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"/>',hooks:'<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"/>'};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';});})();