ai-bot/app/_ui/SiderNav.tsx

50 lines
2.1 KiB
TypeScript
Raw Normal View History

"use client";
2025-01-16 10:38:01 +08:00
import Link from "next/link";
import { LinkTypeItem } from "../_lib/types";
import Logo from "./Logo";
import clsx from "clsx";
import { usePathname } from "next/navigation";
import { LinkType } from "../api/linkType/route";
2025-01-23 11:31:05 +08:00
import { useAtom } from "jotai";
import { linkTypeAtom } from "../_lib/atom";
export default function SiderNav({ linkList }: { linkList: LinkType[] }) {
const pathname = usePathname()
console.log(pathname);
2025-01-23 11:31:05 +08:00
const [selectType, setSelectType] = useAtom(linkTypeAtom)
2025-01-16 10:38:01 +08:00
return (
2025-01-16 18:30:24 +08:00
<div className="w-[220px] flex flex-col gap-y-2 fixed left-0 top-0 h-[100vh] bg-[#F9F9F9]">
2025-01-16 10:38:01 +08:00
<div>
<Logo />
</div>
2025-01-23 11:31:05 +08:00
<nav className="flex flex-col py-1">
2025-01-16 10:38:01 +08:00
{
linkList.map((item) => {
return (
item?.href ?
<Link className={clsx("cursor-pointer py-3 flex gap-x-2 items-center hover:bg-[#E0E0E0] rounded pl-3 hover:text-[#5961F9] text-[14px]",
pathname === item.href ? "text-[#5961F9]" : "text-[#515C6B]")
} href={item.href} key={item._id}>
2025-01-16 10:38:01 +08:00
{
item.iconElement
2025-01-16 10:38:01 +08:00
}
<span>{item.label}</span>
</Link> :
2025-01-23 11:31:05 +08:00
<div className="cursor-pointer py-3 flex gap-x-2 items-center hover:bg-[#E0E0E0] rounded pl-3 text-[#515C6B] hover:text-[#5961F9] text-[14px]" key={item._id}
onClick={() => {
setSelectType(item._id)
}}
>
<img src={item.icon as string} className="w-[20px] h-[20px] object-cover"></img>
2025-01-16 10:38:01 +08:00
<span>{item.label}</span>
</div>
)
})
}
</nav>
2025-01-16 10:38:01 +08:00
</div >
)
}