diff --git a/frontend/src/app/components/Sidebar.tsx b/frontend/src/app/components/Sidebar.tsx index b17fe68..3eaf13a 100644 --- a/frontend/src/app/components/Sidebar.tsx +++ b/frontend/src/app/components/Sidebar.tsx @@ -1,6 +1,7 @@ // components/Sidebar.tsx "use client"; +import { useState, useRef } from "react"; import { Pin } from "@/types/types"; import PinListItem from "./PinListItem"; import { DragDropContext, Droppable, DropResult } from "@hello-pangea/dnd"; @@ -20,58 +21,104 @@ export default function Sidebar({ setIsLoadModalOpen, setIsSubscribeModalOpen, }: SidebarProps) { -const handleDragEnd = (result: DropResult) => { - if (!result.destination) return; // Dropped outside the list - - const reorderedPins = Array.from(pins); - const [movedPin] = reorderedPins.splice(result.source.index, 1); - reorderedPins.splice(result.destination.index, 0, movedPin); - - setPins(reorderedPins); - }; + // State for sidebar width + const [sidebarWidth, setSidebarWidth] = useState(320); // Default width in pixels + + // Refs and state for dragging + const resizerRef = useRef(null); + const isResizing = useRef(false); + + const handleMouseDown = (e: React.MouseEvent) => { + isResizing.current = true; + document.addEventListener("mousemove", handleMouseMove); + document.addEventListener("mouseup", handleMouseUp); + }; + + const handleMouseMove = (e: MouseEvent) => { + if (!isResizing.current) return; + // Calculate new width + const newWidth = e.clientX; + if (newWidth >= 200 && newWidth <= 600) { + // Set min and max widths + setSidebarWidth(newWidth); + } + }; + + const handleMouseUp = () => { + isResizing.current = false; + document.removeEventListener("mousemove", handleMouseMove); + document.removeEventListener("mouseup", handleMouseUp); + }; + + const handleDragEnd = (result: DropResult) => { + if (!result.destination) return; // Dropped outside the list + + const reorderedPins = Array.from(pins); + const [movedPin] = reorderedPins.splice(result.source.index, 1); + reorderedPins.splice(result.destination.index, 0, movedPin); + + setPins(reorderedPins); + }; return ( -
-

Your Pins

- - - - {(provided) => ( -
    - {pins.map((pin, index) => ( - - ))} - {provided.placeholder} -
- )} -
-
+ <> +
+

Your Pins

+ + + {(provided) => ( +
    + {pins.map((pin, index) => ( + + ))} + {provided.placeholder} +
+ )} +
+
-
- +
+ + +
- -
+ + {/* Resizer */} +
+ ); }