"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { curriculum } from "@/lib/curriculum"; import { cn } from "@/lib/utils"; import { useState } from "react"; const unitColorMap = { "unit-1": { active: "bg-unit-1-light text-unit-1-dark border-unit-1/20", dot: "bg-unit-1", heading: "text-unit-1-dark", hoverBg: "hover:bg-unit-1-light/50", }, "unit-2": { active: "bg-unit-2-light text-unit-2-dark border-unit-2/20", dot: "bg-unit-2", heading: "text-unit-2-dark", hoverBg: "hover:bg-unit-2-light/50", }, "unit-3": { active: "bg-unit-3-light text-unit-3-dark border-unit-3/20", dot: "bg-unit-3", heading: "text-unit-3-dark", hoverBg: "hover:bg-unit-3-light/50", }, "unit-4": { active: "bg-unit-4-light text-unit-4-dark border-unit-4/20", dot: "bg-unit-4", heading: "text-unit-4-dark", hoverBg: "hover:bg-unit-4-light/50", }, }; export function Sidebar() { const pathname = usePathname(); const [openUnits, setOpenUnits] = useState>(() => { const open = new Set(); for (const unit of curriculum) { if (pathname.includes(unit.slug)) { open.add(unit.number); } } if (open.size === 0) open.add(1); return open; }); function toggleUnit(num: number) { setOpenUnits((prev) => { const next = new Set(prev); if (next.has(num)) next.delete(num); else next.add(num); return next; }); } return ( ); }