Skip to content

Commit fac6bb0

Browse files
Implemented visual hints on repositioning (#726)
* Initial wiring for drag and drop visual hints done * Create custom hook for visual hint on drag * Drop zone hint logic for visual hints done * Created context for probable parent * Setting context for probable parent * Gives hint when probable parent is found * wip: removing the hint overlay * Solved bug where overlay was not removed properly * Removed redundant code * Removed moved while drag event being sent to editor machine * Created DROPZONE_CREATED and DROPZONE_DESTROYED events * Showing visual hints when drop zone created * Destroyed overlays on dropzone destroyed * Renamed files to signify common functionality * Show hints when reposition is active * Renamed to useDropzoneHints * Remove overlay if overlay is present * If mouse is in the the reposition element then remove overlays * wip: Solved bug where parent that is a child to a parent does not get the overlay * Destroying the previous overlay before creating a new overlay * Nested repeating & overlay adapted for repeating component (#720) * bugfix: before_app_load to unset the comp id state * handleBreakpointChange & bugfix * removed console.log * select overlay done * overlay for hover done * bugfix: update hovered on re-hoverWhileSelected * removed console.log * overlay on reposition * python files are generated from react manifest * generate __init__.py file * atri_core is publishable * python manifest project built using package.json * bugfix: call join after map * wip: generate python model for each page * python page model gets generated * generate python models in dev mode * dev mode for generate python routes done * create alias on drop done * change alias using aliasApi done * action layer added * bugfix: add .jsx random extension for IRToUnixFilepath to work * removed canvas-zone-manager package * support for shared libs in tool * asset manager integrated * removed react-shim manifest-shims packages * resource layer integrated * imported fonts reflect in editor * bugfix: remove duplicate import * manifest in example-atri-app populates in editor & app * removed install-scripts * createComponentManifest done * build editor for production * pwa-builder-server serves pwa-builder * @atrilabs/new package invoked to create a new atri app * changes main to bin * page scaffold includes canvas zone * expose pwa-builder-server binary & new package * package.json version set to 1.0.0-alpha.0 * removed app-scripts & app-generator package * removed webapp-builder package * removed scripts * removed packages not to be shipped in 1.0.0-alpha.0 * installed missing dependencies * package.json updated * v1.0.0-alpha.0 * fix: serve manifest registry * fixes: updated missing deps in create-atri-app * __version__ set to 1.0.0-alpha.1 * v1.0.0-alpha.1 * fix: pwa-builder build command without manifests * v1.0.0-alpha.2 * fix: use uuid vs @atrilabs/core * v1.0.0-alpha.3 * new parameters inside quotes * v1.0.0-alpha.4 * copy-paste inside component done * canvas zone as paste target done * up/down arrow key works * create component undo/redo done * wip: undo-redo * undo-redo done * wip: component navigator data compute done * wip: component navigator update on alias change * component navigator open close done * patchCb called on comp navigator reposition * raise hover & select from comp navigator * select on reposition/rewire end * fix: sort the direct child of canvas * __version__ set to 1.0.0-alpha.5 * v1.0.0-alpha.5 * yarn editor register new components from manifests dir * build manifest python packages inside manifests done * build manifest python packages inside manifests done * wip: wiring for fetching user events done * wip: live canvas zone with components done * live canvas zone with components done * callbacks attached in live mode * wip: hook with python * /_atri/api/event request is sent to python * handle event updates live view * fix: make sure alias patch is sent later * bugfix: drag-drop disappearing * bugfix: new dragged node is set on togglenode * atri-comp-id & atri-parent-marker assigned * overlays adapted for repeating list * removed log statement * __version__ set to 1.0.0-alpha.6 (#721) * bugfix: before_app_load to unset the comp id state * handleBreakpointChange & bugfix * removed console.log * select overlay done * overlay for hover done * bugfix: update hovered on re-hoverWhileSelected * removed console.log * overlay on reposition * python files are generated from react manifest * generate __init__.py file * atri_core is publishable * python manifest project built using package.json * bugfix: call join after map * wip: generate python model for each page * python page model gets generated * generate python models in dev mode * dev mode for generate python routes done * create alias on drop done * change alias using aliasApi done * action layer added * bugfix: add .jsx random extension for IRToUnixFilepath to work * removed canvas-zone-manager package * support for shared libs in tool * asset manager integrated * removed react-shim manifest-shims packages * resource layer integrated * imported fonts reflect in editor * bugfix: remove duplicate import * manifest in example-atri-app populates in editor & app * removed install-scripts * createComponentManifest done * build editor for production * pwa-builder-server serves pwa-builder * @atrilabs/new package invoked to create a new atri app * changes main to bin * page scaffold includes canvas zone * expose pwa-builder-server binary & new package * package.json version set to 1.0.0-alpha.0 * removed app-scripts & app-generator package * removed webapp-builder package * removed scripts * removed packages not to be shipped in 1.0.0-alpha.0 * installed missing dependencies * package.json updated * v1.0.0-alpha.0 * fix: serve manifest registry * fixes: updated missing deps in create-atri-app * __version__ set to 1.0.0-alpha.1 * v1.0.0-alpha.1 * fix: pwa-builder build command without manifests * v1.0.0-alpha.2 * fix: use uuid vs @atrilabs/core * v1.0.0-alpha.3 * new parameters inside quotes * v1.0.0-alpha.4 * copy-paste inside component done * canvas zone as paste target done * up/down arrow key works * create component undo/redo done * wip: undo-redo * undo-redo done * wip: component navigator data compute done * wip: component navigator update on alias change * component navigator open close done * patchCb called on comp navigator reposition * raise hover & select from comp navigator * select on reposition/rewire end * fix: sort the direct child of canvas * __version__ set to 1.0.0-alpha.5 * v1.0.0-alpha.5 * yarn editor register new components from manifests dir * build manifest python packages inside manifests done * build manifest python packages inside manifests done * wip: wiring for fetching user events done * wip: live canvas zone with components done * live canvas zone with components done * callbacks attached in live mode * wip: hook with python * /_atri/api/event request is sent to python * handle event updates live view * fix: make sure alias patch is sent later * bugfix: drag-drop disappearing * bugfix: new dragged node is set on togglenode * __version__ set to 1.0.0-alpha.6 * build-editor takes forest * pwa-builder-server needs forest for build * fix: added missing deps to build scripts * v1.0.0-alpha.6 * added missing dep commands * __version__ set to 1.0.0-alpha.7 * v1.0.0-alpha.7 * wip: add antd components * ssr in dev mode done * Nested repeating & overlay adapted for repeating component (#720) * bugfix: before_app_load to unset the comp id state * handleBreakpointChange & bugfix * removed console.log * select overlay done * overlay for hover done * bugfix: update hovered on re-hoverWhileSelected * removed console.log * overlay on reposition * python files are generated from react manifest * generate __init__.py file * atri_core is publishable * python manifest project built using package.json * bugfix: call join after map * wip: generate python model for each page * python page model gets generated * generate python models in dev mode * dev mode for generate python routes done * create alias on drop done * change alias using aliasApi done * action layer added * bugfix: add .jsx random extension for IRToUnixFilepath to work * removed canvas-zone-manager package * support for shared libs in tool * asset manager integrated * removed react-shim manifest-shims packages * resource layer integrated * imported fonts reflect in editor * bugfix: remove duplicate import * manifest in example-atri-app populates in editor & app * removed install-scripts * createComponentManifest done * build editor for production * pwa-builder-server serves pwa-builder * @atrilabs/new package invoked to create a new atri app * changes main to bin * page scaffold includes canvas zone * expose pwa-builder-server binary & new package * package.json version set to 1.0.0-alpha.0 * removed app-scripts & app-generator package * removed webapp-builder package * removed scripts * removed packages not to be shipped in 1.0.0-alpha.0 * installed missing dependencies * package.json updated * v1.0.0-alpha.0 * fix: serve manifest registry * fixes: updated missing deps in create-atri-app * __version__ set to 1.0.0-alpha.1 * v1.0.0-alpha.1 * fix: pwa-builder build command without manifests * v1.0.0-alpha.2 * fix: use uuid vs @atrilabs/core * v1.0.0-alpha.3 * new parameters inside quotes * v1.0.0-alpha.4 * copy-paste inside component done * canvas zone as paste target done * up/down arrow key works * create component undo/redo done * wip: undo-redo * undo-redo done * wip: component navigator data compute done * wip: component navigator update on alias change * component navigator open close done * patchCb called on comp navigator reposition * raise hover & select from comp navigator * select on reposition/rewire end * fix: sort the direct child of canvas * __version__ set to 1.0.0-alpha.5 * v1.0.0-alpha.5 * yarn editor register new components from manifests dir * build manifest python packages inside manifests done * build manifest python packages inside manifests done * wip: wiring for fetching user events done * wip: live canvas zone with components done * live canvas zone with components done * callbacks attached in live mode * wip: hook with python * /_atri/api/event request is sent to python * handle event updates live view * fix: make sure alias patch is sent later * bugfix: drag-drop disappearing * bugfix: new dragged node is set on togglenode * atri-comp-id & atri-parent-marker assigned * overlays adapted for repeating list * removed log statement * __version__ set to 1.0.0-alpha.6 (#721) * bugfix: before_app_load to unset the comp id state * handleBreakpointChange & bugfix * removed console.log * select overlay done * overlay for hover done * bugfix: update hovered on re-hoverWhileSelected * removed console.log * overlay on reposition * python files are generated from react manifest * generate __init__.py file * atri_core is publishable * python manifest project built using package.json * bugfix: call join after map * wip: generate python model for each page * python page model gets generated * generate python models in dev mode * dev mode for generate python routes done * create alias on drop done * change alias using aliasApi done * action layer added * bugfix: add .jsx random extension for IRToUnixFilepath to work * removed canvas-zone-manager package * support for shared libs in tool * asset manager integrated * removed react-shim manifest-shims packages * resource layer integrated * imported fonts reflect in editor * bugfix: remove duplicate import * manifest in example-atri-app populates in editor & app * removed install-scripts * createComponentManifest done * build editor for production * pwa-builder-server serves pwa-builder * @atrilabs/new package invoked to create a new atri app * changes main to bin * page scaffold includes canvas zone * expose pwa-builder-server binary & new package * package.json version set to 1.0.0-alpha.0 * removed app-scripts & app-generator package * removed webapp-builder package * removed scripts * removed packages not to be shipped in 1.0.0-alpha.0 * installed missing dependencies * package.json updated * v1.0.0-alpha.0 * fix: serve manifest registry * fixes: updated missing deps in create-atri-app * __version__ set to 1.0.0-alpha.1 * v1.0.0-alpha.1 * fix: pwa-builder build command without manifests * v1.0.0-alpha.2 * fix: use uuid vs @atrilabs/core * v1.0.0-alpha.3 * new parameters inside quotes * v1.0.0-alpha.4 * copy-paste inside component done * canvas zone as paste target done * up/down arrow key works * create component undo/redo done * wip: undo-redo * undo-redo done * wip: component navigator data compute done * wip: component navigator update on alias change * component navigator open close done * patchCb called on comp navigator reposition * raise hover & select from comp navigator * select on reposition/rewire end * fix: sort the direct child of canvas * __version__ set to 1.0.0-alpha.5 * v1.0.0-alpha.5 * yarn editor register new components from manifests dir * build manifest python packages inside manifests done * build manifest python packages inside manifests done * wip: wiring for fetching user events done * wip: live canvas zone with components done * live canvas zone with components done * callbacks attached in live mode * wip: hook with python * /_atri/api/event request is sent to python * handle event updates live view * fix: make sure alias patch is sent later * bugfix: drag-drop disappearing * bugfix: new dragged node is set on togglenode * __version__ set to 1.0.0-alpha.6 * build-editor takes forest * pwa-builder-server needs forest for build * fix: added missing deps to build scripts * v1.0.0-alpha.6 * added missing dep commands * __version__ set to 1.0.0-alpha.7 * v1.0.0-alpha.7 * wip: add antd components * ssr in dev mode done * Removed events that were not required: Since they were utility events and not needed in the canvasMachine --------- Co-authored-by: Jonathan Alvares <alvaresjonathan599@gmail.com> Co-authored-by: Shyam Swaroop <30747788+cruxcode@users.noreply.github.com> Co-authored-by: cruxcode <swaroopshyam0@gmail.com>
1 parent d8b9daf commit fac6bb0

File tree

5 files changed

+253
-9
lines changed

5 files changed

+253
-9
lines changed

‎packages/atri-app-core/src/api/canvasApi.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ subscribeCanvasMachine("OUTSIDE_CANVAS", (_context, event) => {
5656
"*"
5757
);
5858
});
59-
subscribeCanvasMachine("moveWhileDrag", () => {
60-
// TODO: detect catcher & call canvas overlay api
61-
});
6259
subscribeCanvasMachine("upWhileDrag", (context) => {
6360
const canvasZone = (context.mousePosition!.target as HTMLElement).closest(
6461
"[data-atri-canvas-id]"

‎packages/atri-app-core/src/canvasMachine.ts‎

Lines changed: 111 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ const KEY_UP = "KEY_UP" as const;
2828
const KEY_DOWN = "KEY_DOWN" as const;
2929
const PROGRAMTIC_HOVER = "PROGRAMTIC_HOVER" as const;
3030
const PROGRAMTIC_SELECT = "PROGRAMTIC_SELECT" as const;
31+
const DROP_ZONE_CREATED = "DROP_ZONE_CREATED" as const;
32+
const DROP_ZONE_DESTROYED = "DROP_ZONE_DESTROYED" as const;
3133

3234
type IFRAME_DETECTED_EVENT = { type: typeof IFRAME_DETECTED };
3335
type TOP_WINDOW_DETECTED_EVENT = { type: typeof TOP_WINDOW_DETECTED };
@@ -174,6 +176,7 @@ type CanvasMachineContext = {
174176
} | null;
175177
repositionComponent: string | null;
176178
lastRewiredComponent: string | null;
179+
probableParent: string | null;
177180
};
178181

179182
// actions
@@ -272,6 +275,10 @@ function setEverythingToNull(context: CanvasMachineContext) {
272275
context.lastDropped = null;
273276
}
274277

278+
function setProbableParentToNull(context: CanvasMachineContext) {
279+
context.probableParent = null;
280+
}
281+
275282
// conds
276283

277284
function insideComponent(
@@ -427,7 +434,9 @@ type SubscribeStates =
427434
| typeof KEY_UP
428435
| typeof KEY_DOWN
429436
| "hoverWhileSelected"
430-
| "hoverWhileSelectedEnd";
437+
| "hoverWhileSelectedEnd"
438+
| typeof DROP_ZONE_CREATED
439+
| typeof DROP_ZONE_DESTROYED;
431440

432441
export function createCanvasMachine(id: string) {
433442
const subscribers: { [key in SubscribeStates]: Callback[] } = {
@@ -456,6 +465,8 @@ export function createCanvasMachine(id: string) {
456465
[KEY_DOWN]: [],
457466
hoverWhileSelected: [],
458467
hoverWhileSelectedEnd: [],
468+
[DROP_ZONE_CREATED]: [],
469+
[DROP_ZONE_DESTROYED]: [],
459470
};
460471
function subscribeCanvasMachine(state: SubscribeStates, cb: Callback) {
461472
subscribers[state].push(cb);
@@ -508,6 +519,7 @@ export function createCanvasMachine(id: string) {
508519
repositionTarget: null,
509520
repositionComponent: null,
510521
lastRewiredComponent: null,
522+
probableParent: null,
511523
},
512524
states: {
513525
[initial]: {
@@ -610,18 +622,77 @@ export function createCanvasMachine(id: string) {
610622
{
611623
target: repositionIdle,
612624
cond: isInTheSameParent,
613-
actions: ["emitRepositionIdle"],
625+
actions: [
626+
"emitRepositionIdle",
627+
"setProbableParentToNull",
628+
"emitDropZoneDestroyed",
629+
],
614630
},
615631
{
616632
actions: [
617633
"setRepositionTarget",
618634
"emitRepositionActive",
635+
(context, event) => {
636+
const { target } = event.event;
637+
if (target !== null && "closest" in target) {
638+
const parentEl = (target as HTMLElement).closest(
639+
"[data-atri-parent]"
640+
);
641+
let parentElId: string | null = null;
642+
if (parentEl) {
643+
parentElId =
644+
parentEl.getAttribute("data-atri-comp-id")!;
645+
}
646+
if (
647+
parentElId !== null &&
648+
parentElId !== context.probableParent
649+
) {
650+
// Destroy a dropzone when the current and
651+
// previous parents do not match
652+
context.probableParent = null;
653+
callSubscribers(
654+
"DROP_ZONE_DESTROYED",
655+
context,
656+
event
657+
);
658+
// Create a dropzone after the previous dropzone
659+
// is destroyed
660+
context.probableParent = parentElId;
661+
callSubscribers(
662+
"DROP_ZONE_CREATED",
663+
context,
664+
event
665+
);
666+
}
667+
}
668+
},
669+
(context, event) => {
670+
const { target } = event.event;
671+
const currentEl = (target as HTMLElement).closest(
672+
"[data-atri-comp-id]"
673+
);
674+
if (
675+
context.repositionComponent ===
676+
currentEl?.getAttribute("data-atri-comp-id")!
677+
) {
678+
setProbableParentToNull(context);
679+
callSubscribers(
680+
"DROP_ZONE_DESTROYED",
681+
context,
682+
event
683+
);
684+
}
685+
},
619686
],
620687
},
621688
],
622689
[MOUSE_UP]: {
623690
target: `#${id}.${ready}.${selected}`,
624-
actions: ["emitRepositionSuccess"],
691+
actions: [
692+
"emitRepositionSuccess",
693+
"setProbableParentToNull",
694+
"emitDropZoneDestroyed",
695+
],
625696
},
626697
},
627698
},
@@ -806,15 +877,47 @@ export function createCanvasMachine(id: string) {
806877
[drag_in_progress_active]: {
807878
on: {
808879
[MOUSE_MOVE]: {
809-
actions: ["setMousePosition", "emitMoveWhileDrag"],
880+
actions: [
881+
"setMousePosition",
882+
"emitMoveWhileDrag",
883+
(context, event) => {
884+
const { target } = event.event;
885+
if (target !== null && "closest" in target) {
886+
const parentEl = (target as HTMLElement).closest(
887+
"[data-atri-parent]"
888+
);
889+
let parentElId: string | null = null;
890+
if (parentEl) {
891+
parentElId =
892+
parentEl.getAttribute("data-atri-comp-id")!;
893+
}
894+
if (
895+
parentElId !== null &&
896+
parentElId !== context.probableParent
897+
) {
898+
context.probableParent = parentElId;
899+
callSubscribers("DROP_ZONE_CREATED", context, event);
900+
}
901+
}
902+
},
903+
],
810904
},
811905
[MOUSE_UP]: {
812906
target: `#${id}.${ready}`,
813-
actions: ["setMousePosition", "emitUpWhileDrag"],
907+
actions: [
908+
"setMousePosition",
909+
"emitUpWhileDrag",
910+
"setProbableParentToNull",
911+
"emitDropZoneDestroyed",
912+
],
814913
},
815914
[OUTSIDE_CANVAS]: {
816915
target: drag_in_progress_idle,
817-
actions: ["emitOutsideCanvas"],
916+
actions: [
917+
"emitOutsideCanvas",
918+
"setProbableParentToNull",
919+
"emitDropZoneDestroyed",
920+
],
818921
},
819922
},
820923
},
@@ -827,6 +930,7 @@ export function createCanvasMachine(id: string) {
827930
actions: {
828931
setDragData,
829932
setMousePosition,
933+
setProbableParentToNull,
830934
emitUpWhileDrag: callSubscribersFromAction("upWhileDrag"),
831935
emitMoveWhileDrag: callSubscribersFromAction("moveWhileDrag"),
832936
emitOutsideCanvas: callSubscribersFromAction("OUTSIDE_CANVAS"),
@@ -850,6 +954,7 @@ export function createCanvasMachine(id: string) {
850954
emitKeyUp: callSubscribersFromAction(KEY_UP),
851955
emitKeyDown: callSubscribersFromAction(KEY_DOWN),
852956
setEverythingToNull,
957+
emitDropZoneDestroyed: callSubscribersFromAction(DROP_ZONE_DESTROYED),
853958
},
854959
}
855960
);

‎packages/atri-app-core/src/editor-components/CanvasOverlay/CanvasOverlay.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import {
33
useSelectHints,
44
useHoverHints,
55
useDraggedOverlay,
6+
useDropzoneHints,
67
} from "./hooks";
78

89
export function CanvasOverlay() {
910
const { dragFC, dragOverlayStyle } = useDragDrop();
1011
useSelectHints();
1112
useHoverHints();
1213
useDraggedOverlay();
14+
useDropzoneHints();
1315
return (
1416
<>
1517
{dragFC?.Comp && dragOverlayStyle ? (

‎packages/atri-app-core/src/editor-components/CanvasOverlay/hooks/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export * from "./useDragDrop";
22
export * from "./useSelectHints";
33
export * from "./useHoverHints";
44
export * from "./useDraggedOverlay";
5+
export * from "./useDropzoneHints";
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
import { orange600 } from "@atrilabs/design-system";
2+
import { useEffect, useRef, useCallback } from "react";
3+
import { subscribeCanvasMachine } from "../../../api";
4+
import { getId } from "../../../utils/getId";
5+
import {
6+
removeHintOverlays,
7+
addOrModifyHintOverlays,
8+
} from "../../VisualHints/hintOverlays";
9+
import { FilledLine } from "../components/FilledLine";
10+
11+
const thickness = 2;
12+
13+
export function useDropzoneHints() {
14+
const topLineHoverId = useRef<string | null>(null);
15+
const rightLineHoverId = useRef<string | null>(null);
16+
const bottomLineHoverId = useRef<string | null>(null);
17+
const leftLineHoverId = useRef<string | null>(null);
18+
const compId = useRef<string | null>(null);
19+
20+
const clearOverlay = useCallback(() => {
21+
if (topLineHoverId.current) {
22+
removeHintOverlays([topLineHoverId.current]);
23+
topLineHoverId.current = null;
24+
}
25+
if (rightLineHoverId.current) {
26+
removeHintOverlays([rightLineHoverId.current]);
27+
rightLineHoverId.current = null;
28+
}
29+
if (bottomLineHoverId.current) {
30+
removeHintOverlays([bottomLineHoverId.current]);
31+
bottomLineHoverId.current = null;
32+
}
33+
if (leftLineHoverId.current) {
34+
removeHintOverlays([leftLineHoverId.current]);
35+
leftLineHoverId.current = null;
36+
}
37+
}, []);
38+
39+
const renderFn = useCallback(() => {
40+
if (
41+
topLineHoverId.current &&
42+
rightLineHoverId.current &&
43+
bottomLineHoverId.current &&
44+
leftLineHoverId.current &&
45+
compId.current
46+
) {
47+
// top line
48+
addOrModifyHintOverlays({
49+
[topLineHoverId.current]: {
50+
compId: compId.current,
51+
comp: <FilledLine fill={orange600} />,
52+
overlayId: topLineHoverId.current,
53+
box: (dim) => {
54+
return {
55+
dimension: {
56+
width: dim.dimension.width,
57+
height: thickness,
58+
},
59+
position: { top: -thickness, left: 0 },
60+
};
61+
},
62+
},
63+
});
64+
// right line
65+
addOrModifyHintOverlays({
66+
[rightLineHoverId.current]: {
67+
compId: compId.current,
68+
comp: <FilledLine fill={orange600} />,
69+
overlayId: rightLineHoverId.current,
70+
box: (dim) => {
71+
return {
72+
dimension: {
73+
width: thickness,
74+
height: dim.dimension.height + 2 * thickness,
75+
},
76+
position: { top: -thickness, left: dim.dimension.width },
77+
};
78+
},
79+
},
80+
});
81+
// bottom line
82+
addOrModifyHintOverlays({
83+
[bottomLineHoverId.current]: {
84+
compId: compId.current,
85+
comp: <FilledLine fill={orange600} />,
86+
overlayId: bottomLineHoverId.current,
87+
box: (dim) => {
88+
return {
89+
dimension: {
90+
width: dim.dimension.width,
91+
height: thickness,
92+
},
93+
position: { top: dim.dimension.height, left: 0 },
94+
};
95+
},
96+
},
97+
});
98+
// left line
99+
addOrModifyHintOverlays({
100+
[leftLineHoverId.current]: {
101+
compId: compId.current,
102+
comp: <FilledLine fill={orange600} />,
103+
overlayId: leftLineHoverId.current,
104+
box: (dim) => {
105+
return {
106+
dimension: {
107+
width: thickness,
108+
height: dim.dimension.height + 2 * thickness,
109+
},
110+
position: { top: -thickness, left: -thickness },
111+
};
112+
},
113+
},
114+
});
115+
}
116+
}, []);
117+
118+
useEffect(() => {
119+
return subscribeCanvasMachine("DROP_ZONE_CREATED", (context, event) => {
120+
if (compId.current === null && context.probableParent !== null) {
121+
topLineHoverId.current = getId();
122+
rightLineHoverId.current = getId();
123+
bottomLineHoverId.current = getId();
124+
leftLineHoverId.current = getId();
125+
compId.current = context.probableParent;
126+
renderFn();
127+
}
128+
});
129+
}, []);
130+
131+
useEffect(() => {
132+
return subscribeCanvasMachine("DROP_ZONE_DESTROYED", (context, event) => {
133+
if (compId.current !== null) {
134+
clearOverlay();
135+
compId.current = null;
136+
}
137+
});
138+
}, []);
139+
}

0 commit comments

Comments
 (0)