Spaces:
Running
Running
File size: 1,775 Bytes
6c6fa5f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
import React from 'react';
import styled from 'styled-components';
import { Link } from 'react-router-dom';
import ThemeToggle from '../UI/ThemeToggle';
import { useAuth } from '../../hooks/useAuth';
const HeaderContainer = styled.header`
background: ${({ theme }) => theme.colors.primary};
color: white;
padding: 1rem 2rem;
box-shadow: ${({ theme }) => theme.shadows.medium};
`;
const Nav = styled.nav`
display: flex;
justify-content: space-between;
align-items: center;
max-width: 1200px;
margin: 0 auto;
`;
const Logo = styled(Link)`
font-size: ${({ theme }) => theme.fontSizes.xxlarge};
font-weight: bold;
color: white;
text-decoration: none;
font-family: ${({ theme }) => theme.fonts.secondary};
`;
const NavLinks = styled.div`
display: flex;
gap: 2rem;
align-items: center;
`;
const NavLink = styled(Link)`
color: white;
text-decoration: none;
font-weight: 500;
transition: opacity 0.3s ease;
&:hover {
opacity: 0.8;
}
`;
const Header = () => {
const { isAuthenticated } = useAuth();
return (
<HeaderContainer>
<Nav>
<Logo to="/">EnlightenQalb</Logo>
<NavLinks>
<NavLink to="/">Home</NavLink>
{isAuthenticated && <NavLink to="/dashboard">Dashboard</NavLink>}
<NavLink to="/about">About</NavLink>
<ThemeToggle />
{isAuthenticated ? <LogoutButton /> : <LoginButton />}
</NavLinks>
</Nav>
</HeaderContainer>
);
};
const LoginButton = () => (
<NavLink to="/login">Login</NavLink>
);
const LogoutButton = () => {
const { logout } = useAuth();
return (
<NavLink as="button" onClick={logout} style={{ background: 'none', border: 'none' }}>
Logout
</NavLink>
);
};
export default Header; |