From ab710bcaf5f842ba6382179403e4dfef5774c22a Mon Sep 17 00:00:00 2001 From: Simon <10131203+gaomeng1900@users.noreply.github.com> Date: Fri, 24 Oct 2025 00:07:15 +0800 Subject: [PATCH] stye: optimize mobile header with icon navigation --- pages/components/Header.tsx | 101 ++++++++++++++---------------------- pages/components/icons.tsx | 75 ++++++++++++++++++++++++++ pages/index.css | 10 ++++ 3 files changed, 124 insertions(+), 62 deletions(-) create mode 100644 pages/components/icons.tsx diff --git a/pages/components/Header.tsx b/pages/components/Header.tsx index bfe058c..a3cc1c9 100644 --- a/pages/components/Header.tsx +++ b/pages/components/Header.tsx @@ -4,6 +4,7 @@ import { Link } from 'wouter' import LanguageSwitcher from './LanguageSwitcher' import ThemeSwitcher from './ThemeSwitcher' +import { BookIcon, CloseIcon, GithubIcon, MenuIcon } from './icons' export default function Header() { const { t } = useTranslation('common') @@ -16,11 +17,11 @@ export default function Header() { role="banner" >
-
+
{/* Logo */} setMobileMenuOpen(false)} > @@ -30,11 +31,39 @@ export default function Header() {
- page-agent -

{t('header.slogan')}

+ + page-agent + +

+ {t('header.slogan')} +

+ {/* Mobile Icon Navigation (横向滚动) */} + + {/* Desktop Navigation */}
@@ -124,20 +116,7 @@ export default function Header() { className="flex items-center gap-2 px-3 py-2 rounded-lg text-gray-600 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-800 hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200" onClick={() => setMobileMenuOpen(false)} > - + {t('header.nav_docs')} - + {t('header.nav_source')}
diff --git a/pages/components/icons.tsx b/pages/components/icons.tsx new file mode 100644 index 0000000..3848e4a --- /dev/null +++ b/pages/components/icons.tsx @@ -0,0 +1,75 @@ +// SVG图标组件集合,用于Header等地方复用 + +interface IconProps { + className?: string + 'aria-hidden'?: boolean +} + +export function BookIcon({ className = 'w-4 h-4', ...props }: IconProps) { + return ( + + ) +} + +export function GithubIcon({ className = 'w-4 h-4', ...props }: IconProps) { + return ( + + ) +} + +export function MenuIcon({ className = 'w-6 h-6', ...props }: IconProps) { + return ( + + ) +} + +export function CloseIcon({ className = 'w-6 h-6', ...props }: IconProps) { + return ( + + ) +} diff --git a/pages/index.css b/pages/index.css index eff7706..883a6e2 100644 --- a/pages/index.css +++ b/pages/index.css @@ -192,3 +192,13 @@ td { border-bottom-color: rgba(255, 255, 255, 0.2); } } */ + +/* 隐藏滚动条,但保持滚动功能 */ +.scrollbar-hide { + -ms-overflow-style: none; /* IE and Edge */ + scrollbar-width: none; /* Firefox */ +} + +.scrollbar-hide::-webkit-scrollbar { + display: none; /* Chrome, Safari and Opera */ +}