diff --git a/src/App.tsx b/src/App.tsx index 64267fb..318ce26 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -21,10 +21,14 @@ function App() { const [showCodePanel, setShowCodePanel] = useState(false); const [showExcaliReactPanel, setShowExcaliReactPanel] = useState(true); + const [dividerPosition, setDividerPosition] = useState(50); // percentage const { excalidrawAPI } = useExcalidraw(); - const prevShowExcaliReactPanelRef = useRef(null); + const prevShowExcaliReactPanelRef = useRef(null); + + const containerRef = useRef(null); + const isDragging = useRef(false); const handlePreviewPanel = () => { prevShowExcaliReactPanelRef.current = showExcaliReactPanel; @@ -44,6 +48,26 @@ function App() { }, 0); } }, [excalidrawAPI, showExcaliReactPanel]); + // Divider logic + const handleMouseDown = () => { + isDragging.current = true; + }; + + const handleMouseMove = (e: React.MouseEvent) => { + if (!isDragging.current || !containerRef.current) return; + + const containerRect = containerRef.current.getBoundingClientRect(); + const newDividerPosition = + ((e.clientX - containerRect.left) / containerRect.width) * 100; + + if (newDividerPosition > 10 && newDividerPosition < 90) { + setDividerPosition(newDividerPosition); + } + }; + + const handleMouseUp = () => { + isDragging.current = false; + }; return (
@@ -57,11 +81,19 @@ function App() { -
+

@@ -87,9 +119,16 @@ function App() {

+
{showExcaliReactPanel && ( <> -
+

ExcaliReact App diff --git a/src/UIElementsDropdown.tsx b/src/UIElementsDropdown.tsx index 2d4c5d0..149d537 100644 --- a/src/UIElementsDropdown.tsx +++ b/src/UIElementsDropdown.tsx @@ -67,7 +67,7 @@ export const UIElementsDropdown = ({ UI Elements {showUiElements && ( -
+
{UIElements.map((uiElement) => (