mirror of
https://github.com/cssgunc/compass.git
synced 2025-04-21 18:59:49 -04:00
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
//delete, duplicate, open
|
|
import {
|
|
TrashIcon,
|
|
DocumentDuplicateIcon,
|
|
ArrowUpRightIcon,
|
|
EllipsisVerticalIcon,
|
|
EyeSlashIcon,
|
|
} from "@heroicons/react/24/solid";
|
|
import Button from "../Button";
|
|
import { useState, useEffect, useRef } from "react";
|
|
import { RowOption } from "./RowOption";
|
|
|
|
export const RowOptionMenu = ({ onDelete, onHide }) => {
|
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
const openMenu = () => setMenuOpen(true);
|
|
const closeMenu = () => setMenuOpen(false);
|
|
|
|
// TODO: Hide menu if clicked elsewhere
|
|
|
|
return (
|
|
<>
|
|
<button
|
|
className="items-end"
|
|
onClick={() => setMenuOpen(!menuOpen)}
|
|
>
|
|
<EllipsisVerticalIcon className="h-4" />
|
|
</button>
|
|
<div
|
|
className={
|
|
"justify-start border border-gray-200 shadow-lg flex flex-col absolute bg-white w-auto p-2 rounded [&>*]:rounded z-10" +
|
|
(!menuOpen ? " invisible" : "")
|
|
}
|
|
>
|
|
<RowOption icon={TrashIcon} label="Delete" onClick={onDelete} />
|
|
<RowOption
|
|
icon={ArrowUpRightIcon}
|
|
label="Open"
|
|
onClick={() => {
|
|
/* handle open */
|
|
}}
|
|
/>
|
|
<RowOption icon={EyeSlashIcon} label="Hide" onClick={onHide} />
|
|
</div>
|
|
</>
|
|
);
|
|
};
|