From 73917b46d8731f61a455970e584eb65866bf937b Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Thu, 19 Nov 2026 11:11:20 -0600 Subject: [PATCH] solid navbar --- .../src/components/NavbarDesktop.astro | 2 +- .../website/src/components/NavbarMobile.astro | 32 ++++++------------- .../src/components/NavbarMobileAutoHide.astro | 24 ++++++++++++++ packages/website/src/layouts/BaseLayout.astro | 6 ++-- .../[...locale]/guesser/index.astro | 2 +- 5 files changed, 39 insertions(+), 27 deletions(-) create mode 100644 packages/website/src/components/NavbarMobileAutoHide.astro diff --git a/packages/website/src/components/NavbarDesktop.astro b/packages/website/src/components/NavbarDesktop.astro index 50df7e932..291e6ae96 100644 --- a/packages/website/src/components/NavbarDesktop.astro +++ b/packages/website/src/components/NavbarDesktop.astro @@ -17,7 +17,7 @@ const { locale } = Astro.props; const strings = await api.strings(locale); export const filtered = Object.values(tools).filter( - (tool) => !tool.href && (tool.navbar ?? true), + (tool) => !tool.href && (tool.navbar ?? true) && !tool.disabled, ); --- diff --git a/packages/website/src/components/NavbarMobile.astro b/packages/website/src/components/NavbarMobile.astro index 7bb13b377..f75a8d908 100644 --- a/packages/website/src/components/NavbarMobile.astro +++ b/packages/website/src/components/NavbarMobile.astro @@ -4,12 +4,17 @@ import { CaretUpIcon, GearIcon } from "@radix-ui/react-icons"; import { api } from "../api/dynamic"; import { Logo } from "../icons/Logo"; import { LinkI18nWrapper } from "./LinkI18nWrapper"; +import type { Props as NavbarDesktopProps } from "./NavbarDesktop.astro"; import { filtered } from "./NavbarDesktop.astro"; +import NavbarMobileAutoHide from "./NavbarMobileAutoHide.astro"; import { Scroller, ScrollerOrientation } from "./Scroller"; import { Text } from "./Text"; -export { type Props } from "./NavbarDesktop.astro"; -const { locale, tool } = Astro.props; +export type Props = NavbarDesktopProps & { + solid?: boolean; +}; + +const { locale, tool, solid = false } = Astro.props; const strings = await api.strings(locale); --- @@ -175,27 +180,6 @@ const strings = await api.strings(locale); const navbar = document.getElementById("navbar-mobile")!; const tool = document.getElementById("current-tool")!; const overlay = document.getElementById("navbar-mobile-overlay")!; - const lastScrollTops = new WeakMap(); - - // Scroll doesn't bubble, so capturing also catches nested scrollers like tables - document.addEventListener( - "scroll", - (event) => { - const target = - event.target instanceof Element - ? event.target - : document.scrollingElement!; - const scrollTop = target.scrollTop; - const lastScrollTop = lastScrollTops.get(target) ?? 0; - - // Horizontal scrolling leaves scrollTop unchanged, so it's ignored - if (scrollTop === lastScrollTop) return; - - navbar.dataset.visible = `${scrollTop < lastScrollTop}`; - lastScrollTops.set(target, scrollTop); - }, - { capture: true, passive: true }, - ); tool.addEventListener("click", () => { navbar.dataset.expanded = `${navbar.dataset.expanded !== "true"}`; @@ -261,3 +245,5 @@ const strings = await api.strings(locale);