Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { memo, useState } from "react";
import { Button } from "@/components/atoms/Button/Button";
import {
BaseEdge,
Expand All @@ -20,7 +21,6 @@ export type CustomEdgeData = {
};

export type CustomEdge = XYEdge<CustomEdgeData, "custom">;
import { memo } from "react";

const CustomEdge = ({
id,
Expand All @@ -35,6 +35,8 @@ const CustomEdge = ({
selected,
}: EdgeProps<CustomEdge>) => {
const removeConnection = useEdgeStore((state) => state.removeEdge);
const [isHovered, setIsHovered] = useState(false);

const [edgePath, labelX, labelY] = getBezierPath({
sourceX,
sourceY,
Expand Down Expand Up @@ -69,12 +71,17 @@ const CustomEdge = ({
<EdgeLabelRenderer>
<Button
onClick={() => removeConnection(id)}
className={`absolute h-fit min-w-0 p-1`}
className={cn(
"absolute h-fit min-w-0 p-1 transition-opacity",
isHovered ? "opacity-100" : "opacity-0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use hidden / block. With opacity, the button is still there. A quick misclick on that area will trigger the delete action, making the user think it is a bug 🐛

)}
variant="secondary"
style={{
transform: `translate(-50%, -50%) translate(${labelX}px, ${labelY}px)`,
pointerEvents: "all",
}}
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
>
<XIcon className="h-3 w-3" weight="bold" />
</Button>
Expand Down
Loading