import { useCallback, useEffect, useRef, useState } from 'react' import { useTranslation } from '@shared/i18n/react' import { Link, useLocation } from 'react-router' import { LanguageSwitch } from '../../i18n/LanguageSwitch' import { MobileMenu } from './MobileMenu' import { NavPill } from './NavPill' import { AccountSlot, DownloadIcon, MenuIcon, Watermark } from './parts' const MENU_ID = 'site-menu' function useNavItems() { const { t } = useTranslation('common') return [ { to: '/showcase', label: t('nav.showcase') }, { to: '/themes', label: t('nav.themes') }, { to: '/configs', label: t('nav.myConfigs') }, { to: '/link', label: t('nav.linkGame') }, ] } function useScrolled(threshold = 24): boolean { const [scrolled, setScrolled] = useState(false) useEffect(() => { const onScroll = () => setScrolled(window.scrollY > threshold) onScroll() window.addEventListener('scroll', onScroll, { passive: true }) return () => window.removeEventListener('scroll', onScroll) }, [threshold]) return scrolled } /** * A floating glass bar in the mod's own UI language: HUD-watermark logo, the [Modules | Settings] * pill as navigation, and a compact right cluster. It sits on the page's content column * (the bar overhangs by its own padding so the watermark lines up with the text below). */ export function TopBar() { const { t } = useTranslation(['common', 'download']) const scrolled = useScrolled() const [open, setOpen] = useState(false) const toggleRef = useRef(null) const { pathname } = useLocation() const items = useNavItems() const close = useCallback(() => setOpen(false), []) // A route change (link in the sheet, back button) always closes the menu. const [lastPath, setLastPath] = useState(pathname) if (lastPath !== pathname) { setLastPath(pathname) setOpen(false) } return (
{t('download:nav')}
) }