forked from fahrPool/fahrPool
63 lines
2.1 KiB
TypeScript
63 lines
2.1 KiB
TypeScript
import type { Role } from "@/lib/auth/roles";
|
|
import { navigationFuer, PROFIL_ZIEL, type NavZiel } from "@/lib/navigation";
|
|
import { AktiverLink } from "@/components/navigation/AktiverLink";
|
|
|
|
const LINK =
|
|
"flex min-h-11 items-center text-asphalt-grey hover:text-performance-blue focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-performance-blue";
|
|
const AKTIV = "font-semibold text-performance-blue";
|
|
|
|
function Links({ ziele }: { ziele: NavZiel[] }) {
|
|
return ziele.map((ziel) => (
|
|
<AktiverLink key={ziel.href} href={ziel.href} className={LINK} aktivClassName={AKTIV}>
|
|
{ziel.label}
|
|
</AktiverLink>
|
|
));
|
|
}
|
|
|
|
export function NavLinks({
|
|
role,
|
|
orientation = "vertical",
|
|
}: {
|
|
role: Role;
|
|
orientation?: "vertical" | "horizontal";
|
|
}) {
|
|
const { haupt, verwaltung } = navigationFuer(role);
|
|
|
|
if (orientation === "horizontal") {
|
|
return (
|
|
<nav aria-label="Hauptnavigation" className="flex flex-row items-center gap-6">
|
|
<Links ziele={haupt} />
|
|
{verwaltung.length > 0 && (
|
|
<details className="relative">
|
|
<summary className={`${LINK} cursor-pointer list-none`}>Verwaltung ▾</summary>
|
|
<div className="absolute right-0 z-50 mt-2 flex w-56 flex-col gap-1 rounded-md border border-aluminium-grey bg-white p-3 shadow-lg">
|
|
<Links ziele={verwaltung} />
|
|
</div>
|
|
</details>
|
|
)}
|
|
<Links ziele={[PROFIL_ZIEL]} />
|
|
</nav>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<nav aria-label="Hauptnavigation" className="flex flex-col gap-6">
|
|
<section>
|
|
<h2 className="mb-1 text-xs font-semibold uppercase tracking-wide text-status-neutral">Navigation</h2>
|
|
<div className="flex flex-col gap-1">
|
|
<Links ziele={haupt} />
|
|
</div>
|
|
</section>
|
|
{verwaltung.length > 0 && (
|
|
<section>
|
|
<h2 className="mb-1 text-xs font-semibold uppercase tracking-wide text-status-neutral">Verwaltung</h2>
|
|
<div className="flex flex-col gap-1">
|
|
<Links ziele={verwaltung} />
|
|
</div>
|
|
</section>
|
|
)}
|
|
<Links ziele={[PROFIL_ZIEL]} />
|
|
</nav>
|
|
);
|
|
}
|