211 lines
7.1 KiB
TypeScript
211 lines
7.1 KiB
TypeScript
import { Link } from "@inertiajs/react";
|
|
import { ChevronDown, ChevronUp, Circle } from "lucide-react";
|
|
import { useState } from "react";
|
|
|
|
import CookieNoticeLink from "@/front/Components/cookie/CookieNoticeLink";
|
|
import FooterEleveurs from "@/front/Components/Footer/FooterEleveurs";
|
|
|
|
interface NavItem {
|
|
label: string;
|
|
href: string;
|
|
isCookieButton?: boolean;
|
|
children?: { label: string; href: string }[];
|
|
}
|
|
|
|
function getColonneGauche(): NavItem[] {
|
|
return [
|
|
{
|
|
label: "La démarche",
|
|
href: "#",
|
|
children: [
|
|
{
|
|
label: "Pourquoi cette démarche ?",
|
|
href: route("front.why-this-approach"),
|
|
},
|
|
{
|
|
label: "Le bien-être et la protection animale",
|
|
href: route("front.animal-welfare"),
|
|
},
|
|
],
|
|
},
|
|
{ label: "Les engagements", href: route("front.engagements") },
|
|
{
|
|
label: "Qui sommes-nous ?",
|
|
href: "#",
|
|
children: [
|
|
{
|
|
label: "La gouvernance du collectif",
|
|
href: route("front.gouvernance.index"),
|
|
},
|
|
{
|
|
label: "La communauté Amont",
|
|
href: route("front.communities.show", "amont"),
|
|
},
|
|
{
|
|
label: "La communauté Transformateurs et Aval",
|
|
href: route("front.communities.show", "transformateurs"),
|
|
},
|
|
{
|
|
label: "La communauté Autres Parties Prenantes",
|
|
href: route("front.communities.show", "autres"),
|
|
},
|
|
],
|
|
},
|
|
{
|
|
label: "Questions ? Réponses",
|
|
href: route("front.questions-reponses.index"),
|
|
},
|
|
{ label: "Actualités", href: route("front.news.index") },
|
|
{ label: "Rejoindre le collectif", href: route("front.join-group.index") },
|
|
];
|
|
}
|
|
|
|
function getColonneDroite(): NavItem[] {
|
|
return [
|
|
{ label: "Espace presse", href: route("front.espace-presse.index") },
|
|
{ label: "Recherche", href: route("front.recherche.index") },
|
|
{ label: "Mentions légales & CGU", href: route("front.mentions-legales") },
|
|
{
|
|
label: "Charte de confidentialité",
|
|
href: route("front.confidentialite"),
|
|
},
|
|
{ label: "Gestion des cookies", href: "#", isCookieButton: true },
|
|
];
|
|
}
|
|
|
|
interface MenuContentProps {
|
|
variant?: "default" | "menu";
|
|
}
|
|
|
|
const MARGIN_CLASSES: Record<
|
|
NonNullable<MenuContentProps["variant"]>,
|
|
string
|
|
> = {
|
|
default: "mx-6 my-12 lg:mx-24 lg:my-24",
|
|
menu: "mx-6 my-12 lg:ml-12 lg:mr-20 lg:mb-24 lg:mt-4",
|
|
};
|
|
|
|
export default function MenuContent({
|
|
variant = "default",
|
|
}: Readonly<MenuContentProps>) {
|
|
const [openItem, setOpenItem] = useState<string | null>(null);
|
|
const colonneGauche = getColonneGauche();
|
|
const colonneDroite = getColonneDroite();
|
|
|
|
const toggleItem = (label: string) => {
|
|
setOpenItem((prev) => (prev === label ? null : label));
|
|
};
|
|
|
|
return (
|
|
<div
|
|
className={`flex flex-col items-start gap-11 lg:flex-row lg:justify-between lg:gap-8 ${MARGIN_CLASSES[variant]}`}
|
|
>
|
|
<div className="order-1 w-full lg:order-2 lg:w-auto">
|
|
<FooterEleveurs />
|
|
</div>
|
|
|
|
<div className="order-2 flex w-full flex-col items-start gap-11 text-left lg:order-1 lg:w-[600px] lg:gap-[72px]">
|
|
<h2 className="font-lato-black text-h3 uppercase leading-tight text-white lg:text-h2">
|
|
Filière agricole engagée pour élever le bien-être animal
|
|
</h2>
|
|
|
|
<nav className="flex w-full flex-col gap-8 lg:flex-row lg:gap-[72px]">
|
|
<ul className="flex flex-col items-start gap-4">
|
|
{colonneGauche.map((item) => {
|
|
const isOpen = openItem === item.label;
|
|
|
|
return (
|
|
<li key={item.label} className="w-full">
|
|
{item.children ? (
|
|
<button
|
|
type="button"
|
|
onClick={() => {
|
|
toggleItem(item.label);
|
|
}}
|
|
className="flex w-full cursor-pointer items-center gap-4 font-poppins-regular text-[14px] lg:text-body text-white/90 transition-colors hover:text-white"
|
|
>
|
|
<span
|
|
className={isOpen ? "font-poppins-bold underline" : ""}
|
|
>
|
|
{item.label}
|
|
</span>
|
|
{isOpen ? (
|
|
<ChevronUp
|
|
size={14}
|
|
strokeWidth={2}
|
|
className="shrink-0"
|
|
/>
|
|
) : (
|
|
<ChevronDown
|
|
size={14}
|
|
strokeWidth={2}
|
|
className="shrink-0"
|
|
/>
|
|
)}
|
|
</button>
|
|
) : (
|
|
<Link
|
|
href={item.href}
|
|
className="flex items-center gap-4 font-poppins-regular text-[14px] lg:text-body text-white/90 transition-colors hover:text-white"
|
|
>
|
|
{item.label}
|
|
</Link>
|
|
)}
|
|
|
|
{item.children && (
|
|
<div
|
|
className={`grid transition-all duration-300 ${
|
|
isOpen
|
|
? "grid-rows-[1fr] opacity-100"
|
|
: "grid-rows-[0fr] opacity-0"
|
|
}`}
|
|
>
|
|
<ul className="mt-3 flex flex-col gap-3 overflow-hidden pl-4">
|
|
{item.children.map((child) => (
|
|
<li key={child.label}>
|
|
<Link
|
|
href={child.href}
|
|
className="flex items-center gap-2 font-poppins-regular text-[14px] lg:text-body text-white/80 transition-colors hover:text-white"
|
|
>
|
|
<Circle
|
|
size={6}
|
|
className="shrink-0 fill-white/60 text-white/60"
|
|
/>
|
|
{child.label}
|
|
</Link>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</div>
|
|
)}
|
|
</li>
|
|
);
|
|
})}
|
|
</ul>
|
|
|
|
<ul className="flex w-full flex-col items-end gap-4 lg:w-auto lg:items-start">
|
|
{colonneDroite.map((item) =>
|
|
item.isCookieButton ? (
|
|
<li key={item.label}>
|
|
<CookieNoticeLink
|
|
label={item.label}
|
|
className="font-poppins-regular text-[14px] lg:text-body text-white/90 transition-colors hover:text-white cursor-pointer"
|
|
/>
|
|
</li>
|
|
) : (
|
|
<li key={item.label}>
|
|
<Link
|
|
href={item.href}
|
|
className="font-poppins-regular text-[14px] lg:text-body text-white/90 transition-colors hover:text-white"
|
|
>
|
|
{item.label}
|
|
</Link>
|
|
</li>
|
|
),
|
|
)}
|
|
</ul>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|