'use client' import { getRelativeLocaleUrl } from 'astro:i18n' import { Dialog, DialogPanel, Disclosure, DisclosureButton, DisclosurePanel, Popover, PopoverButton, PopoverGroup, PopoverPanel, } from '@headlessui/react' import { Bars3Icon, ChevronDownIcon, GlobeAltIcon, XMarkIcon, } from '@heroicons/react/20/solid' import { useState } from 'react' import logo from '../assets/xahau-logo.svg' import { defaultLocale } from '../i18n/locales' import { getAlternateLocaleHref } from '../utils/localizedHref' const languages = [ { code: 'en', label: 'English' }, { code: 'es', label: 'Español' }, { code: 'pt-BR', label: 'Português (Brasil)' }, // { code: 'ja', label: '日本語' }, { code: 'ja', label: '日本語' }, ] const nav = { en: { about: 'About', features: 'Features', ecosystem: 'Ecosystem', roadmap: 'Roadmap', docs: 'Documentation', connect: 'Connect', explorers: 'Explorers', events: 'Events', getstarted: 'Get started', protocol: 'Protocol Reference', infra: 'Infrastructure', discord: 'Community Discord', }, es: { about: 'Acerca de', features: 'Características', ecosystem: 'Ecosistema', roadmap: 'Hoja de ruta', docs: 'Documentación', connect: 'Conectar', explorers: 'Exploradores', events: 'Eventos', getstarted: 'Primeros pasos', protocol: 'Referencia de Protocolo', infra: 'Infraestructura', discord: 'Discord de la Comunidad', }, 'pt-BR': { about: 'Sobre', features: 'Recursos', ecosystem: 'Ecossistema', roadmap: 'Roadmap', docs: 'Documentação', connect: 'Conectar', explorers: 'Exploradores', events: 'Eventos', getstarted: 'Primeiros passos', protocol: 'Referência de Protocolo', infra: 'Infraestrutura', discord: 'Discord da Comunidade', }, ja: { about: 'Xahauについて', features: '機能', ecosystem: 'エコシステム', roadmap: 'ロードマップ', docs: 'ドキュメント', connect: 'コネクト', explorers: 'エクスプローラー', events: 'イベント', getstarted: 'はじめる', protocol: 'プロトコルリファレンス', infra: 'インフラストラクチャ', discord: 'コミュニティDiscord', }, } const XahauLogo = ({ href }) => ( Xahau Xahau Logo ) export default function Header(props) { const [mobileMenuOpen, setMobileMenuOpen] = useState(false) const pathname = props.url.pathname const currentLocale = props.locale || defaultLocale const t = nav[currentLocale] || nav.en function langUrl(code) { return getAlternateLocaleHref(pathname, code) } const socials = [ { name: t.events, href: getRelativeLocaleUrl(currentLocale, '/connect') }, { name: 'Dev Contest', href: getRelativeLocaleUrl(currentLocale, '/contest'), }, { name: 'X / Twitter', href: 'https://x.com/XahauNetwork' }, { name: 'GitHub', href: 'https://github.com/Xahau' }, { name: t.discord, href: 'https://discord.com/invite/UzU58haAn4' }, ] const docs = [ { name: t.getstarted, href: getRelativeLocaleUrl(currentLocale, '/docs') }, { name: t.protocol, href: getRelativeLocaleUrl( currentLocale, '/docs/protocol-reference/transactions', ), }, { name: 'Hooks', href: getRelativeLocaleUrl(currentLocale, '/docs/hooks') }, { name: 'Data APIs', href: getRelativeLocaleUrl(currentLocale, '/docs/data-apis'), }, { name: t.infra, href: getRelativeLocaleUrl( currentLocale, '/docs/infrastructure/system-requirements', ), }, { name: 'Whitepaper', href: getRelativeLocaleUrl(currentLocale, '/docs/resources/whitepaper'), }, ] const explorers = [ { name: 'XAHSCAN', href: 'https://xahscan.com/' }, { name: 'Bithomp Xahau Explorer', href: 'https://xahauexplorer.com/en' }, { name: 'XRPLWin Xahau Explorer', href: 'https://xahau.xrplwin.com/' }, { name: 'Technical Explorer', href: 'https://explorer.xahau.network/' }, ] const navItems = [ { name: t.about, href: getRelativeLocaleUrl(currentLocale, '/about'), urlPattern: 'about', }, { name: t.features, href: getRelativeLocaleUrl(currentLocale, '/features'), urlPattern: 'features', }, { name: t.ecosystem, href: getRelativeLocaleUrl(currentLocale, '/ecosystem'), urlPattern: 'ecosystem', }, { name: t.roadmap, href: getRelativeLocaleUrl(currentLocale, '/roadmap'), urlPattern: 'roadmap', }, { name: t.docs, children: docs, urlPattern: 'docs' }, { name: t.connect, children: socials }, { name: t.explorers, children: explorers }, ] const pathSegments = pathname.slice(1).split('/') const activeSegment = currentLocale !== defaultLocale ? pathSegments[1] : pathSegments[0] /* ── Shared class fragments ─────────────────────────────────────────────── */ const linkBase = 'no-underline text-sm font-medium transition-colors duration-150' const linkIdle = 'text-[#2d3e44] hover:text-[#0f2328]' const linkActive = 'text-[#007b3d]' const dropdownPanel = 'absolute left-1/2 z-10 mt-3 w-52 -translate-x-1/2 overflow-hidden ' + 'bg-white rounded-xl border border-[#e4edef] shadow-[0_4px_24px_-4px_rgba(15,35,40,0.12)] ' + 'transition data-closed:translate-y-1 data-closed:opacity-0 ' + 'data-enter:duration-150 data-enter:ease-out data-leave:duration-100 data-leave:ease-in' const dropdownItem = 'no-underline flex items-center px-3 py-2 text-sm text-[#2d3e44] ' + 'hover:text-[#0f2328] hover:bg-[#f4f6f7] rounded-lg transition-colors duration-100' return (
{/* ── Mobile menu ────────────────────────────────────────────────────── */}
{navItems.map((navItem) => { const isActive = navItem.urlPattern && activeSegment === navItem.urlPattern if (navItem.href) { return ( {navItem.name} {isActive && ( )} ) } return ( {navItem.name} {navItem.children.map((item) => ( {item.name} ))} ) })}
{/* Mobile language selector */}
{languages.find((l) => l.code === currentLocale)?.label} {languages.map((lang) => ( {lang.label} {currentLocale === lang.code && ( )} ))}
) }