Skip to content

Commit 24a9c8f

Browse files
committed
fix: navbar full width by default, shrinks on scroll
- Navbar is full width (100%) by default when not scrolled - Navbar shrinks to centered width when scrolled - Full width state has no rounded edges (rounded-none) - Scrolled state has rounded-full with shadow - Matches landing page behavior Fixes #3428 Signed-off-by: Dhruv Bharuka <iit2022015@iiitl.ac.in>
1 parent b13c0df commit 24a9c8f

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

components/navbar/FloatingNavbar.tsx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useRouter } from "next/router";
55
import FloatingNavbarClient from "./FloatingNavbarClient";
66

77
const glassNavBase =
8-
"relative overflow-visible rounded-full transition-all duration-300 backdrop-blur-2xl";
8+
"relative overflow-visible transition-all duration-300 backdrop-blur-2xl";
99
const glassNavDefault =
1010
"bg-gradient-to-br from-gray-100/80 via-gray-100/62 to-gray-100/48 border border-white/70 shadow-[0_18px_44px_rgba(15,23,42,0.18)]";
1111
const glassNavScrolled =
@@ -40,32 +40,40 @@ export default function FloatingNavbar({ isBlogReadingPage }: FloatingNavbarProp
4040
}, [derivedBlogReadingPage]);
4141

4242
const navPositionClasses = derivedBlogReadingPage
43-
? "relative top-0 mx-auto z-40"
44-
: "fixed top-6 left-1/2 -translate-x-1/2 z-40";
43+
? "relative top-0 z-40"
44+
: isScrolled
45+
? "fixed top-6 left-1/2 -translate-x-1/2 z-40"
46+
: "fixed top-0 left-0 right-0 z-40";
4547
const navWidthClasses = isScrolled
46-
? "w-[82%] md:max-w-5xl"
47-
: "w-[96%] md:max-w-6xl";
48+
? "w-[90%] md:w-[96%] md:max-w-6xl"
49+
: "w-full";
4850
const navPaddingClasses = isScrolled
49-
? "px-4 py-1.5 md:px-4 md:py-2 lg:px-5 lg:py-2.5"
51+
? "px-4 py-1.5 md:px-6 md:py-2 lg:px-8 lg:py-2.5"
5052
: "px-5 py-2 md:px-6 md:py-3 lg:px-8 lg:py-4";
5153
const navShadowClasses = derivedBlogReadingPage
5254
? ""
5355
: isScrolled
54-
? "shadow-none"
55-
: "shadow-[0_18px_44px_rgba(15,23,42,0.18)]";
56+
? "shadow-[0_18px_44px_rgba(15,23,42,0.18)]"
57+
: "shadow-none";
5658

5759
const navGlassClasses = derivedBlogReadingPage
5860
? glassNavReading
5961
: isScrolled
6062
? glassNavScrolled
6163
: glassNavDefault;
6264

65+
const navBorderRadius = derivedBlogReadingPage
66+
? "rounded-none"
67+
: isScrolled
68+
? "rounded-full"
69+
: "rounded-none";
70+
6371
return (
6472
<nav className={`${navPositionClasses} transition-all duration-300 ${navWidthClasses}`}>
6573
<div
66-
className={`${glassNavBase} ${navGlassClasses} overflow-visible ${navShadowClasses} ${navPaddingClasses}`}
74+
className={`${glassNavBase} ${navGlassClasses} overflow-visible ${navShadowClasses} ${navPaddingClasses} ${navBorderRadius}`}
6775
>
68-
<div className="pointer-events-none absolute inset-0 rounded-full">
76+
<div className={`pointer-events-none absolute inset-0 ${navBorderRadius}`}>
6977
<div className="absolute -top-8 -left-6 h-24 w-24 rounded-full bg-gray-200/60 blur-2xl" />
7078
<div className="absolute -bottom-10 -right-8 h-32 w-32 rounded-full bg-gray-200/40 blur-3xl" />
7179
</div>

0 commit comments

Comments
 (0)