From 483f45765d52c1fbaf6ac2797b3d72b2d96c303c Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Sun, 17 Mar 2024 16:35:59 +0800 Subject: [PATCH] refactor: colDivider style improve for draging overing (#3709) * refactor: colDivider style improve for draging overing * refactor: stle improve * style: grid.Col style improve --- .../src/schema-component/antd/grid/Grid.tsx | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/packages/core/client/src/schema-component/antd/grid/Grid.tsx b/packages/core/client/src/schema-component/antd/grid/Grid.tsx index fe2edbfff..bd0adb590 100644 --- a/packages/core/client/src/schema-component/antd/grid/Grid.tsx +++ b/packages/core/client/src/schema-component/antd/grid/Grid.tsx @@ -448,8 +448,7 @@ Grid.Col = observer( } return { width }; }, [cols?.length, schema?.['x-component-props']?.['width']]); - - const { setNodeRef } = useDroppable({ + const { isOver, setNodeRef } = useDroppable({ id: field.address.toString(), data: { insertAdjacent: 'beforeEnd', @@ -457,9 +456,41 @@ Grid.Col = observer( wrapSchema: (s) => s, }, }); + const [active, setActive] = useState(false); + + const droppableStyle = useMemo(() => { + if (!isOver) + return { + height: '100%', + }; + + return { + background: `linear-gradient(to top, ${new TinyColor(token.colorSettings) + .setAlpha(0.1) + .toHex8String()} 20%, transparent 20%)`, + borderTopRightRadius: '10px', + borderTopLeftRadius: '10px', + height: '100%', + }; + }, [active, isOver]); + + useDndMonitor({ + onDragStart(event) { + setActive(true); + }, + onDragMove(event) {}, + onDragOver(event) {}, + onDragEnd(event) { + setActive(false); + }, + onDragCancel(event) { + setActive(false); + }, + }); + return ( -
+
{props.children}