Skip to content

Commit e78ed87

Browse files
Implement shared top nav
- Added NavBar component and integrated it across Home, People, and Projects pages. - Replaced page-specific navs with the shared NavBar to ensure consistency. - Adjusted landing page to render NavBar in the top-right with dark variant; updated People page header to use the shared NavBar; updated Research and Index pages accordingly. X-Lovable-Edit-ID: edt-49f916b4-966c-4cce-853a-88e5fb1ac654
2 parents 797dfb8 + 7ddfde3 commit e78ed87

4 files changed

Lines changed: 54 additions & 34 deletions

File tree

src/components/NavBar.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { Link, useLocation } from "react-router-dom";
2+
3+
const links = [
4+
{ label: "home", to: "/" },
5+
{ label: "people", to: "/people" },
6+
{ label: "projects", to: "/research" },
7+
];
8+
9+
interface NavBarProps {
10+
variant?: "dark" | "light";
11+
}
12+
13+
const NavBar = ({ variant = "dark" }: NavBarProps) => {
14+
const { pathname } = useLocation();
15+
16+
const textClass =
17+
variant === "dark"
18+
? "text-foreground/80 hover:text-foreground"
19+
: "text-foreground/60 hover:text-foreground";
20+
21+
const activeClass =
22+
variant === "dark"
23+
? "text-foreground underline underline-offset-4"
24+
: "text-foreground underline underline-offset-4";
25+
26+
return (
27+
<nav className="flex items-center gap-8 font-mono-display text-base tracking-wide">
28+
{links.map((link) => {
29+
const isActive =
30+
link.to === "/" ? pathname === "/" : pathname.startsWith(link.to);
31+
return (
32+
<Link
33+
key={link.to}
34+
to={link.to}
35+
className={`transition-colors ${isActive ? activeClass : textClass}`}
36+
>
37+
{link.label}
38+
</Link>
39+
);
40+
})}
41+
</nav>
42+
);
43+
};
44+
45+
export default NavBar;

src/pages/Index.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useRef } from "react";
2-
import { Link } from "react-router-dom";
2+
import NavBar from "@/components/NavBar";
33

44
const Index = () => {
55
const videoRef = useRef<HTMLVideoElement>(null);
@@ -22,13 +22,9 @@ const Index = () => {
2222
</div>
2323

2424
{/* Navigation */}
25-
<nav className="relative z-10 flex justify-end px-8 pt-6 sm:px-16 lg:px-24">
26-
<div className="flex items-center gap-8 font-mono-display text-base tracking-wide text-foreground/80">
27-
<Link to="/" className="transition-colors hover:text-foreground">home</Link>
28-
<Link to="/people" className="transition-colors hover:text-foreground">people</Link>
29-
<Link to="/research" className="transition-colors hover:text-foreground">projects</Link>
30-
</div>
31-
</nav>
25+
<div className="relative z-10 flex justify-end px-8 pt-6 sm:px-16 lg:px-24">
26+
<NavBar variant="dark" />
27+
</div>
3228

3329
{/* Content */}
3430
<main className="relative z-10 flex min-h-[calc(100vh-4rem)] flex-col justify-center px-8 sm:px-16 lg:px-24">

src/pages/People.tsx

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { people } from "@/data/people";
2-
import { ArrowLeft, ExternalLink } from "lucide-react";
3-
import { Link } from "react-router-dom";
2+
import NavBar from "@/components/NavBar";
43

54
const currentMembers = people.filter((p) => p.category === "current");
65
const alumni = people.filter((p) => p.category === "alumni");
@@ -11,21 +10,7 @@ const People = () => {
1110
{/* header */}
1211
<header className="sticky top-0 z-20 bg-background/95 backdrop-blur-sm">
1312
<div className="mx-auto max-w-[1200px] px-8 py-5 flex items-center justify-between">
14-
<Link
15-
to="/"
16-
className="flex items-center gap-1.5 text-sm text-muted-foreground transition-colors hover:text-foreground"
17-
>
18-
<ArrowLeft className="h-3.5 w-3.5" />
19-
home
20-
</Link>
21-
<nav className="flex items-center gap-6">
22-
<Link
23-
to="/research"
24-
className="text-sm text-muted-foreground hover:text-foreground transition-colors"
25-
>
26-
research
27-
</Link>
28-
</nav>
13+
<NavBar variant="light" />
2914
</div>
3015
</header>
3116

src/pages/Research.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useState, useMemo } from "react";
22
import { publications, type Tag } from "@/data/publications";
3-
import { Search, ArrowLeft, ExternalLink, Award } from "lucide-react";
4-
import { Link } from "react-router-dom";
3+
import { Search, ExternalLink } from "lucide-react";
4+
import NavBar from "@/components/NavBar";
55

66
const ALL_TAGS: Tag[] = ["human", "ai systems", "privacy", "security", "trust"];
77

@@ -43,13 +43,7 @@ const Research = () => {
4343
{/* header */}
4444
<header className="sticky top-0 z-20 bg-background/95 backdrop-blur-sm">
4545
<div className="mx-auto max-w-[1200px] px-8 py-5 flex items-center justify-between">
46-
<Link
47-
to="/"
48-
className="flex items-center gap-1.5 text-sm text-muted-foreground transition-colors hover:text-foreground"
49-
>
50-
<ArrowLeft className="h-3.5 w-3.5" />
51-
Home
52-
</Link>
46+
<NavBar variant="light" />
5347
<nav className="flex items-center gap-6">
5448
{ALL_TAGS.map((tag) => (
5549
<button

0 commit comments

Comments
 (0)