changed icon component, paddings
This commit is contained in:
parent
dd231a1903
commit
f8c1141e8c
@ -3,9 +3,9 @@
|
|||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
import React, { Fragment } from "react";
|
import React, { Fragment } from "react";
|
||||||
import { Menu, Transition } from "@headlessui/react";
|
import { Menu, Transition } from "@headlessui/react";
|
||||||
import { PropsPartion } from "./ContextMenuItem";
|
import { PropsPartion } from "./drop-down-menu/ContextMenuItem";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { ReactComponent as SelectIcon } from "assets/svg/select-arrow.svg";
|
import { SVGCaretDown } from "components/icons";
|
||||||
type ChildType = React.ReactElement<any & PropsPartion[]>;
|
type ChildType = React.ReactElement<any & PropsPartion[]>;
|
||||||
type ChildrenType = ChildType[] | ChildType;
|
type ChildrenType = ChildType[] | ChildType;
|
||||||
|
|
||||||
@ -25,13 +25,13 @@ type MenuProps = {
|
|||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
const MenuButtonStyle = `
|
const MenuButtonStyle = `
|
||||||
|
items-center
|
||||||
inline-flex
|
inline-flex
|
||||||
justify-center w-full
|
justify-center w-full
|
||||||
cursor-default
|
cursor-default
|
||||||
rounded
|
rounded
|
||||||
border border-gray-100
|
border border-gray-100
|
||||||
outline-8
|
outline-8
|
||||||
bg-white
|
|
||||||
py-2
|
py-2
|
||||||
pl-4
|
pl-4
|
||||||
pr-1
|
pr-1
|
||||||
@ -52,16 +52,16 @@ py-2 px-4 sm:text-sm`;
|
|||||||
/* Component implementation */
|
/* Component implementation */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/**
|
/**
|
||||||
* Use width ContextMenuAction.tsx , for example:
|
* Use width ContextMenuAction.tsx , for example:
|
||||||
* <ContextMenu button="MyButton" emphasis="low/high">
|
* <ContextMenu button="MyButton" emphasis="low/high">
|
||||||
* <ContextMenuAction
|
* <ContextMenuAction
|
||||||
* caption="First Menu"
|
* caption="First Menu"
|
||||||
* icon={icon}
|
* icon={icon}
|
||||||
* action={() => alert('click')}
|
* action={() => alert('click')}
|
||||||
* ></ContextMenuAction>
|
* ></ContextMenuAction>
|
||||||
* ...
|
* ...
|
||||||
* </ContextMenu>
|
* </ContextMenu>
|
||||||
*/
|
*/
|
||||||
export default function ContextMenu({
|
export default function ContextMenu({
|
||||||
button,
|
button,
|
||||||
children,
|
children,
|
||||||
@ -75,15 +75,17 @@ export default function ContextMenu({
|
|||||||
<Menu.Button
|
<Menu.Button
|
||||||
className={classNames([
|
className={classNames([
|
||||||
`${MenuButtonStyle}`,
|
`${MenuButtonStyle}`,
|
||||||
{ "bg-gray-100 font-bold uppercase": emphasis === "high" },
|
{
|
||||||
|
"hover:bg-gray-100 font-bold uppercase": emphasis === "high",
|
||||||
|
},
|
||||||
className,
|
className,
|
||||||
])}
|
])}
|
||||||
>
|
>
|
||||||
{button}
|
{button}
|
||||||
<SelectIcon
|
<SVGCaretDown
|
||||||
className={`${
|
className={`${
|
||||||
open ? "rotate-180 transform" : "font-normal"
|
open ? "rotate-180 transform" : "font-normal"
|
||||||
} my-2 mx-3 h-2 w-3 flex-center`}
|
} my-2 mx-3 w-4 flex-center fill-gray-900 stroke-gray-900`}
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
/>
|
/>
|
||||||
</Menu.Button>
|
</Menu.Button>
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
action: Function;
|
action: Function;
|
||||||
caption: string;
|
caption: string;
|
||||||
@ -18,19 +17,16 @@ export default function ContextMenuAction({
|
|||||||
className,
|
className,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
return (
|
return (
|
||||||
<button
|
<a
|
||||||
|
href="#"
|
||||||
onClick={(e) => action(e)}
|
onClick={(e) => action(e)}
|
||||||
disabled={disabled}
|
|
||||||
className={classNames([
|
className={classNames([
|
||||||
"group flex items-center text-base",
|
"group flex px-2 rounded items-center text-base hover:bg-gray-100",
|
||||||
{ "opacity-50": disabled, "cursor-default": !disabled },
|
|
||||||
className,
|
className,
|
||||||
])}
|
])}
|
||||||
>
|
>
|
||||||
{icon && <div className="mr-2 h-5 w-5">{icon}</div>}
|
{icon && <div className="mr-2 h-5 w-5">{icon}</div>}
|
||||||
<span className="px-2 py-2">{caption}</span>
|
<span className="px-2 py-2">{caption}</span>
|
||||||
</button>
|
</a>
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user