Skip to content

Commit 1d24961

Browse files
committed
Patch: removed seat select outline
1 parent 2334c6e commit 1d24961

File tree

1 file changed

+22
-49
lines changed

1 file changed

+22
-49
lines changed

src/components/workspace/elements/index.tsx

Lines changed: 22 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import { memo, useEffect, useMemo, useRef } from "react";
1+
import { memo, useEffect, useRef } from "react";
22
import * as d3 from "d3";
33
import { isEqual } from "lodash";
44
import { twMerge } from "tailwind-merge";
55
import { dataAttributes } from "@/constants";
66
import { store } from "@/store";
77
import { clearAndSelectElements, deselectElement, selectElement } from "@/store/reducers/editor";
88
import { STKMode } from "@/types";
9-
import { d3Extended } from "@/utils";
109
import { Tool } from "../../toolbar/data";
1110
import {
1211
ElementType,
@@ -23,21 +22,8 @@ export * from "./utils";
2322
export const Element = ({ type = ElementType.Seat, id, x = 250, y = 250, isSelected = false, options, ...props }) => {
2423
const ref = useRef<HTMLElement>();
2524

26-
const node = ref.current && d3.select(ref.current);
27-
28-
const centerCoords = isSelected && options.mode === STKMode.Designer && node && d3Extended.getNodeCenter(node);
29-
3025
const Element = elements[type];
3126

32-
const controlRadius = useMemo(() => {
33-
if (!node) return 0;
34-
switch (type) {
35-
case ElementType.Seat:
36-
return +node.attr("r") * 6;
37-
}
38-
return +node.attr("width") * 1.5;
39-
}, [node]);
40-
4127
useEffect(() => {
4228
if (!ref.current || options.mode !== STKMode.Designer) return;
4329
const node = d3.select(ref.current);
@@ -73,40 +59,27 @@ export const Element = ({ type = ElementType.Seat, id, x = 250, y = 250, isSelec
7359
};
7460

7561
return (
76-
<>
77-
{centerCoords &&
78-
![ElementType.Text, ElementType.Shape, ElementType.Image, ElementType.Polyline].includes(type) && (
79-
<circle
80-
id={`${id}-controls`}
81-
cx={centerCoords.x}
82-
cy={centerCoords.y}
83-
r={controlRadius}
84-
className="stroke-2 stroke-blue-200 fill-none pointer-events-none"
85-
strokeDasharray="20, 38"
86-
/>
87-
)}
88-
<Element
89-
id={id}
90-
ref={ref}
91-
x={x}
92-
y={y}
93-
{...props}
94-
className={twMerge(
95-
"fill-current transition-all duration-medium",
96-
isSelected
97-
? type === ElementType.Text
98-
? "text-selected"
99-
: "element-selected"
100-
: type === ElementType.Text
101-
? "text-unselected"
102-
: "element-unselected",
103-
!props.color && type !== ElementType.Text && "text-white"
104-
)}
105-
onClick={onClick}
106-
options={options}
107-
{...{ [dataAttributes.elementType]: type }}
108-
/>
109-
</>
62+
<Element
63+
id={id}
64+
ref={ref}
65+
x={x}
66+
y={y}
67+
{...props}
68+
className={twMerge(
69+
"fill-current transition-all duration-medium",
70+
isSelected
71+
? type === ElementType.Text
72+
? "text-selected"
73+
: "element-selected"
74+
: type === ElementType.Text
75+
? "text-unselected"
76+
: "element-unselected",
77+
!props.color && type !== ElementType.Text && "text-white"
78+
)}
79+
onClick={onClick}
80+
options={options}
81+
{...{ [dataAttributes.elementType]: type }}
82+
/>
11083
);
11184
};
11285

0 commit comments

Comments
 (0)