cosmo/frontend/src/components/Header.tsx

75 lines
2.4 KiB
TypeScript
Raw Normal View History

2025-11-30 02:43:47 +00:00
import { UserAuth } from './UserAuth';
interface HeaderProps {
selectedBodyName?: string;
bodyCount: number;
2025-12-03 06:26:53 +00:00
cutoffDate?: Date | null;
2025-11-30 02:43:47 +00:00
user?: any;
onOpenAuth?: () => void;
onLogout?: () => void;
onNavigateToAdmin?: () => void;
}
2025-12-03 06:26:53 +00:00
export function Header({
selectedBodyName,
2025-11-30 02:43:47 +00:00
bodyCount,
2025-12-03 06:26:53 +00:00
cutoffDate,
2025-11-30 02:43:47 +00:00
user,
onOpenAuth,
onLogout,
onNavigateToAdmin
}: HeaderProps) {
2025-12-03 06:26:53 +00:00
// Format cutoff date as YYYY/MM/DD
const formattedCutoffDate = cutoffDate
? `${cutoffDate.getFullYear()}/${String(cutoffDate.getMonth() + 1).padStart(2, '0')}/${String(cutoffDate.getDate()).padStart(2, '0')}`
: '';
2025-11-29 15:10:00 +00:00
return (
2025-11-29 16:58:58 +00:00
<header className="absolute top-0 left-0 right-0 z-50 pointer-events-none">
2025-11-30 02:43:47 +00:00
<div className="px-6 py-4 bg-gradient-to-b from-black/90 via-black/60 to-transparent flex items-start justify-between">
{/* Left: Branding */}
2025-11-29 16:58:58 +00:00
<div className="flex items-center gap-4 pointer-events-auto inline-flex">
<div className="flex items-center gap-3">
2025-12-02 11:20:33 +00:00
<span className="text-4xl">🌌</span>
2025-11-29 16:58:58 +00:00
<div>
2025-12-03 06:26:53 +00:00
<div className="flex items-baseline gap-2">
<h1 className="text-2xl font-bold text-white tracking-tight drop-shadow-md">Cosmo</h1>
{formattedCutoffDate && (
<span className="text-xs text-gray-400 font-mono">
2025-12-03 07:13:31 +00:00
({formattedCutoffDate})
2025-12-03 06:26:53 +00:00
</span>
)}
</div>
2025-11-29 16:58:58 +00:00
<p className="text-xs text-gray-400 font-medium tracking-wide">DEEP SPACE EXPLORER</p>
2025-11-29 15:10:00 +00:00
</div>
</div>
2025-11-29 16:58:58 +00:00
{/* Status Info */}
<div className="ml-4 px-3 py-1 bg-white/10 backdrop-blur-md rounded-full border border-white/10">
<p className="text-xs text-gray-300">
{selectedBodyName ? (
<>
<span className="text-cyan-400 animate-pulse"></span> : <span className="text-white font-bold ml-1">{selectedBodyName}</span>
</>
) : (
<>
<span className="text-green-400"></span> {bodyCount} 线
</>
2025-11-29 15:10:00 +00:00
)}
2025-11-29 16:58:58 +00:00
</p>
2025-11-29 15:10:00 +00:00
</div>
</div>
2025-11-30 02:43:47 +00:00
{/* Right: User Auth */}
{onOpenAuth && (
<UserAuth
user={user}
onOpenAuth={onOpenAuth}
onLogout={onLogout!}
onNavigateToAdmin={onNavigateToAdmin!}
/>
)}
2025-11-29 16:58:58 +00:00
</div>
</header>
2025-11-29 15:10:00 +00:00
);
2025-11-29 16:58:58 +00:00
}