293 lines
9.4 KiB
TypeScript
293 lines
9.4 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";
|
|
import useDeviceType from "@/hooks/use-device-type";
|
|
|
|
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é Scientifique",
|
|
href: route("front.communities.show", "scientifique"),
|
|
},
|
|
{
|
|
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") },
|
|
// FIXME: Issue #48 - Masquer page de recherche car non précisé
|
|
// { 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 MENU_BREAKPOINT = 1024;
|
|
const MENU_TEXT_BREAKPOINT = 1280;
|
|
|
|
export default function MenuContent({
|
|
variant = "default",
|
|
}: Readonly<MenuContentProps>) {
|
|
const [openItem, setOpenItem] = useState<string | null>(null);
|
|
const { isCompact } = useDeviceType(MENU_BREAKPOINT);
|
|
const { isCompact: isTextCompact } = useDeviceType(MENU_TEXT_BREAKPOINT);
|
|
const colonneGauche = getColonneGauche();
|
|
const colonneDroite = getColonneDroite();
|
|
|
|
const toggleItem = (label: string) => {
|
|
setOpenItem((prev) => (prev === label ? null : label));
|
|
};
|
|
|
|
const useSmallText = isCompact || isTextCompact;
|
|
|
|
const navContent = (
|
|
<>
|
|
<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={
|
|
useSmallText
|
|
? "flex w-full cursor-pointer items-center gap-4 font-poppins-regular text-[14px] text-white/90 transition-colors hover:text-white"
|
|
: "flex w-full cursor-pointer items-center gap-4 font-poppins-regular 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={
|
|
useSmallText
|
|
? "flex items-center gap-4 font-poppins-regular text-[14px] text-white/90 transition-colors hover:text-white"
|
|
: "flex items-center gap-4 font-poppins-regular 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={
|
|
useSmallText
|
|
? "flex items-center gap-2 font-poppins-regular text-[14px] text-white/80 transition-colors hover:text-white"
|
|
: "flex items-center gap-2 font-poppins-regular 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 sm:w-auto flex-col items-start gap-4">
|
|
{colonneDroite.map((item) =>
|
|
item.isCookieButton ? (
|
|
<li key={item.label}>
|
|
<CookieNoticeLink
|
|
label={item.label}
|
|
className={
|
|
useSmallText
|
|
? "font-poppins-regular text-[14px] text-white/90 transition-colors hover:text-white cursor-pointer"
|
|
: "font-poppins-regular text-body text-white/90 transition-colors hover:text-white cursor-pointer"
|
|
}
|
|
/>
|
|
</li>
|
|
) : (
|
|
<li key={item.label}>
|
|
<Link
|
|
href={item.href}
|
|
className={
|
|
useSmallText
|
|
? "font-poppins-regular text-[14px] text-white/90 transition-colors hover:text-white"
|
|
: "font-poppins-regular text-body text-white/90 transition-colors hover:text-white"
|
|
}
|
|
>
|
|
{item.label}
|
|
</Link>
|
|
</li>
|
|
),
|
|
)}
|
|
<li className="pb-2"></li>
|
|
</ul>
|
|
</>
|
|
);
|
|
|
|
const isMenu = variant === "menu";
|
|
|
|
if (isCompact) {
|
|
return (
|
|
<div
|
|
className={`flex flex-col items-start gap-10 ${
|
|
isMenu ? "px-4 pt-4 pb-8" : "px-6 py-10 max-w-[600px] mx-auto w-full"
|
|
}`}
|
|
>
|
|
<div
|
|
className={`order-1 w-full pt-6 md:pt-8 ${isMenu ? "hidden" : ""}`}
|
|
>
|
|
<FooterEleveurs />
|
|
</div>
|
|
|
|
<div className="order-2 flex w-full flex-col items-start gap-8 text-left">
|
|
<h2
|
|
className={`font-lato-black text-h3 uppercase leading-tight text-white ${
|
|
isMenu ? "hidden" : ""
|
|
}`}
|
|
>
|
|
Filière agricole engagée pour élever le bien-être animal
|
|
</h2>
|
|
|
|
<nav className="flex w-full flex-col sm:flex-row gap-8 sm:gap-14">
|
|
{navContent}
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
const wideMarginClass = isMenu
|
|
? "px-6 py-2 lg:px-12 lg:pb-12 lg:pt-2 w-full max-w-[1600px]"
|
|
: "px-6 sm:px-10 lg:px-16 py-8 lg:py-12 max-w-[1440px] mx-auto w-full";
|
|
|
|
return (
|
|
<div
|
|
className={`flex flex-row items-start justify-between gap-8 ${wideMarginClass}`}
|
|
>
|
|
<div
|
|
className={`order-2 ${isMenu ? "hidden xl:block" : "block"} w-auto self-end`}
|
|
>
|
|
<FooterEleveurs />
|
|
</div>
|
|
|
|
<div
|
|
className={`order-1 flex flex-col items-start text-left ${
|
|
isMenu
|
|
? "flex-1 max-w-[650px] gap-8"
|
|
: isTextCompact
|
|
? "flex-1 max-w-[480px] xl:max-w-[600px] gap-[48px]"
|
|
: "flex-1 max-w-[600px] gap-[72px]"
|
|
}`}
|
|
>
|
|
<h2
|
|
className={`font-lato-black uppercase leading-tight text-white ${
|
|
isTextCompact ? "text-h3" : "text-h2"
|
|
} ${isMenu ? "hidden" : ""}`}
|
|
>
|
|
Filière agricole engagée pour élever le bien-être animal
|
|
</h2>
|
|
|
|
<nav
|
|
className={`flex w-full flex-row ${
|
|
isTextCompact
|
|
? "gap-[36px] lg:gap-[48px]"
|
|
: "gap-[48px] lg:gap-[72px]"
|
|
}`}
|
|
>
|
|
{navContent}
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|