qazaq-legacy-foundation-web/src/components/Header.tsx

36 lines
1.9 KiB
TypeScript

import Link from 'next/link'
import { locales, type Dict, type Locale } from '@/i18n'
/** `path` — текущая страница без языка ('' — главная): переключатель языка ведёт на ту же страницу, якоря — на главную. */
export function Header({ t, locale, showProjects, showNews, path = '' }: { t: Dict; locale: Locale; showProjects: boolean; showNews: boolean; path?: string }) {
const links = [
['/about', t.sections.about, true],
['/about#directions', t.nav.directions, true],
['/projects', t.nav.projects, showProjects],
['/news', t.news.title, showNews],
['/contacts', t.sections.contacts, true],
] as const
return (
<header className="absolute inset-x-0 top-0 z-10">
<div className="mx-auto flex max-w-6xl flex-wrap items-center justify-between gap-x-8 gap-y-3 px-5 py-6 sm:px-8">
<Link href={`/${locale}`} className="font-serif text-lg tracking-wide">
{t.siteName}
</Link>
<nav className="order-3 flex w-full flex-wrap gap-x-6 gap-y-2 text-sm text-graphite md:order-2 md:w-auto">
{links.filter((l) => l[2]).map(([href, label]) => (
<a key={href} href={`/${locale}${href}`} className="hover:text-burgundy">{label}</a>
))}
</nav>
<div className="order-2 flex shrink-0 items-center gap-1 text-sm md:order-3" aria-label={t.language}>
{locales.map((l) => (
<Link key={l} href={`/${l}${path}`} hrefLang={l} aria-current={l === locale ? 'true' : undefined}
className={`inline-flex min-h-11 min-w-11 items-center justify-center rounded-full px-3 py-1 md:min-h-0 md:min-w-0 ${l === locale ? 'bg-burgundy font-bold text-paper' : 'font-normal text-graphite hover:text-burgundy'}`}>
{l.toUpperCase()}
</Link>
))}
</div>
</div>
</header>
)
}