From 0257d596196ed2e248fba5c5aa7fa69a5880b1b3 Mon Sep 17 00:00:00 2001 From: tequ Date: Thu, 8 Jan 2026 15:18:19 +0900 Subject: [PATCH] Refactor Header.jsx --- src/components/Header.jsx | 354 +++++++++++++------------------------- 1 file changed, 118 insertions(+), 236 deletions(-) diff --git a/src/components/Header.jsx b/src/components/Header.jsx index 8cac6b3..68e0f27 100644 --- a/src/components/Header.jsx +++ b/src/components/Header.jsx @@ -42,8 +42,26 @@ const explorers = [ { name: 'Technical Explorer', href: 'https://explorer.xahau.network/' }, ] +// Navigation items definition shared between desktop and mobile +const navItems = [ + { name: 'About', link: '/about', urlPattern: 'about' }, + { name: 'Features', link: '/features', urlPattern: 'features' }, + { name: 'Ecosystem', link: '/ecosystem', urlPattern: 'ecosystem' }, + { name: 'Roadmap', link: '/roadmap', urlPattern: 'roadmap' }, + { name: 'Documentation', links: docs, urlPattern: 'docs' }, + { name: 'Connect', links: socials }, + { name: 'Explorers', links: explorers }, +] + import logo from '../assets/xahau-logo.svg' +const XahauLogo = () => ( + + Xahau + Xahau Logo + +) + export default function Header(props) { const [mobileMenuOpen, setMobileMenuOpen] = useState(false) @@ -54,10 +72,7 @@ export default function Header(props) { className="mx-auto flex max-w-7xl items-center justify-between p-6" >
- - Xahau - Xahau Logo - +
+ {/* Desktop navigation */} - - About - - - Features - - - Ecosystem - - - Roadmap - - - - Documentation - - -
- {docs.map((item) => ( - -
- {item.name} -
-
- ))} -
-
-
- - - Connect - - -
- {socials.map((item) => ( - -
- {item.name} -
-
- ))} -
-
-
- - - Explorers - - -
- {explorers.map((item) => ( - -
- {item.name} -
-
- ))} -
-
-
+ {navItems.map((navItem) => { + const isActive = + navItem.urlPattern && + props.url.pathname.slice(1).split('/')[0] === navItem.urlPattern + // Single link item + if (navItem.link) { + return ( + + {navItem.name} + + ) + } + // Dropdown item + return ( + + + {navItem.name} + + +
+ {navItem.links.map((item) => ( + +
+ {item.name} +
+
+ ))} +
+
+
+ ) + })}
- - Xahau - - - - - +