mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import MenuItemContent from "./DropdownMenuItemContent";
|
|
import React from "react";
|
|
import {
|
|
getDropdownMenuItemClassName,
|
|
useHandleDropdownMenuItemClick,
|
|
} from "./common";
|
|
|
|
const DropdownMenuItemLink = ({
|
|
icon,
|
|
shortcut,
|
|
href,
|
|
children,
|
|
onSelect,
|
|
className = "",
|
|
selected,
|
|
rel = "noreferrer",
|
|
...rest
|
|
}: {
|
|
href: string;
|
|
icon?: JSX.Element;
|
|
children: React.ReactNode;
|
|
shortcut?: string;
|
|
className?: string;
|
|
selected?: boolean;
|
|
onSelect?: (event: Event) => void;
|
|
rel?: string;
|
|
} & React.AnchorHTMLAttributes<HTMLAnchorElement>) => {
|
|
const handleClick = useHandleDropdownMenuItemClick(rest.onClick, onSelect);
|
|
|
|
return (
|
|
<a
|
|
{...rest}
|
|
href={href}
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
className={getDropdownMenuItemClassName(className, selected)}
|
|
title={rest.title ?? rest["aria-label"]}
|
|
onClick={handleClick}
|
|
>
|
|
<MenuItemContent icon={icon} shortcut={shortcut}>
|
|
{children}
|
|
</MenuItemContent>
|
|
</a>
|
|
);
|
|
};
|
|
|
|
export default DropdownMenuItemLink;
|
|
DropdownMenuItemLink.displayName = "DropdownMenuItemLink";
|