From 0b5020b3d0659b9b2d10a703467d8bc6fbb79a4f Mon Sep 17 00:00:00 2001 From: weeihan Date: Wed, 30 Sep 2026 19:06:17 +0800 Subject: [PATCH] feat(design): restyle shell with flat Modernist sidebar, mobile nav and bell Co-Authored-By: Claude Haiku 4.5 --- app/(protected)/layout.tsx | 2 +- components/layout/sidebar.tsx | 148 +++++++++-------------- components/notifications/bell.tsx | 13 +- tests/components/layout/sidebar.test.tsx | 41 +++++++ 4 files changed, 107 insertions(+), 97 deletions(-) create mode 100644 tests/components/layout/sidebar.test.tsx diff --git a/app/(protected)/layout.tsx b/app/(protected)/layout.tsx index d7cc8be..1978f5b 100644 --- a/app/(protected)/layout.tsx +++ b/app/(protected)/layout.tsx @@ -13,7 +13,7 @@ export default async function ProtectedLayout({ if (!session) redirect('/login') return ( -
+
( - - - -) -const IconList = () => ( - - - -) -const IconCheck = () => ( - - - -) -const IconChart = () => ( - - - -) -const IconSettings = () => ( - - - - -) -const IconUsers = () => ( - - - -) -const IconPlus = () => ( - - - -) -const IconLogout = () => ( - - - -) -const IconUser = () => ( - - - -) +const IconGrid = () => +const IconList = () => +const IconCheck = () => +const IconChart = () => +const IconSettings = () => +const IconUsers = () => +const IconPlus = () => +const IconLogout = () => +const IconUser = () => const NAV_ITEMS: Record = { reporter: [ @@ -94,6 +68,12 @@ const NAV_ITEMS: Record = { ], } +const EXACT_ROOTS = ['/reporter', '/supervisor', '/management', '/capa-owner', '/admin', '/report', '/account'] + +function isActivePath(href: string, pathname: string): boolean { + return EXACT_ROOTS.includes(href) ? pathname === href : pathname.startsWith(href) +} + function initials(name: string): string { return name .split(' ') @@ -107,23 +87,19 @@ function useNavItems(role: string): NavItem[] { return NAV_ITEMS[role] ?? NAV_ITEMS.reporter } -function NavLink({ item, pathname }: { item: NavItem; pathname: string }) { - // Exact match for root-level single-page roles, prefix match otherwise - const exactRoots = ['/reporter', '/supervisor', '/management', '/capa-owner', '/admin', '/report', '/account'] - const isActive = exactRoots.includes(item.href) - ? pathname === item.href - : pathname.startsWith(item.href) +const LINK_BASE = 'flex items-center gap-3 px-3 py-2 text-sm border-l-2 transition-colors' +const LINK_ACTIVE = 'border-accent text-accent-700 font-extrabold bg-accent-100/50' +const LINK_IDLE = 'border-transparent text-ink/70 font-medium hover:bg-ink/7 hover:text-ink' +function NavLink({ item, pathname }: { item: NavItem; pathname: string }) { + const active = isActivePath(item.href, pathname) return ( - {item.icon} + {item.icon} {item.label} ) @@ -143,86 +119,78 @@ export function Sidebar({ role, userName, userEmail }: SidebarProps) { const displayName = userName || userEmail || 'User' const roleLabel = role.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase()) + const accountActive = pathname === '/account' return ( <> {/* Desktop sidebar */} -