/* -------------------------------------------------------------------------- */ /* Imports */ /* -------------------------------------------------------------------------- */ import React, { Fragment } from "react"; import { Menu, Transition } from "@headlessui/react"; import { PropsPartion } from "./ContextMenuItem"; import classNames from "classnames"; import { SVGCaretDown } from "components/icons"; type ChildType = React.ReactElement; type ChildrenType = ChildType[] | ChildType; /* -------------------------------------------------------------------------- */ /* Component props */ /* -------------------------------------------------------------------------- */ type MenuProps = { emphasis?: "high" | "low"; disabled?: boolean; className?: string | undefined; button: React.ReactNode; children: ChildrenType; }; /* -------------------------------------------------------------------------- */ /* Styles */ /* -------------------------------------------------------------------------- */ const MenuButtonStyle = ` items-center inline-flex justify-center w-full cursor-default rounded border border-gray-100 outline-8 py-2 pl-4 pr-1 text-base`; const MenuItemStyle = ` absolute left-0 mt-2 w-60 origin-top-left rounded bg-white shadow-lg focus:outline-none py-2 px-4 sm:text-sm`; /* -------------------------------------------------------------------------- */ /* Component implementation */ /* -------------------------------------------------------------------------- */ /** * Use width ContextMenuAction.tsx , for example: * * alert('click')} * > * ... * */ export default function ContextMenu({ button, children, className, emphasis = "low", }: MenuProps) { return ( {({ open }) => ( <> {button} {children} )} ); }