From 4c7e1bc2bf7ed97d93649e40351b048a06b5d0fd Mon Sep 17 00:00:00 2001 From: sowgro Date: Fri, 6 Dec 2024 18:36:12 -0500 Subject: improve drag n drop and refactor --- extension/src/components/DropTargets.tsx | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 extension/src/components/DropTargets.tsx (limited to 'extension/src/components/DropTargets.tsx') diff --git a/extension/src/components/DropTargets.tsx b/extension/src/components/DropTargets.tsx new file mode 100644 index 0000000..297f366 --- /dev/null +++ b/extension/src/components/DropTargets.tsx @@ -0,0 +1,52 @@ +import React, {useEffect} from "react"; +import {ActiveDrag} from "./Body.tsx"; +import CreateFolderIcon from "../assets/create_folder.svg?react" + +function DropTarget(props: {children: React.ReactNode, className: string, onDrop: () => void}) { + let [drop, setDrop] = React.useState(false); + let [activeDrag, _] = React.useContext(ActiveDrag); + + useEffect(() => { + setDrop(false); + }, [activeDrag]); + + function handleDragOver(e: React.DragEvent) { + e.preventDefault() + setDrop(true) + } + + function handleDragLeave(e: React.DragEvent) { + setDrop(false) + } + + function handleDrop(e: React.DragEvent) { + e.preventDefault(); + props.onDrop(); + } + + return ( +
+ {props.children} +
+ ); +} + +function DropTargets(props: { onDropLeft: () => void, onDropRight: () => void, onDropCenter: () => void }) { + + return ( +
+ +
+ + +
+ + + + +
+ ); +} + +export default DropTargets; \ No newline at end of file -- cgit v1.2.3