diff --git a/src/components/ContextMenu.tsx b/src/components/ContextMenu.tsx deleted file mode 100644 index 0073083..0000000 --- a/src/components/ContextMenu.tsx +++ /dev/null @@ -1,115 +0,0 @@ -/* -------------------------------------------------------------------------- */ -/* Imports */ -/* -------------------------------------------------------------------------- */ -import React, { Fragment } from "react"; -import { Menu, Transition } from "@headlessui/react"; -import { PropsPartion } from "./ContextMenuItem"; -import classNames from "classnames"; -import { ReactComponent as SelectIcon } from "assets/svg/select-arrow.svg"; -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 = ` -inline-flex -justify-center w-full -cursor-default -rounded -border border-gray-100 -outline-8 -py-2 -px-2 -text-base`; - -const MenuItemStyle = ` -absolute -left-0 -mt-2 w-60 -origin-top-left -rounded -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} - - - - )} - - ); -} diff --git a/src/components/ContextMenuAction.tsx b/src/components/ContextMenuAction.tsx deleted file mode 100644 index 8d1e653..0000000 --- a/src/components/ContextMenuAction.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import classNames from "classnames"; -import React from "react"; - -type Props = { - action: Function; - caption: string; - disabled?: boolean; - icon?: React.ReactNode; - className?: string | undefined; -}; - -export default function ContextMenuAction({ - action, - caption, - disabled, - icon, - className, -}: Props) { - return ( - action(e)} - className={classNames([ - "group flex px-2 rounded items-center text-base hover:bg-gray-100", - className, - ])} - > - {icon &&
{icon}
} - {caption} -
- ); -} diff --git a/src/components/drop-down-menu/ContextMenu.tsx b/src/components/drop-down-menu/ContextMenu.tsx index 16b7c0c..e3c7866 100644 --- a/src/components/drop-down-menu/ContextMenu.tsx +++ b/src/components/drop-down-menu/ContextMenu.tsx @@ -5,7 +5,7 @@ import React, { Fragment } from "react"; import { Menu, Transition } from "@headlessui/react"; import { PropsPartion } from "./ContextMenuItem"; import classNames from "classnames"; -import { ReactComponent as SelectIcon } from "assets/svg/select-arrow.svg"; +import { SVGCaretDown } from "components/icons"; type ChildType = React.ReactElement; type ChildrenType = ChildType[] | ChildType; @@ -25,13 +25,13 @@ type MenuProps = { /* -------------------------------------------------------------------------- */ const MenuButtonStyle = ` +items-center inline-flex justify-center w-full cursor-default rounded border border-gray-100 outline-8 -bg-white py-2 pl-4 pr-1 @@ -43,7 +43,7 @@ left-0 mt-2 w-60 origin-top-left rounded -bg-white +bg-white shadow-lg focus:outline-none py-2 px-4 sm:text-sm`; @@ -51,17 +51,17 @@ py-2 px-4 sm:text-sm`; /* -------------------------------------------------------------------------- */ /* Component implementation */ /* -------------------------------------------------------------------------- */ -/** -* Use width ContextMenuAction.tsx , for example: -* -* alert('click')} -* > -* ... -* -*/ +/** + * Use width ContextMenuAction.tsx , for example: + * + * alert('click')} + * > + * ... + * + */ export default function ContextMenu({ button, children, @@ -69,48 +69,50 @@ export default function ContextMenu({ emphasis = "low", }: MenuProps) { return ( - - {({ open }) => ( - <> - + {({ open }) => ( + <> + + {button} + + + + - {button} - - - - - {children} - - - - )} - + {children} + + + + )} + ); } diff --git a/src/components/drop-down-menu/ContextMenuAction.tsx b/src/components/drop-down-menu/ContextMenuAction.tsx index 2023fb1..8d1e653 100644 --- a/src/components/drop-down-menu/ContextMenuAction.tsx +++ b/src/components/drop-down-menu/ContextMenuAction.tsx @@ -1,7 +1,6 @@ import classNames from "classnames"; import React from "react"; - type Props = { action: Function; caption: string; @@ -18,19 +17,16 @@ export default function ContextMenuAction({ className, }: Props) { return ( - - + ); } -