forked from matijagrcic/azurechatgpt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.tsx
70 lines (61 loc) · 1.68 KB
/
menu.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import * as React from "react";
import { cn } from "@/lib/utils";
import Link from "next/link";
const Menu = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div ref={ref} className={cn("w-64 flex flex-col", className)} {...props} />
));
Menu.displayName = "Menu";
const MenuHeader = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("flex pb-2 justify-between items-center", className)}
{...props}
/>
));
MenuHeader.displayName = "MenuHeader";
const MenuContent = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn(
"flex flex-col flex-1 overflow-y-auto py-2 gap-0.5",
className
)}
{...props}
/>
));
MenuContent.displayName = "MenuContent";
interface MenuItemProps extends React.HTMLAttributes<HTMLLinkElement> {
href: string;
isSelected?: boolean;
}
const MenuItem: React.FC<MenuItemProps> = (props) => {
return (
<Link
className={cn(
props.className,
"items-center text-sm font-medium flex gap-2 p-2 py-1 rounded-md hover:bg-primary/10",
props.isSelected && "bg-primary/10"
)}
href={props.href}
>
{props.children}
</Link>
);
};
const MenuFooter = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div ref={ref} className={cn("flex flex-col", className)} {...props} />
));
MenuFooter.displayName = "MenuFooter";
export { Menu, MenuContent, MenuFooter, MenuHeader, MenuItem };