'use client'; import { featureFlags } from '@workspace/backend/config/featureFlags'; import Link from 'next/link'; import { useMemo } from 'react'; import { Button } from '@/components/ui/button'; import { UserMenu } from '@/components/UserMenu'; import { useAuthState } from '@/modules/auth/AuthProvider'; import { useHeaderPortal } from '@/modules/header/HeaderPortalProvider'; // Brand label shown in the header. Keep as a single literal: scripts/branding.ts // rewrites `const APP_SHORT_NAME = '...';` during branding setup. const APP_SHORT_NAME = 'Chatroom'; /** * Main navigation header component with authentication state handling. * Implements Industrial Design System styling with portal support. */ export function Navigation() { const authState = useAuthState(); const portalContent = useHeaderPortal(); /** * Memoized authentication status to prevent unnecessary re-renders. */ const authStatus = useMemo(() => { const isAuthenticated = authState?.state === 'authenticated'; const isLoading = authState === undefined; return { isAuthenticated, isLoading }; }, [authState]); const hideAppTitle = portalContent.hideAppTitle ?? false; const hideUserMenu = portalContent.hideUserMenu ?? false; return (
{ if (e.target === e.currentTarget || e.currentTarget.contains(e.target as Node)) { e.currentTarget.focus(); } }} className="relative z-50 w-full shrink-0 border-b-2 border-border/15 bg-background/95 dark:bg-zinc-950/95 backdrop-blur-xl supports-[backdrop-filter]:bg-background/80 dark:supports-[backdrop-filter]:bg-zinc-950/80 outline-none focus:outline-none focus-visible:outline-none" >
{/* Left section: Logo and portal content */}
{!hideAppTitle && ( {APP_SHORT_NAME} )} {/* Portal content injection point */} {portalContent.left}
{/* Center section: Portal content (absolutely centered; visible on all breakpoints) */} {portalContent.center && (
{portalContent.center}
)} {/* Right section: Portal content and auth */}
{portalContent.right} {!hideUserMenu && _renderAuthSection(authStatus.isLoading, authStatus.isAuthenticated)}
); } /** * Renders the appropriate authentication section based on user state. * Uses Industrial Design System styling. */ function _renderAuthSection(isLoading: boolean, isAuthenticated: boolean) { if (isLoading) { return null; } if (isAuthenticated) { return ; } if (!featureFlags.disableLogin) { return ( ); } return null; }