|
1
|
"use client" |
|
2
|
|
|
3
|
import clsx from "clsx" |
|
4
|
import Link from "next/link" |
|
5
|
import React from "react" |
|
6
|
import { MenuItem as MenuItemType, MenuItemLink } from "types" |
|
7
|
|
|
8
|
export type MenuItemProps = { |
|
9
|
item: MenuItemLink |
|
10
|
onClick?: (item: MenuItemType) => void |
|
11
|
} |
|
12
|
|
|
13
|
export const MenuItem = ({ item, onClick }: MenuItemProps) => { |
|
14
|
return ( |
|
15
|
<div className="px-docs_0.25"> |
|
16
|
<Link |
|
17
|
className={clsx( |
|
18
|
"flex py-docs_0.25 px-docs_0.5", |
|
19
|
"gap-docs_0.5 rounded-docs_xs", |
|
20
|
"hover:bg-medusa-bg-component-hover", |
|
21
|
"text-medusa-fg-base" |
|
22
|
)} |
|
23
|
href={item.link} |
|
24
|
onClick={() => onClick?.(item)} |
|
25
|
target={item.openInNewTab ? "_blank" : undefined} |
|
26
|
rel={item.openInNewTab ? "noopener noreferrer" : undefined} |
|
27
|
> |
|
28
|
{item.icon && ( |
|
29
|
<span className="text-medusa-fg-subtle mt-[2.5px] block"> |
|
30
|
{item.icon} |
|
31
|
</span> |
|
32
|
)} |
|
33
|
<span className="text-compact-small">{item.title}</span> |
|
34
|
</Link> |
|
35
|
</div> |
|
36
|
) |
|
37
|
} |