Skip to content

Commit

Permalink
typescript :)
Browse files Browse the repository at this point in the history
  • Loading branch information
Badbird5907 committed Jul 3, 2024
1 parent 9182127 commit af62219
Showing 1 changed file with 53 additions and 49 deletions.
102 changes: 53 additions & 49 deletions src/components/dashboard/menu.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import Link from "next/link";
import { Ellipsis, LogOut } from "lucide-react";
import { Ellipsis, LogOut, LucideIcon } from "lucide-react";
import { usePathname } from "next/navigation";

import { cn } from "@/lib/utils";
Expand Down Expand Up @@ -51,55 +51,59 @@ export function Menu({ isOpen }: MenuProps) {
<p className="pb-2"></p>
)}
{menus.map(
({ href, label, icon: Icon, active, submenus }, index) =>
submenus.length === 0 ? (
<div className="w-full" key={index}>
<TooltipProvider disableHoverableContent>
<Tooltip delayDuration={100}>
<TooltipTrigger asChild>
<Button
variant={active ? "secondary" : "ghost"}
className="w-full justify-start h-10 mb-1"
asChild
>
<Link href={href}>
<span
className={cn(isOpen === false ? "" : "mr-4")}
>
<Icon size={18} />
</span>
<p
className={cn(
"max-w-[200px] truncate",
isOpen === false
? "-translate-x-96 opacity-0"
: "translate-x-0 opacity-100"
)}
>
{label}
</p>
</Link>
</Button>
</TooltipTrigger>
{isOpen === false && (
<TooltipContent side="right">
{label}
</TooltipContent>
)}
</Tooltip>
</TooltipProvider>
</div>
) : (
<div className="w-full" key={index}>
<CollapseMenuButton
icon={Icon}
label={label}
active={active}
submenus={submenus}
isOpen={isOpen}
/>
</div>
({ href, label, icon: Icon1, active, submenus }, index) => {
const Icon: LucideIcon = Icon1 as LucideIcon;
return (
submenus.length === 0 ? (
<div className="w-full" key={index}>
<TooltipProvider disableHoverableContent>
<Tooltip delayDuration={100}>
<TooltipTrigger asChild>
<Button
variant={active ? "secondary" : "ghost"}
className="w-full justify-start h-10 mb-1"
asChild
>
<Link href={href}>
<span
className={cn(isOpen === false ? "" : "mr-4")}
>
<Icon size={18} />
</span>
<p
className={cn(
"max-w-[200px] truncate",
isOpen === false
? "-translate-x-96 opacity-0"
: "translate-x-0 opacity-100"
)}
>
{label}
</p>
</Link>
</Button>
</TooltipTrigger>
{isOpen === false && (
<TooltipContent side="right">
{label}
</TooltipContent>
)}
</Tooltip>
</TooltipProvider>
</div>
) : (
<div className="w-full" key={index}>
<CollapseMenuButton
icon={Icon}
label={label}
active={active}
submenus={submenus}
isOpen={isOpen}
/>
</div>
)
)
}
)}
</li>
))}
Expand Down

0 comments on commit af62219

Please sign in to comment.