From 58d98dc1eba5332bb6a96cbdb9cbd58044770371 Mon Sep 17 00:00:00 2001 From: Saumya Pandey Date: Fri, 12 Feb 2021 18:01:18 +0530 Subject: [PATCH] Show top cursor if collection is hovered --- .../Sidebar/components/CollectionLink.js | 16 ++++---- .../Sidebar/components/Collections.js | 37 ++++++++++++++----- .../Sidebar/components/DropCursor.js | 6 ++- 3 files changed, 41 insertions(+), 18 deletions(-) diff --git a/app/components/Sidebar/components/CollectionLink.js b/app/components/Sidebar/components/CollectionLink.js index b9944824e0..a598cccf8e 100644 --- a/app/components/Sidebar/components/CollectionLink.js +++ b/app/components/Sidebar/components/CollectionLink.js @@ -78,26 +78,29 @@ function CollectionLink({ const [{ isCollectionDropping }, dropToReorderCollection] = useDrop({ accept: "collection", drop: async (item, monitor) => { - if (!collection) return; - //documents.move() console.log("move collection"); }, collect: (monitor) => ({ - isCollectionDroppping: monitor.isOver(), + isCollectionDropping: monitor.isOver(), }), }); // Drag to reorder Collection const [{ isCollectionDragging }, dragToReorderCollection] = useDrag({ - item: { type: "collection" }, + item: { type: "collection", activeCollectionId: ui.activeCollectionId }, collect: (monitor) => ({ isCollectionDragging: monitor.isDragging(), }), canDrag: (monitor) => { - ui.activeCollectionId = ""; //policies to allow admin return true; }, + begin: (monitor) => { + ui.activeCollectionId = ""; + }, + end: (monitor) => { + ui.activeCollectionId = monitor.activeCollectionId; + }, }); return ( @@ -147,11 +150,10 @@ function CollectionLink({ /> - {expanded && manualSort && ( )} - {isCollectionDropping && ( + {!expanded && ( { + //documents.move() + console.log("move collection"); + }, + collect: (monitor) => ({ + isCollectionDropping: monitor.isOver(), + }), + }); + const content = ( <> + {collections.orderedData.map((collection) => ( ); + if (!collections.isLoaded) { + return ( + +
{t("Collections")}
+ +
+ ); + } + return (
{t("Collections")}
- {collections.isLoaded ? ( - isPreloaded ? ( - content - ) : ( - {content} - ) - ) : ( - - )} + {isPreloaded ? content : {content}}
); } diff --git a/app/components/Sidebar/components/DropCursor.js b/app/components/Sidebar/components/DropCursor.js index 2eb584cf85..bb2df5d0d4 100644 --- a/app/components/Sidebar/components/DropCursor.js +++ b/app/components/Sidebar/components/DropCursor.js @@ -7,12 +7,14 @@ function DropCursor({ isActiveDrop, innerRef, theme, + from, }: { isActiveDrop: boolean, innerRef: React.Ref, theme: Theme, + from: string, }) { - return ; + return ; } // transparent hover zone with a thin visible band vertically centered @@ -25,7 +27,7 @@ const Cursor = styled("div")` width: 100%; height: 14px; - bottom: -7px; + ${(props) => (props.from === "collections" ? "top:15px;" : "bottom: -7px;")} background: transparent; ::after {