shahrbin-citizen/components/Menu/SideMenu.tsx

60 lines
2.2 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";
const SideMenu = () => {
const [open, setOpen] = useState(false);
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-[200px]" : "w-[70px]"} `}
>
<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-180" : "rotate-0"} `}
>
<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]",
menuItem.id == 1 && "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 transition-all overflow-hidden font-bold`,
menuItem.id == 1 && "text-black/70 text-[13px]",
menuItem.id == 2 && "font-extrabold",
open === true ? "w-auto opacity-100 " : "w-0 opacity-0"
)}
>
{menuItem.title}
</span>
</Link>
))}
</ul>
</div>
</div>
);
};
export default SideMenu;