Skip to content

Commit

Permalink
griditem drag drop
Browse files Browse the repository at this point in the history
  • Loading branch information
heswell committed Sep 7, 2024
1 parent d33d891 commit a7db2f0
Show file tree
Hide file tree
Showing 11 changed files with 320 additions and 288 deletions.
1 change: 1 addition & 0 deletions vuu-ui/packages/vuu-layout/src/grid-layout/GridLayout.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
.vuuGridLayoutItemHeader {
align-items: center;
background-color: #ccc;
cursor: grab;
display: flex;
flex: 0 0 var(--vuu-header-height);
inset: var(--vuu-grid-gap) var(--vuu-grid-gap) auto var(--vuu-grid-gap);
Expand Down
20 changes: 11 additions & 9 deletions vuu-ui/packages/vuu-layout/src/grid-layout/GridLayoutItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
useDraggable,
useGridLayoutDragStartHandler,
useGridLayoutProps,
useGridLayoutProviderDispatch
useGridLayoutProviderDispatch,
} from "@finos/vuu-layout";
import { IconButton } from "@finos/vuu-ui-controls";
import { useComponentCssInjection } from "@salt-ds/styles";
Expand All @@ -13,7 +13,7 @@ import {
DragEvent,
HTMLAttributes,
MouseEventHandler,
useCallback
useCallback,
} from "react";
import { GridResizeable } from "./GridLayout";
import { useAsDropTarget } from "./useAsDropTarget";
Expand Down Expand Up @@ -58,12 +58,12 @@ export const GridLayoutItem = ({
useComponentCssInjection({
testId: "vuu-grid-layout",
css: gridLayoutCss,
window: targetWindow
window: targetWindow,
});
useComponentCssInjection({
testId: "vuu-grid-splitter",
css: gridSplitterCss,
window: targetWindow
window: targetWindow,
});

const dispatch = useGridLayoutProviderDispatch();
Expand All @@ -75,7 +75,7 @@ export const GridLayoutItem = ({
evt.stopPropagation();
dispatch({ type: "close", id });
},
[dispatch, id]
[dispatch, id],
);

const getPayload = useCallback(
Expand All @@ -86,27 +86,29 @@ export const GridLayoutItem = ({
}
throw Error("GridLayoutItem no found");
},
[]
[],
);

const getDragImg = useCallback(() => {}, []);

const useDropTargetHook = isDropTarget ? useAsDropTarget : useNotDropTarget;
const { dropTargetClassName, ...droppableProps } = useDropTargetHook();
const draggableProps = useDraggable({
draggableClassName: classBaseItem,
getPayload,
onDragStart
onDragStart,
});

const className = cx(classBaseItem, {
[`${classBaseItem}-resizeable-h`]: resizeable === "h",
[`${classBaseItem}-resizeable-v`]: resizeable === "v",
[`${classBaseItem}-resizeable-vh`]: resizeable === "hv"
[`${classBaseItem}-resizeable-vh`]: resizeable === "hv",
});

const style = {
...styleProp,
...layoutProps,
"--header-height": header ? "25px" : "0px"
"--header-height": header ? "25px" : "0px",
};

return (
Expand Down
Loading

0 comments on commit a7db2f0

Please sign in to comment.