Skip to content

Commit 54d1c6f

Browse files
committed
Perf: reduced a few computations
1 parent f30031d commit 54d1c6f

File tree

1 file changed

+18
-10
lines changed
  • src/components/workspace/elements

1 file changed

+18
-10
lines changed

src/components/workspace/elements/seat.tsx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@ import { ISeat, ISeatCategory, ISection, SeatStatus } from "@/types/elements";
66
import { d3Extended } from "@/utils";
77
import { getDetailedSeat } from "./utils";
88

9-
export const seatSize = 28;
9+
const seatSize = 28;
1010

11-
export const seatLabelFontSize = seatSize / 3;
11+
const seatSizeHalf = seatSize / 2;
12+
13+
const seatLabelFontSize = seatSize / 3;
14+
15+
const seatIconXSubtract = seatSize / 2.73;
16+
17+
const seatIconYSubtract = seatSize / 2.65;
18+
19+
const seatIconSize = seatSize * 0.75;
1220

1321
export interface ISeatProps extends ISeat {
1422
className?: string;
@@ -134,24 +142,24 @@ const Seat: React.FC<ISeatProps> = forwardRef(
134142
<>
135143
{element.square ? (
136144
<rect
137-
x={x - seatSize / 2}
138-
y={y - seatSize / 2}
145+
x={x - seatSizeHalf}
146+
y={y - seatSizeHalf}
139147
height={seatSize}
140148
width={seatSize}
141149
rx={3}
142150
ry={3}
143151
{...seatProps}
144152
/>
145153
) : (
146-
<circle cx={x} cy={y} r={seatSize / 2} {...seatProps} />
154+
<circle cx={x} cy={y} r={seatSizeHalf} {...seatProps} />
147155
)}
148156
{SeatIcon && (
149157
<SeatIcon
150-
x={x - seatSize / 2.73}
151-
y={y - seatSize / 2.65}
152-
width={seatSize * 0.75}
153-
height={seatSize * 0.75}
154-
size={seatSize * 0.75}
158+
x={x - seatIconXSubtract}
159+
y={y - seatIconYSubtract}
160+
width={seatIconSize}
161+
height={seatIconSize}
162+
size={seatIconSize}
155163
className={twMerge(consumer.styles?.elements?.seat?.icon?.className, "stk-seat-icon")}
156164
style={consumer.styles?.elements?.seat?.icon?.properties}
157165
/>

0 commit comments

Comments
 (0)