Skip to content

Commit 2c37fc1

Browse files
committed
fix: navbar full width on scroll with no rounded edges
- Keep original centered, rounded behavior when not scrolled - Expand to full width with no rounded edges when scrolled - Navbar merges with page margins on scroll - Fixes navbar alignment issue on desktop Resolves #3428
1 parent a31041d commit 2c37fc1

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

components/navbar/FloatingNavbar.tsx

Lines changed: 15 additions & 7 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,13 +40,15 @@ 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-0 left-0 right-0 z-40"
46+
: "fixed top-6 left-1/2 -translate-x-1/2 z-40";
4547
const navWidthClasses = isScrolled
46-
? "w-[78%] md:w-[82%] md:max-w-4xl"
48+
? "w-full"
4749
: "w-[90%] md:w-[96%] md:max-w-6xl";
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
? ""
@@ -60,12 +62,18 @@ export default function FloatingNavbar({ isBlogReadingPage }: FloatingNavbarProp
6062
? glassNavScrolled
6163
: glassNavDefault;
6264

65+
const navBorderRadius = derivedBlogReadingPage
66+
? "rounded-none"
67+
: isScrolled
68+
? "rounded-none"
69+
: "rounded-full";
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)