ldc-ker-chant/resources/ts/front/partials/Navbar.tsx

114 lines
3.2 KiB
TypeScript

import { Link } from "@inertiajs/react";
import { type ReactNode } from "react";
import logoImg from "&/images/global/logo.svg";
import humanIcon from "&/images/icons/human.svg";
import mapsIcon from "&/images/icons/maps.svg";
import scrollIcon from "&/images/icons/scroll.svg";
import starIcon from "&/images/icons/stars.svg";
export interface HeroNavItem {
label: string;
href: string;
icon?: ReactNode;
}
interface NavbarProps {
navItems?: HeroNavItem[];
logoImage?: string;
homeHref?: string;
}
const DEFAULT_NAV: HeroNavItem[] = [
{
label: "Notre histoire",
href: "/#notre-histoire",
icon: <img src={mapsIcon} alt="" className="h-10 w-auto" />,
},
{
label: "Nos valeurs",
href: "/#nos-valeurs",
icon: <img src={humanIcon} alt="" className="h-10 w-auto" />,
},
{
label: "Nos produits",
href: "/#nos-produits",
icon: <img src={starIcon} alt="" className="h-10 w-auto" />,
},
];
const scrollDown = (): void => {
window.scrollTo({ top: 0, behavior: "smooth" });
};
export default function Navbar({
navItems = DEFAULT_NAV,
logoImage = logoImg,
homeHref = route("front.homepage"),
}: Readonly<NavbarProps>) {
return (
<nav
className="
fixed bottom-0 left-0 z-400 flex w-full items-center bg-[#1D1E1C] px-6 py-4 text-white
lg:bottom-auto lg:left-auto lg:right-12 lg:top-0 lg:w-auto lg:max-w-[760px]
lg:gap-12 lg:rounded-b-3xl lg:px-16 lg:shadow-xl font-baloo"
>
{/* logo (desktop) */}
<Link
href={homeHref}
aria-label="Accueil"
className="hidden shrink-0 lg:block"
>
<img
src={logoImage}
alt="Logo Ker Chant, spécialiste des volailles de Bretagne"
title="Ker Chant"
className="h-12 w-auto max-w-none object-contain"
/>
</Link>
{/* (desktop) */}
<ul className="ml-auto hidden items-center gap-6 lg:flex">
{navItems.map((n, i) => (
<li key={n.href} className="flex items-center gap-8">
{i > 0 && (
<span className="h-5 w-px bg-white/90" aria-hidden="true" />
)}
<Link
href={n.href}
className="text-lg font-semibold text-white transition-colors hover:underline"
>
{n.label}
</Link>
</li>
))}
</ul>
{/* (mobile) */}
<div className="flex w-full items-center justify-around lg:hidden">
{navItems.map((n) => (
<Link
key={n.href}
href={n.href}
aria-label={n.label}
className="flex items-center justify-center text-white/85 transition-colors hover:text-white"
>
{n.icon ?? <span className="text-sm font-semibold">{n.label}</span>}
</Link>
))}
<button
type="button"
onClick={scrollDown}
className="flex h-11 w-11 items-center justify-center rounded-full shadow-lg"
>
<img
src={scrollIcon}
alt=""
className="h-11 w-11 max-w-none"
role="img"
/>
</button>
</div>
</nav>
);
}