From 75f93b5f6ca5d771ec29934c40283c3ea0b4a0a7 Mon Sep 17 00:00:00 2001 From: Mauricio Siu Date: Wed, 11 Mar 2026 11:34:01 -0600 Subject: [PATCH] feat: implement body scroll lock in mobile navigation for improved user experience - Added BodyScrollLock component to prevent background scrolling when the mobile navigation is open. - Updated MobileNavigation to utilize createPortal for rendering the overlay, enhancing the navigation's usability and accessibility. - Maintained existing navigation links while improving the overall structure and interaction of the mobile menu. --- apps/website/components/Header.tsx | 156 +++++++++++++++-------------- 1 file changed, 82 insertions(+), 74 deletions(-) diff --git a/apps/website/components/Header.tsx b/apps/website/components/Header.tsx index d144a35..b047843 100644 --- a/apps/website/components/Header.tsx +++ b/apps/website/components/Header.tsx @@ -4,7 +4,8 @@ import { cn } from "@/lib/utils"; import { Popover, Transition } from "@headlessui/react"; import { ChevronRight } from "lucide-react"; import Link from "next/link"; -import { Fragment, type JSX, type SVGProps } from "react"; +import { Fragment, useEffect, type JSX, type SVGProps } from "react"; +import { createPortal } from "react-dom"; import { Container } from "./Container"; import GithubStars from "./GithubStars"; import { trackGAEvent } from "./analitycs"; @@ -72,84 +73,91 @@ function MobileNavIcon({ open }: { open: boolean }) { ); } +function BodyScrollLock({ lock }: { lock: boolean }) { + useEffect(() => { + document.body.style.overflow = lock ? "hidden" : ""; + return () => { + document.body.style.overflow = ""; + }; + }, [lock]); + return null; +} + function MobileNavigation() { return ( - - {({ open }) => } - - - - - - - - ( + <> + + -

- Features -

- Application Deployment - Databases -
- Pricing -
-

- Solutions -

- Enterprise - Partners -
- +
+ {open && createPortal( +
close()} />, + document.body + )} + + - Docs - -
-

- Resources -

- Templates - Blog - FAQ -
- Contact - - - - -
-
+ +

+ Features +

+ Application Deployment + Databases +
+ Pricing +
+

+ Solutions +

+ Enterprise + Partners +
+ + Docs + +
+

+ Resources +

+ Templates + Blog + FAQ +
+ Contact + + + +
+ + + + )} ); }