Initial release of Moniki paid services site and CMS (v1.0.0).
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
"use client";
|
||||
|
||||
import { HeaderTools } from "@/components/layout/HeaderTools";
|
||||
import { LocaleSwitcher } from "@/components/layout/LocaleSwitcher";
|
||||
import { Logo } from "@/components/layout/Logo";
|
||||
import { Button } from "@/components/ui/Button";
|
||||
import { Link } from "@/i18n/routing";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useEffect, useId, useState } from "react";
|
||||
|
||||
const links = [
|
||||
{ href: "/services" as const, key: "services" },
|
||||
{ href: "/doctors" as const, key: "doctors" },
|
||||
{ href: "/booking" as const, key: "booking" },
|
||||
{ href: "/promotions" as const, key: "promotions" },
|
||||
{ href: "/branches" as const, key: "branches" },
|
||||
{ href: "/news" as const, key: "news" },
|
||||
{ href: "/gallery" as const, key: "gallery" },
|
||||
];
|
||||
|
||||
export function Header() {
|
||||
const t = useTranslations("nav");
|
||||
const a11y = useTranslations("a11y");
|
||||
const meta = useTranslations("meta");
|
||||
const [open, setOpen] = useState(false);
|
||||
const menuId = useId();
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
function onKey(event: KeyboardEvent) {
|
||||
if (event.key === "Escape") setOpen(false);
|
||||
}
|
||||
document.addEventListener("keydown", onKey);
|
||||
return () => document.removeEventListener("keydown", onKey);
|
||||
}, [open]);
|
||||
|
||||
return (
|
||||
<header className="sticky top-0 z-50 border-b border-[var(--border)] bg-[var(--surface)]">
|
||||
<div className="mx-auto flex h-[var(--header-h)] max-w-7xl items-center gap-3 px-4 sm:px-6">
|
||||
<Logo tagline={meta("tagline")} className="min-w-0 shrink-0" />
|
||||
|
||||
<nav
|
||||
className="hidden min-w-0 flex-1 items-center justify-end gap-0 lg:flex"
|
||||
aria-label={a11y("mainNav")}
|
||||
>
|
||||
{links.map((l) => (
|
||||
<Link
|
||||
key={l.href}
|
||||
href={l.href}
|
||||
className="whitespace-nowrap rounded-lg px-2.5 py-2 text-base font-medium text-[var(--neutral-700)] transition hover:bg-[var(--brand-50)] hover:text-[var(--brand-700)]"
|
||||
>
|
||||
{t(l.key)}
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
|
||||
<div className="ml-auto flex shrink-0 items-center gap-2">
|
||||
<HeaderTools />
|
||||
<Link href="/cabinet" className="hidden md:inline-flex">
|
||||
<Button size="sm">{t("cabinet")}</Button>
|
||||
</Link>
|
||||
<LocaleSwitcher />
|
||||
<button
|
||||
type="button"
|
||||
className="relative inline-flex h-10 w-10 flex-col items-center justify-center gap-1.5 rounded-lg border border-[var(--border)] lg:hidden"
|
||||
aria-expanded={open}
|
||||
aria-controls={menuId}
|
||||
aria-label={open ? t("close") : t("menu")}
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
>
|
||||
<span
|
||||
className={cn(
|
||||
"block h-0.5 w-5 bg-[var(--neutral-800)] transition",
|
||||
open && "translate-y-2 rotate-45",
|
||||
)}
|
||||
/>
|
||||
<span
|
||||
className={cn(
|
||||
"block h-0.5 w-5 bg-[var(--neutral-800)] transition",
|
||||
open && "opacity-0",
|
||||
)}
|
||||
/>
|
||||
<span
|
||||
className={cn(
|
||||
"block h-0.5 w-5 bg-[var(--neutral-800)] transition",
|
||||
open && "-translate-y-2 -rotate-45",
|
||||
)}
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{open ? (
|
||||
<div id={menuId} className="border-t border-[var(--border)] bg-[var(--surface)] px-4 py-4 lg:hidden">
|
||||
<nav className="flex flex-col gap-1" aria-label={a11y("mainNav")}>
|
||||
{links.map((l) => (
|
||||
<Link
|
||||
key={l.href}
|
||||
href={l.href}
|
||||
className="rounded-lg px-3 py-3 text-base font-medium text-[var(--neutral-700)] hover:bg-[var(--brand-50)]"
|
||||
onClick={() => setOpen(false)}
|
||||
>
|
||||
{t(l.key)}
|
||||
</Link>
|
||||
))}
|
||||
<div className="mt-3 flex flex-wrap items-center gap-2 md:hidden">
|
||||
<Link href="/cabinet" onClick={() => setOpen(false)}>
|
||||
<Button size="sm">{t("cabinet")}</Button>
|
||||
</Link>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
) : null}
|
||||
</header>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user