Skip to content

Commit 9edc3b0

Browse files
committed
Feat: added support for a custom seat icon
1 parent 73ebdb0 commit 9edc3b0

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

src/components/workspace/elements/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export const Element: React.FC<IElementProps> = ({
105105
)}
106106
onClick={onClick}
107107
consumer={consumer}
108+
isSelected={isSelected}
108109
{...{ [dataAttributes.elementType]: type }}
109110
/>
110111
);

src/components/workspace/elements/seat.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ export interface ISeatProps extends ISeat {
1616
categories: ISeatCategory[];
1717
sections: ISection[];
1818
onClick: (e: any) => void;
19+
isSelected?: boolean;
1920
}
2021

2122
const Seat: React.FC<ISeatProps> = forwardRef(
22-
({ x, y, id, label, categories, category, sections, status, onClick, consumer, element, ...props }, ref: any) => {
23+
(
24+
{ x, y, id, label, categories, category, sections, status, onClick, consumer, element, isSelected, ...props },
25+
ref: any
26+
) => {
2327
const categoryObject = useMemo(() => categories?.find?.((c) => c.id === category), [categories, category]);
2428
const sectionObject = useMemo(
2529
() => sections?.find?.((s) => s.id === categoryObject?.section),
@@ -28,6 +32,8 @@ const Seat: React.FC<ISeatProps> = forwardRef(
2832

2933
const showLabel = consumer.options?.showSeatLabels ?? true;
3034

35+
const SeatIcon = isSelected ? consumer.options?.selectedSeatIcon : consumer.options?.seatIcon;
36+
3137
const textX = useMemo(() => {
3238
let value = (+ref.current?.getAttribute("cx") || x) - seatLabelFontSize / 3.5;
3339
const labelLength = label?.toString()?.length ?? 0;
@@ -79,7 +85,16 @@ const Seat: React.FC<ISeatProps> = forwardRef(
7985
{...props}
8086
className={twMerge(props.className, "filter hover:brightness-[1.05]")}
8187
/>
82-
{label && showLabel && (
88+
{SeatIcon && (
89+
<SeatIcon
90+
x={x - seatSize / 2.73}
91+
y={y - seatSize / 2.65}
92+
width={seatSize * 0.75}
93+
height={seatSize * 0.75}
94+
size={seatSize * 0.75}
95+
/>
96+
)}
97+
{label && showLabel && !SeatIcon && (
8398
<text
8499
id={`${id}-label`}
85100
x={textX}

src/types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,7 @@ export interface ISTKProps {
4646
showZoomControls?: boolean;
4747
exportButtonText?: string;
4848
operationTriggerIcon?: React.FC;
49+
seatIcon?: React.FC<any>;
50+
selectedSeatIcon?: React.FC<any>;
4951
};
5052
}

0 commit comments

Comments
 (0)