From 0b370c51e6cff023d271cf45af10036f1fc7458a Mon Sep 17 00:00:00 2001 From: Enrique Gonzalez Date: Fri, 18 Sep 2026 23:47:09 +0000 Subject: [PATCH 1/2] Simplify the mobile docs header Amp-Thread-ID: https://ampcode.com/threads/T-01a0b6d8-52c2-769c-a693-81ec73b53042 Co-authored-by: Amp --- src/components/Layout.tsx | 14 ++--- src/components/MobileNavigation.tsx | 56 ++++++++++++------- src/components/ThemeSelector.tsx | 56 +++++++++++++++---- src/components/VersionSelector.tsx | 5 +- .../search/docsearch/DocSearchButton.tsx | 4 +- 5 files changed, 90 insertions(+), 45 deletions(-) diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx index 81a71217b..9a76ec337 100644 --- a/src/components/Layout.tsx +++ b/src/components/Layout.tsx @@ -44,14 +44,14 @@ function Header() {
-
+
@@ -64,16 +64,16 @@ function Header() {
-
+
-
+
{/* Plain anchor: next/link treats this same-origin URL as an app route and prefetches the changelog app's ~60 assets on every docs page. */} @@ -87,10 +87,10 @@ function Header() { - + diff --git a/src/components/MobileNavigation.tsx b/src/components/MobileNavigation.tsx index 22c24aba0..da8ed8f38 100644 --- a/src/components/MobileNavigation.tsx +++ b/src/components/MobileNavigation.tsx @@ -6,6 +6,7 @@ import Link from 'next/link'; import {usePathname, useSearchParams} from 'next/navigation'; import {Dialog} from '@headlessui/react'; import {Navigation} from '@/components/Navigation'; +import {ThemeSelector} from '@/components/ThemeSelector'; function MenuIcon(props: React.ComponentPropsWithoutRef<'svg'>) { return ( @@ -74,7 +75,7 @@ export function MobileNavigation() { - + Sourcegraph Docs
- {/* Plain anchor, so next/link does not prefetch the changelog app */} - - Changelog - - - - - +
+ + + +
+
+ + + GitHub + + {/* Plain anchor, so next/link does not prefetch the changelog app */} + + Changelog + +
diff --git a/src/components/ThemeSelector.tsx b/src/components/ThemeSelector.tsx index ca1f23680..3802869b5 100644 --- a/src/components/ThemeSelector.tsx +++ b/src/components/ThemeSelector.tsx @@ -1,5 +1,6 @@ import {useTheme} from 'next-themes'; import {Listbox} from '@headlessui/react'; +import {ChevronDownIcon} from '@heroicons/react/20/solid'; import clsx from 'clsx'; const themes = [ @@ -44,24 +45,56 @@ function SystemIcon(props: React.ComponentPropsWithoutRef<'svg'>) { ); } -export function ThemeSelector( - props: React.ComponentPropsWithoutRef> -) { +export function ThemeSelector({ + showLabel = false, + ...props +}: React.ComponentPropsWithoutRef> & { + showLabel?: boolean; +}) { let {theme, setTheme} = useTheme(); return ( - Theme + {!showLabel && ( + Theme + )} - - + {showLabel ? ( + <> + Appearance + + { + themes.find(option => option.value === theme) + ?.name + } + + + ) : ( + <> + + + + )} - + {themes.map(theme => ( clsx( 'flex cursor-pointer select-none items-center rounded-xl p-1', + showLabel && 'min-h-11', { 'text-link': selected, 'text-slate-700 dark:text-white': diff --git a/src/components/VersionSelector.tsx b/src/components/VersionSelector.tsx index 90b34b93c..9d917f74e 100644 --- a/src/components/VersionSelector.tsx +++ b/src/components/VersionSelector.tsx @@ -78,10 +78,7 @@ export default function VersionSelector() { return (
- + {selectedVersion.label === 'latest' ? 'Latest' : selectedVersion.name} diff --git a/src/components/search/docsearch/DocSearchButton.tsx b/src/components/search/docsearch/DocSearchButton.tsx index 9d07c49e2..a9ba2987d 100644 --- a/src/components/search/docsearch/DocSearchButton.tsx +++ b/src/components/search/docsearch/DocSearchButton.tsx @@ -35,10 +35,10 @@ export const DocSearchButton = React.forwardRef< return (