62 lines
2.3 KiB
TypeScript
62 lines
2.3 KiB
TypeScript
"use client";
|
|
import React, { useState } from "react";
|
|
import { GoArrowLeft } from "react-icons/go";
|
|
import { menuItems } from "@/constants";
|
|
import Link from "next/link";
|
|
import { cn } from "@/lib/utils";
|
|
import { usePathname } from "next/navigation";
|
|
|
|
const SideMenu = () => {
|
|
const [open, setOpen] = useState(false);
|
|
const pathname = usePathname();
|
|
|
|
return (
|
|
<div
|
|
className={` flex flex-col items-start justify-start bg-gradient-to-b from-yellow to-orange-400 h-screen rounded-l-[30px] fixed right-0 top-0 transition-all duration-700 ease-in-out
|
|
${open === true ? "w-[70px]" : "w-[200px]"} `}
|
|
>
|
|
<div
|
|
onClick={() => setOpen(!open)}
|
|
className={`flex items-center aspect-square bg-white rounded-full shadow-[0_0_4px_1px_rgba(0,0,0,0.1)] text-yellow cursor-pointer h-8 w-8 justify-center -left-3 absolute top-5 transition-all duration-700 ease-in-out z-[400]
|
|
${open === true ? "rotate-0" : "rotate-180"} `}
|
|
>
|
|
<GoArrowLeft className="text-yellow" />
|
|
</div>
|
|
<div>
|
|
<ul className="flex flex-1 flex-col items-start justify-start pt-5 ">
|
|
{menuItems.map((menuItem) => (
|
|
<Link
|
|
href={menuItem.href}
|
|
key={menuItem.id}
|
|
className="flex justify-start items-center mb-5 pr-4 text-white"
|
|
>
|
|
<div
|
|
className={cn(
|
|
"w-10 h-10 aspect-square rounded-md flex items-center justify-center transition-all duration-[0.3s]",
|
|
pathname == menuItem.href && "bg-black/30"
|
|
)}
|
|
>
|
|
<span className="w-1/2 h-1/2 aspect-square flex items-center justify-center text-white transition-all duration-[0.3s] text-lg">
|
|
{menuItem.icon}
|
|
</span>
|
|
</div>
|
|
<span
|
|
className={cn(
|
|
`text-xs text-white mr-1 overflow-hidden font-bold transition-all duration-1000 ease-in-out`,
|
|
pathname == menuItem.href && "text-black/70 text-[13px]",
|
|
menuItem.id == 2 && "font-extrabold",
|
|
open === true ? "w-0 opacity-0" : "w-auto opacity-100 "
|
|
)}
|
|
>
|
|
{menuItem.title}
|
|
</span>
|
|
</Link>
|
|
))}
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default SideMenu;
|