From 1ca4340e46f7fec3d2689cb8a3c60f9018ead048 Mon Sep 17 00:00:00 2001
From: sowgro <tpoke.ferrari@gmail.com>
Date: Tue, 17 Dec 2024 03:16:10 -0500
Subject: backup push: not quite working

---
 extension/src/components/ContextMenu.tsx | 51 ++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 extension/src/components/ContextMenu.tsx

(limited to 'extension/src/components/ContextMenu.tsx')

diff --git a/extension/src/components/ContextMenu.tsx b/extension/src/components/ContextMenu.tsx
new file mode 100644
index 0000000..058e9ba
--- /dev/null
+++ b/extension/src/components/ContextMenu.tsx
@@ -0,0 +1,51 @@
+import DeleteIcon from "../assets/delete.svg?react";
+import EditIcon from "../assets/edit.svg?react";
+import DragIcon from "../assets/drag.svg?react";
+import MoreIcon from "../assets/more.svg?react";
+import React, {useEffect, useState} from "react";
+
+function ContextMenu(props: {onEdit: (e: React.MouseEvent<HTMLButtonElement>) => void, onDelete: (e: React.MouseEvent<HTMLButtonElement>) => void}) {
+    const [open, setOpen] = useState(false)
+
+    useEffect(() => {
+        let evl = () => {
+            console.log("clicked")
+            open && setOpen(false);
+            console.log("evl unregistered")
+            document.body.removeEventListener('click', evl);
+        }
+        if (open) {
+            console.log("evl registered")
+            document.body.addEventListener('click', evl);
+        }
+    }, [open]);
+
+    return (
+        <div className={"overflow"}>
+            <button onClick={e => {
+                e.preventDefault();
+                setOpen(!open);
+            }}>
+                <MoreIcon/>
+            </button>
+            {open && <div className={"context-menu"}>
+                <button onClick={e => {
+                    setOpen(false);
+                    props.onEdit(e);
+                }}>
+                    <EditIcon />
+                    Edit
+                </button>
+                <button className={"del"} onClick={e => {
+                    setOpen(false);
+                    props.onDelete(e);
+                }}>
+                    <DeleteIcon/>
+                    Delete
+                </button>
+            </div>}
+        </div>
+    )
+}
+
+export default ContextMenu;
\ No newline at end of file
-- 
cgit v1.2.3

