Skip to content

Commit bd7d792

Browse files
committed
Patch: removed enum from declaration file
1 parent 8c652db commit bd7d792

File tree

7 files changed

+36
-18
lines changed

7 files changed

+36
-18
lines changed

src/components/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { twMerge } from "tailwind-merge";
22
import { useEvents, useInteractions } from "@/hooks";
3-
import { type ISTKProps, STKMode } from "@/types";
3+
import { type ISTKProps } from "@/types";
44
import { default as Controls } from "./controls";
55
import { default as Footer } from "./footer";
66
import { default as Operations } from "./operations";
@@ -46,7 +46,7 @@ const User: React.FC<ISTKProps> = (props) => {
4646
};
4747

4848
const Core = (props: ISTKProps) => {
49-
if (props.mode === STKMode.Designer) {
49+
if (props.mode === "designer") {
5050
return <Designer {...props} />;
5151
}
5252
return <User {...props} />;

src/components/workspace/elements/index.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { twMerge } from "tailwind-merge";
55
import { dataAttributes } from "@/constants";
66
import { store } from "@/store";
77
import { clearAndSelectElements, deselectElement, selectElement } from "@/store/reducers/editor";
8-
import { ISTKProps, STKMode } from "@/types";
8+
import { ISTKProps } from "@/types";
99
import { Tool } from "../../toolbar/data";
1010
import {
1111
ElementType,
@@ -19,15 +19,28 @@ import {
1919

2020
export * from "./utils";
2121

22-
export const Element = ({ type = ElementType.Seat, id, x = 250, y = 250, isSelected = false, consumer, ...props }) => {
22+
interface IElementProps {
23+
[prop: string]: any;
24+
consumer: ISTKProps;
25+
}
26+
27+
export const Element: React.FC<IElementProps> = ({
28+
type = ElementType.Seat,
29+
id,
30+
x = 250,
31+
y = 250,
32+
isSelected = false,
33+
consumer,
34+
...props
35+
}) => {
2336
const ref = useRef<HTMLElement>();
2437

2538
const Element = elements[type] as any;
2639

2740
const styles = (consumer as ISTKProps).styles?.elements;
2841

2942
useEffect(() => {
30-
if (!ref.current || consumer.mode !== STKMode.Designer) return;
43+
if (!ref.current || consumer.mode !== "designer") return;
3144
const node = d3.select(ref.current);
3245
if (type === ElementType.Seat) {
3346
handleSeatDrag(node);

src/components/workspace/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { twMerge } from "tailwind-merge";
44
import { ids } from "@/constants";
55
import { store } from "@/store";
66
import { initializeElements, sync } from "@/store/reducers/editor";
7-
import { type ISTKProps, STKMode } from "@/types";
7+
import { type ISTKProps } from "@/types";
88
import { Tool, tools } from "../toolbar/data";
99
import { default as Crosshairs } from "./crosshairs";
1010
import { default as Element, ElementType } from "./elements";
@@ -123,7 +123,7 @@ export const Workspace: React.FC<ISTKProps> = (props) => {
123123
{selectedPolylineId && <line id={ids.templine} className="stroke-2 stroke-black fill-white" />}
124124
</g>
125125
</svg>
126-
{props.mode === STKMode.Designer && (
126+
{props.mode === "designer" && (
127127
<>
128128
<Crosshairs render={tools[selectedTool]?.crosshairs} />
129129
<Grid />

src/stories/designer.stories.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import SeatToolkit from "@/index";
2-
import { STKMode } from "@/types";
32

43
export default {
54
title: "Designer Mode",
@@ -11,5 +10,5 @@ export default {
1110
};
1211

1312
export const Default = {
14-
render: () => <SeatToolkit mode={STKMode.Designer} />
13+
render: () => <SeatToolkit mode={"designer"} />
1514
};

src/stories/user.stories.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import SeatToolkit from "@/index";
2-
import { STKMode } from "@/types";
32

43
export default {
54
title: "User Mode",
@@ -13,7 +12,7 @@ export default {
1312
export const Default = {
1413
render: () => (
1514
<SeatToolkit
16-
mode={STKMode.User}
15+
mode={"user"}
1716
data={{
1817
seats: [
1918
{

src/types/elements/seat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ISection } from "./polyline";
1+
import type { ISection } from "./polyline";
22

33
export interface ISeatCategory {
44
id: string;

src/types/index.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
import { IBooth, IImage, IPolyline, IPopulatedSeat, ISeat, ISeatCategory, ISection, IShape, IText } from "./elements";
2-
import { IStyles } from "./styles";
1+
import type {
2+
IBooth,
3+
IImage,
4+
IPolyline,
5+
IPopulatedSeat,
6+
ISeat,
7+
ISeatCategory,
8+
ISection,
9+
IShape,
10+
IText
11+
} from "./elements";
12+
import type { IStyles } from "./styles";
313

414
export * from "./elements";
515

6-
export enum STKMode {
7-
Designer = "designer",
8-
User = "user"
9-
}
16+
export type STKMode = "designer" | "user";
1017

1118
export interface IEvents {
1219
onSeatClick?: (seat: IPopulatedSeat) => void;

0 commit comments

Comments
 (0)