2026-02-02 20:34:35 +00:00
|
|
|
/**
|
|
|
|
|
* Navigation Component
|
2026-05-18 15:26:01 +01:00
|
|
|
* Top header nav for desktop; bottom tab bar for mobile (≤640px).
|
2026-02-02 20:34:35 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import Link from 'next/link';
|
|
|
|
|
import { usePathname } from 'next/navigation';
|
|
|
|
|
import { useComparison } from '@/hooks/useComparison';
|
|
|
|
|
import styles from './Navigation.module.css';
|
|
|
|
|
|
2026-05-18 15:26:01 +01:00
|
|
|
type IconProps = { className?: string };
|
|
|
|
|
|
|
|
|
|
const SearchIcon = ({ className }: IconProps) => (
|
|
|
|
|
<svg className={className} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
|
|
|
<circle cx="11" cy="11" r="7" />
|
|
|
|
|
<path d="m20 20-3.5-3.5" />
|
|
|
|
|
</svg>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const CompareIcon = ({ className }: IconProps) => (
|
|
|
|
|
<svg className={className} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
|
|
|
<path d="M4 7h13l-3-3" />
|
|
|
|
|
<path d="M20 17H7l3 3" />
|
|
|
|
|
</svg>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const RankingsIcon = ({ className }: IconProps) => (
|
|
|
|
|
<svg className={className} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
|
|
|
<path d="M7 21V11" />
|
|
|
|
|
<path d="M12 21V4" />
|
|
|
|
|
<path d="M17 21v-7" />
|
|
|
|
|
</svg>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const AdmissionsIcon = ({ className }: IconProps) => (
|
|
|
|
|
<svg className={className} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
|
|
|
<rect x="3" y="5" width="18" height="16" rx="2" />
|
|
|
|
|
<path d="M3 10h18M8 3v4M16 3v4" />
|
|
|
|
|
</svg>
|
|
|
|
|
);
|
|
|
|
|
|
2026-02-02 20:34:35 +00:00
|
|
|
export function Navigation() {
|
|
|
|
|
const pathname = usePathname();
|
|
|
|
|
const { selectedSchools } = useComparison();
|
|
|
|
|
|
|
|
|
|
const isActive = (path: string) => {
|
2026-05-18 15:26:01 +01:00
|
|
|
if (path === '/') return pathname === '/';
|
2026-02-02 20:34:35 +00:00
|
|
|
return pathname.startsWith(path);
|
|
|
|
|
};
|
|
|
|
|
|
2026-05-18 15:26:01 +01:00
|
|
|
const items = [
|
|
|
|
|
{ href: '/', label: 'Search', Icon: SearchIcon },
|
|
|
|
|
{ href: '/compare', label: 'Compare', Icon: CompareIcon },
|
|
|
|
|
{ href: '/rankings', label: 'Rankings', Icon: RankingsIcon },
|
|
|
|
|
{ href: '/admissions', label: 'Admissions', Icon: AdmissionsIcon },
|
|
|
|
|
] as const;
|
2026-02-02 20:34:35 +00:00
|
|
|
|
2026-05-18 15:26:01 +01:00
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<header className={styles.header}>
|
|
|
|
|
<div className={styles.container}>
|
|
|
|
|
<Link href="/" className={styles.logo} aria-label="SchoolCompare home">
|
|
|
|
|
<span className={styles.logoIcon}>
|
|
|
|
|
<svg viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
|
|
|
<circle cx="20" cy="20" r="18" stroke="currentColor" strokeWidth="2" />
|
|
|
|
|
<path d="M20 6L20 34M8 14L32 14M6 20L34 20M8 26L32 26" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
|
|
|
|
|
<circle cx="20" cy="20" r="3" fill="currentColor" />
|
|
|
|
|
</svg>
|
|
|
|
|
</span>
|
|
|
|
|
<span className={styles.logoText}>SchoolCompare</span>
|
2026-03-25 20:28:03 +00:00
|
|
|
</Link>
|
2026-05-18 15:26:01 +01:00
|
|
|
|
|
|
|
|
<nav className={styles.nav} aria-label="Main navigation">
|
|
|
|
|
{items.map(({ href, label }) => {
|
|
|
|
|
const active = isActive(href);
|
|
|
|
|
const showBadge = href === '/compare' && selectedSchools.length > 0;
|
|
|
|
|
return (
|
|
|
|
|
<Link
|
|
|
|
|
key={href}
|
|
|
|
|
href={href}
|
|
|
|
|
className={active ? `${styles.navLink} ${styles.active}` : styles.navLink}
|
|
|
|
|
aria-current={active ? 'page' : undefined}
|
|
|
|
|
>
|
|
|
|
|
{label}
|
|
|
|
|
{showBadge && (
|
|
|
|
|
<span key={selectedSchools.length} className={styles.badge}>
|
|
|
|
|
{selectedSchools.length}
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
</Link>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</nav>
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
|
|
|
|
|
|
|
|
|
<nav className={styles.bottomBar} aria-label="Main navigation">
|
|
|
|
|
{items.map(({ href, label, Icon }) => {
|
|
|
|
|
const active = isActive(href);
|
|
|
|
|
const showBadge = href === '/compare' && selectedSchools.length > 0;
|
|
|
|
|
return (
|
|
|
|
|
<Link
|
|
|
|
|
key={href}
|
|
|
|
|
href={href}
|
|
|
|
|
className={active ? `${styles.tab} ${styles.tabActive}` : styles.tab}
|
|
|
|
|
aria-current={active ? 'page' : undefined}
|
|
|
|
|
>
|
|
|
|
|
<span className={styles.tabIconWrap}>
|
|
|
|
|
<Icon className={styles.tabIcon} />
|
|
|
|
|
{showBadge && (
|
|
|
|
|
<span key={selectedSchools.length} className={styles.tabBadge} aria-label={`${selectedSchools.length} selected`}>
|
|
|
|
|
{selectedSchools.length}
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
2026-02-03 14:26:23 +00:00
|
|
|
</span>
|
2026-05-18 15:26:01 +01:00
|
|
|
<span className={styles.tabLabel}>{label}</span>
|
|
|
|
|
</Link>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</nav>
|
|
|
|
|
</>
|
2026-02-02 20:34:35 +00:00
|
|
|
);
|
|
|
|
|
}
|