Skip to content

Commit b82bdc1

Browse files
committed
Add selected color to main nav menu
1 parent 924ed74 commit b82bdc1

File tree

3 files changed

+55
-25
lines changed

3 files changed

+55
-25
lines changed

src/app/NavMenu.tsx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
'use client';
2+
3+
import { Button } from '@/components/ui/button';
4+
import { GithubIcon } from '@/icons';
5+
import clsx from 'clsx/lite';
6+
import Link from 'next/link';
7+
import { usePathname } from 'next/navigation';
8+
9+
export function NavMenu() {
10+
const pathname = usePathname();
11+
12+
return (
13+
<ul className="flex flex-row gap-4">
14+
<li>
15+
<Button
16+
asChild
17+
variant="ghost"
18+
className={clsx(
19+
pathname.startsWith('/trackers') &&
20+
'text-nav-menu-selected-foreground',
21+
)}
22+
>
23+
<Link href="/trackers">Advantage trackers</Link>
24+
</Button>
25+
</li>
26+
<li>
27+
<Button
28+
asChild
29+
variant="ghost"
30+
className={clsx(
31+
pathname === '/participate' && 'text-nav-menu-selected-foreground',
32+
)}
33+
>
34+
<Link href="/participate">Participate</Link>
35+
</Button>
36+
</li>
37+
<li>
38+
<Button asChild variant="ghost" size="icon">
39+
<a
40+
href="https://github.com/quantum-advantage-tracker/quantum-advantage-tracker.github.io"
41+
target="_blank"
42+
rel="noopener noreferrer"
43+
>
44+
<GithubIcon className="size-6" />
45+
</a>
46+
</Button>
47+
</li>
48+
</ul>
49+
);
50+
}

src/app/globals.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
--radius-md: calc(var(--radius) - 2px);
4141
--radius-lg: var(--radius);
4242
--radius-xl: calc(var(--radius) + 4px);
43+
44+
/* TODO: Review these custom variables */
45+
--color-nav-menu-selected-foreground: #24a148;
4346
}
4447

4548
:root {

src/app/layout.tsx

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { Button } from '@/components/ui/button';
2-
import { GithubIcon } from '@/icons';
31
import type { Metadata } from 'next';
42
import { Inter } from 'next/font/google';
53
import Link from 'next/link';
4+
import { NavMenu } from './NavMenu';
65

76
import './globals.css';
87

@@ -30,29 +29,7 @@ export default function RootLayout(props: LayoutProps<'/'>) {
3029
📐 Quantum Advantage Tracker
3130
</Link>
3231

33-
<ul className="flex flex-row gap-4">
34-
<li>
35-
<Button asChild variant="ghost">
36-
<Link href="/trackers">Advantage trackers</Link>
37-
</Button>
38-
</li>
39-
<li>
40-
<Button asChild variant="ghost">
41-
<Link href="/participate">Participate</Link>
42-
</Button>
43-
</li>
44-
<li>
45-
<Button asChild variant="ghost" size="icon">
46-
<a
47-
href="https://github.com/quantum-advantage-tracker/quantum-advantage-tracker.github.io"
48-
target="_blank"
49-
rel="noopener noreferrer"
50-
>
51-
<GithubIcon className="size-6" />
52-
</a>
53-
</Button>
54-
</li>
55-
</ul>
32+
<NavMenu />
5633
</div>
5734
</nav>
5835
</header>

0 commit comments

Comments
 (0)