diff --git a/apps/edr-freight-web/portal/src/components/PublicNavbar.tsx b/apps/edr-freight-web/portal/src/components/PublicNavbar.tsx index 7ee7fa422..c808f6014 100644 --- a/apps/edr-freight-web/portal/src/components/PublicNavbar.tsx +++ b/apps/edr-freight-web/portal/src/components/PublicNavbar.tsx @@ -1,4 +1,5 @@ -import { ArrowRight, Menu, TrainFront } from "lucide-react"; +import { useDisclosure } from "@mantine/hooks"; +import { ArrowRight, Menu, TrainFront, X } from "lucide-react"; import { Link } from "react-router-dom"; /** @@ -25,10 +26,52 @@ export const navLinks = [ * same-page anchors that would go nowhere. */ export function PublicNavbar({ onLanding = false }: { onLanding?: boolean }) { + const [menuOpen, { toggle: toggleMenu, close: closeMenu }] = + useDisclosure(false); + + // A route always navigates. An anchor only works on the landing page; + // elsewhere it has to go home first, or clicking it does nothing at all. + // Rendered twice — once for the desktop bar, once inside the mobile panel — + // so the branching lives in one place. + const renderLink = (link: (typeof navLinks)[number], className: string) => { + if (link.href.startsWith("/")) { + return ( + + {link.label} + + ); + } + + return onLanding ? ( + + {link.label} + + ) : ( + + {link.label} + + ); + }; + return (
- + @@ -42,31 +85,12 @@ export function PublicNavbar({ onLanding = false }: { onLanding?: boolean }) {
@@ -87,13 +111,52 @@ export function PublicNavbar({ onLanding = false }: { onLanding?: boolean }) {
+ + {menuOpen && ( +
+ + + {/* Only below md — from md up these two are already in the bar above. */} +
+ + Log in + + + + Get started + + +
+
+ )}
); }