Files
caszl-next/app/_components/LeftNav.tsx

54 lines
1.5 KiB
TypeScript
Raw Normal View History

2023-10-29 22:25:16 +08:00
"use client";
2023-11-01 17:27:06 +08:00
2023-10-27 17:29:50 +08:00
import Image from "next/image";
2023-11-06 17:27:50 +08:00
import circle from "@/app/_assets/circle.png";
2023-10-27 17:29:50 +08:00
import styles from "./LeftNav.module.scss";
import Link from "next/link";
2023-10-29 22:25:16 +08:00
import { usePathname } from "next/navigation";
2023-10-27 17:29:50 +08:00
2023-10-29 22:25:16 +08:00
const LeftNav = ({
navigations,
title,
}: {
2023-11-01 17:27:06 +08:00
navigations?: any[];
2023-10-29 22:25:16 +08:00
title: string;
}) => {
const pathname = usePathname();
2023-10-27 17:29:50 +08:00
return (
2023-10-30 17:29:35 +08:00
<div
className={
2023-11-03 17:25:10 +08:00
"left-nav h-full min-h-[600px] rounded bg-[#d7ecfd] pt-2 shadow"
2023-10-30 17:29:35 +08:00
}
>
2023-11-03 17:25:10 +08:00
<div className={"flex h-7 items-center pl-2"}>
2023-10-27 17:29:50 +08:00
<Image src={circle} alt={"circle icon"} height={16} width={16} />
2023-10-29 22:25:16 +08:00
<span className={"pl-2"}>{title}</span>
2023-10-27 17:29:50 +08:00
</div>
2023-11-01 17:27:06 +08:00
{(navigations?.length ?? 0) > 0 && (
2023-10-29 22:25:16 +08:00
<div
2023-11-03 17:25:10 +08:00
className={`${styles.navContent} mx-3 mt-3 rounded-lg px-2.5 py-[5px]`}
2023-10-29 22:25:16 +08:00
>
<ul className={styles.navItems}>
2023-11-01 17:27:06 +08:00
{navigations?.map((navigation) => (
2023-10-29 22:25:16 +08:00
<li key={navigation.href}>
<Link
2023-11-03 17:25:10 +08:00
className={`flex h-[34px] items-center px-[9px] text-sm font-bold transition-all hover:text-xs hover:text-[#fff176] ${
2023-10-29 22:25:16 +08:00
navigation.href === pathname
2023-11-03 17:25:10 +08:00
? "text-xs text-[#fff176]"
2023-10-29 22:25:16 +08:00
: "text-white"
}`}
href={navigation.href}
>
{navigation.title}
</Link>
</li>
))}
</ul>
</div>
)}
2023-10-27 17:29:50 +08:00
</div>
);
};
export default LeftNav;