Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
215e765
Initial wiring for drag and drop visual hints done
jonathanalvares9009 Mar 11, 2023
8d46933
Create custom hook for visual hint on drag
jonathanalvares9009 Mar 11, 2023
7e65b0d
Drop zone hint logic for visual hints done
jonathanalvares9009 Mar 11, 2023
5768ead
Created context for probable parent
jonathanalvares9009 Mar 11, 2023
26f5f3e
Setting context for probable parent
jonathanalvares9009 Mar 11, 2023
922334a
Gives hint when probable parent is found
jonathanalvares9009 Mar 11, 2023
62f8f64
wip: removing the hint overlay
jonathanalvares9009 Mar 11, 2023
f78093b
Solved bug where overlay was not removed properly
jonathanalvares9009 Mar 12, 2023
b89390c
Removed redundant code
jonathanalvares9009 Mar 12, 2023
744e000
Removed moved while drag event being sent to editor machine
jonathanalvares9009 Mar 12, 2023
043f65d
Created DROPZONE_CREATED and DROPZONE_DESTROYED events
jonathanalvares9009 Mar 12, 2023
401a1a1
Showing visual hints when drop zone created
jonathanalvares9009 Mar 12, 2023
f9a37b9
Destroyed overlays on dropzone destroyed
jonathanalvares9009 Mar 12, 2023
97474b2
Nested repeating & overlay adapted for repeating component (#720)
cruxcode Mar 12, 2023
ff0e338
__version__ set to 1.0.0-alpha.6 (#721)
cruxcode Mar 12, 2023
ded2262
build-editor takes forest
cruxcode Mar 12, 2023
edb7c5b
pwa-builder-server needs forest for build
cruxcode Mar 12, 2023
88c9b46
fix: added missing deps to build scripts
cruxcode Mar 12, 2023
726a0ad
v1.0.0-alpha.6
cruxcode Mar 12, 2023
a8f5d33
added missing dep commands
cruxcode Mar 12, 2023
7ffa81a
__version__ set to 1.0.0-alpha.7
cruxcode Mar 12, 2023
d38411d
v1.0.0-alpha.7
cruxcode Mar 12, 2023
123c451
wip: add antd components
cruxcode Mar 13, 2023
7010e50
ssr in dev mode done
cruxcode Mar 13, 2023
13c3f70
Removed events that were not required: Since they were utility events…
jonathanalvares9009 Mar 14, 2023
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Drop zone hint logic for visual hints done
  • Loading branch information
jonathanalvares9009 committed Mar 11, 2023
commit 7e65b0d9f0a7db33d5278f2ac9eb4a50445a11ab
Original file line number Diff line number Diff line change
@@ -1,10 +1,134 @@
import { useEffect } from "react";
import { orange600 } from "@atrilabs/design-system";
import { useEffect, useRef, useCallback } from "react";
import { subscribeCanvasMachine } from "../../../api";
import { getId } from "../../../utils/getId";
import {
removeHintOverlays,
addOrModifyHintOverlays,
} from "../../VisualHints/hintOverlays";
import { FilledLine } from "../components/FilledLine";

const thickness = 2;

export function useDropzoneHints() {
const topLineHoverId = useRef<string | null>(null);
const rightLineHoverId = useRef<string | null>(null);
const bottomLineHoverId = useRef<string | null>(null);
const leftLineHoverId = useRef<string | null>(null);
const compId = useRef<string | null>(null);

const clearOverlay = useCallback(() => {
if (topLineHoverId.current) {
removeHintOverlays([topLineHoverId.current]);
topLineHoverId.current = null;
}
if (rightLineHoverId.current) {
removeHintOverlays([rightLineHoverId.current]);
rightLineHoverId.current = null;
}
if (bottomLineHoverId.current) {
removeHintOverlays([bottomLineHoverId.current]);
bottomLineHoverId.current = null;
}
if (leftLineHoverId.current) {
removeHintOverlays([leftLineHoverId.current]);
leftLineHoverId.current = null;
}
}, []);

const renderFn = useCallback(() => {
if (
topLineHoverId.current &&
rightLineHoverId.current &&
bottomLineHoverId.current &&
leftLineHoverId.current &&
compId.current
) {
// top line
addOrModifyHintOverlays({
[topLineHoverId.current]: {
compId: compId.current,
comp: <FilledLine fill={orange600} />,
overlayId: topLineHoverId.current,
box: (dim) => {
return {
dimension: {
width: dim.dimension.width,
height: thickness,
},
position: { top: -thickness, left: 0 },
};
},
},
});
// right line
addOrModifyHintOverlays({
[rightLineHoverId.current]: {
compId: compId.current,
comp: <FilledLine fill={orange600} />,
overlayId: rightLineHoverId.current,
box: (dim) => {
return {
dimension: {
width: thickness,
height: dim.dimension.height + 2 * thickness,
},
position: { top: -thickness, left: dim.dimension.width },
};
},
},
});
// bottom line
addOrModifyHintOverlays({
[bottomLineHoverId.current]: {
compId: compId.current,
comp: <FilledLine fill={orange600} />,
overlayId: bottomLineHoverId.current,
box: (dim) => {
return {
dimension: {
width: dim.dimension.width,
height: thickness,
},
position: { top: dim.dimension.height, left: 0 },
};
},
},
});
// left line
addOrModifyHintOverlays({
[leftLineHoverId.current]: {
compId: compId.current,
comp: <FilledLine fill={orange600} />,
overlayId: leftLineHoverId.current,
box: (dim) => {
return {
dimension: {
width: thickness,
height: dim.dimension.height + 2 * thickness,
},
position: { top: -thickness, left: -thickness },
};
},
},
});
}
}, []);

useEffect(() => {
return subscribeCanvasMachine("moveWhileDrag", () => {
console.log("wiring working properly");
return subscribeCanvasMachine("moveWhileDrag", (context, event) => {
topLineHoverId.current = getId();
rightLineHoverId.current = getId();
bottomLineHoverId.current = getId();
leftLineHoverId.current = getId();
// compId.current = event.;
renderFn();
});
}, []);

// useEffect(() => {
// return subscribeCanvasMachine("moveWhileDrag", () => {
// console.log("wiring working properly");
// });
// }, []);
}