TTime/frontend/src/Components/Header.tsx

55 lines
1.4 KiB
TypeScript
Raw Normal View History

2024-03-07 11:48:34 +01:00
import { useState } from "react";
import { Link } from "react-router-dom";
2024-03-07 11:48:34 +01:00
function Header({ username }: { username: string }): JSX.Element {
const [isOpen, setIsOpen] = useState(false);
2024-03-07 11:48:34 +01:00
const handleLogout = (): void => {
// Add any logout logic here
};
return (
2024-03-07 11:48:34 +01:00
<header
className="fixed top-0 left-0 right-0 border-[1.75px] border-black text-black p-3 pl-5 flex items-center justify-between bg-cover"
style={{ backgroundImage: `url('src/assets/1.jpg')` }}
>
<Link to="/your-projects">
2024-03-07 11:48:34 +01:00
<img
src="/src/assets/TTIMElogo.png"
alt="TTIME Logo"
className="w-11 h-14 cursor-pointer"
/>
</Link>
2024-03-07 11:48:34 +01:00
<div
className="relative"
2024-03-07 11:48:34 +01:00
onMouseEnter={() => {
setIsOpen(true);
}}
onMouseLeave={() => {
setIsOpen(false);
}}
>
<button className="mr-4 underline font-bold text-white">
{username}
</button>
2024-03-07 11:48:34 +01:00
{isOpen && (
<div className="absolute right-0 bg-white border rounded shadow-lg">
<Link to="/">
2024-03-07 11:48:34 +01:00
<button
onClick={handleLogout}
className="block px-2 py-1 text-black hover:bg-gray-200"
>
Logout
</button>
</Link>
</div>
)}
</div>
</header>
);
2024-03-07 11:48:34 +01:00
}
export default Header;