Skip to content

Commit 88fe450

Browse files
committed
feat: mobile navbar
1 parent b03aad4 commit 88fe450

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

src/app/(marketing)/_components/navbar.tsx

+32-26
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use client';
22

3-
import { forwardRef, useEffect, useState } from 'react';
3+
import { forwardRef, useState } from 'react';
44
import Image from 'next/image';
55
import Link from 'next/link';
66

7-
import { ChevronRightIcon } from 'lucide-react';
7+
import { ChevronRightIcon, MenuIcon } from 'lucide-react';
88

99
import { constants, features } from '@/constants';
1010
import { cn } from '@/lib/utils';
@@ -49,32 +49,10 @@ const ListItem = forwardRef<
4949
ListItem.displayName = 'ListItem';
5050

5151
export const Navbar = () => {
52-
const [scroll, setScroll] = useState(false);
53-
54-
useEffect(() => {
55-
const handleScroll = () => {
56-
if (window.scrollY > 50) {
57-
setScroll(true);
58-
} else {
59-
setScroll(false);
60-
}
61-
};
62-
63-
handleScroll();
64-
65-
window.addEventListener('scroll', handleScroll);
66-
return () => {
67-
window.removeEventListener('scroll', handleScroll);
68-
};
69-
}, []);
52+
const [menuOpen, setMenuOpen] = useState(false);
7053

7154
return (
72-
<nav
73-
className={cn(
74-
'sticky inset-x-0 top-0 z-50 w-full border-b border-transparent bg-transparent py-4 transition-colors duration-500',
75-
scroll && 'border-gray-element bg-background/85 backdrop-blur-md',
76-
)}
77-
>
55+
<nav className={cn('z-50 w-full pb-0 pt-4 md:py-4')}>
7856
<div className="container flex items-center justify-between transition-all">
7957
<Link href="/" className="flex items-center gap-3">
8058
<Image src="/logo.svg" width={35} height={35} alt="Noodle Logo" />
@@ -169,6 +147,34 @@ export const Navbar = () => {
169147
</Link>
170148
</Button>
171149
</div>
150+
<div className="block md:hidden">
151+
<button
152+
type="button"
153+
onClick={() => {
154+
setMenuOpen((prev) => !prev);
155+
}}
156+
>
157+
<MenuIcon size={24} />
158+
</button>
159+
</div>
160+
</div>
161+
<div className={cn('h-0 overflow-hidden', menuOpen && 'h-full pt-6')}>
162+
<div className="container">
163+
<ul className="flex flex-col gap-3">
164+
<li>
165+
<Link href="/">Early access</Link>
166+
</li>
167+
<li>
168+
<Link href="/">Blog</Link>
169+
</li>
170+
<li>
171+
<Link href="/">Contribute</Link>
172+
</li>
173+
<li>
174+
<Link href="/">Discord</Link>
175+
</li>
176+
</ul>
177+
</div>
172178
</div>
173179
</nav>
174180
);

0 commit comments

Comments
 (0)