Skip to content

Commit 7eb183f

Browse files
committed
Feat: added support for a few style overrrides
1 parent 0227186 commit 7eb183f

File tree

8 files changed

+92
-16
lines changed

8 files changed

+92
-16
lines changed

src/components/core/animated-switcher.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ interface AnimatedSwitcherProps {
77
alternateComponent?: React.ReactNode;
88
show: boolean;
99
className?: string;
10+
style?: React.CSSProperties;
1011
duration?: number;
1112
}
1213

@@ -16,6 +17,7 @@ const AnimatedSwitcher = ({
1617
alternateComponent,
1718
show,
1819
className,
20+
style,
1921
duration
2022
}: AnimatedSwitcherProps) => {
2123
return (
@@ -25,6 +27,7 @@ const AnimatedSwitcher = ({
2527
initial={{ opacity: 0 }}
2628
animate={{ opacity: 1 }}
2729
transition={{ duration: duration ?? 0.3 }}
30+
style={style}
2831
exit={{ opacity: 0 }}
2932
>
3033
{show ? component : alternateComponent}

src/components/footer.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
11
import { useSelector } from "react-redux";
2+
import { twMerge } from "tailwind-merge";
3+
import { ISTKProps } from "@/types";
24
import { AnimatedSwitcher } from "./core";
35
import { tools } from "./toolbar/data";
46

5-
const Footer = () => {
7+
const Footer: React.FC<ISTKProps> = (props) => {
68
const selectedTool = useSelector((state: any) => state.toolbar.selectedTool);
9+
const styles = props.styles?.footer;
710
return (
8-
<div className="w-full fixed bottom-0 h-8 flex justify-center items-center bg-black text-white">
9-
<span className="text-sm">React Seat Toolkit </span>
11+
<div
12+
className={twMerge(
13+
"w-full fixed bottom-0 h-8 flex justify-center items-center bg-black text-white",
14+
styles?.root?.className
15+
)}
16+
style={styles?.root?.properties}
17+
>
18+
<span className={twMerge("text-sm", styles?.title?.className)} style={styles?.title?.properties}>
19+
React Seat Toolkit{" "}
20+
</span>
1021
<AnimatedSwitcher
1122
show={!!selectedTool}
1223
customKey={selectedTool}
13-
className="absolute top-[0.4rem] left-5 text-xs"
24+
className={twMerge("absolute top-[0.4rem] left-5 text-xs", styles?.meta?.className)}
25+
style={styles?.meta?.properties}
1426
component={<span>{tools[selectedTool]?.description}</span>}
1527
alternateComponent={null}
1628
duration={0.2}

src/components/index.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { twMerge } from "tailwind-merge";
12
import { useEvents, useInteractions } from "@/hooks";
23
import { type ISTKProps, STKMode } from "@/types";
34
import { default as Controls } from "./controls";
@@ -13,23 +14,32 @@ const Designer: React.FC<ISTKProps> = (props) => {
1314
useInteractions();
1415
return (
1516
<>
16-
<div className="h-full flex flex-col">
17+
<div
18+
className={twMerge("h-full min-h-[85vh] flex flex-col", props.styles?.root?.className)}
19+
style={props?.styles?.root?.properties}
20+
>
1721
<Operations />
18-
<div className="h-full flex relative">
19-
<Toolbar />
22+
<div
23+
className={twMerge("h-full flex relative", props.styles?.workspace?.container?.className)}
24+
style={props.styles?.workspace?.container?.properties}
25+
>
26+
<Toolbar {...props} />
2027
<Workspace {...props} />
2128
<Controls />
2229
</div>
2330
</div>
24-
<Footer />
31+
<Footer {...props} />
2532
<Cursor />
2633
</>
2734
);
2835
};
2936

3037
const User: React.FC<ISTKProps> = (props) => {
3138
return (
32-
<div className="h-full min-h-[85vh] flex flex-col relative">
39+
<div
40+
className={twMerge("h-full min-h-[85vh] flex flex-col relative", props.styles?.root?.className)}
41+
style={props?.styles.root?.properties}
42+
>
3343
<Workspace {...props} />
3444
</div>
3545
);

src/components/toolbar/index.tsx

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ import { ids } from "@/constants";
66
import { store } from "@/store";
77
import { clearCursor, setCursor, setSelectedPolylineId, showControls } from "@/store/reducers/editor";
88
import { clearTool, selectTool } from "@/store/reducers/toolbar";
9+
import { ISTKProps } from "@/types";
910
import { fallible } from "@/utils";
1011
import { selectFirstShape } from "../controls/shapes";
1112
import { Tool, tools } from "./data";
1213

13-
const ToolBar = () => {
14+
const ToolBar: React.FC<ISTKProps> = (props) => {
1415
const selectedTool = useSelector((state: any) => state.toolbar.selectedTool);
1516
const selectedPolylineId = store.getState().editor.selectedPolylineId;
1617

18+
const styles = props.styles?.toolbar;
19+
1720
const onEscape = useCallback(
1821
(event) => {
1922
if (event.key === "Escape") {
@@ -58,7 +61,11 @@ const ToolBar = () => {
5861
return (
5962
<div
6063
id={ids.toolbar}
61-
className="h-full flex flex-col gap-5 border-t pt-5 border-black [&>*:last-child]:[&>*:last-child]:hidden bg-black/5"
64+
className={twMerge(
65+
"h-full flex flex-col gap-5 border-t pt-5 border-black [&>*:last-child]:[&>*:last-child]:hidden bg-black/5",
66+
styles?.root?.className
67+
)}
68+
style={styles?.root?.properties}
6269
>
6370
{Object.entries(tools).map(([key, value]) => {
6471
const Icon = value.icon;
@@ -67,8 +74,10 @@ const ToolBar = () => {
6774
key={key}
6875
className={twMerge(
6976
"relative hover:bg-white transition-all duration-300 !cursor-pointer",
70-
selectedTool === key && "bg-white/80"
77+
selectedTool === key && "bg-white/80",
78+
styles?.tool?.root?.className
7179
)}
80+
style={styles?.tool?.root?.properties}
7281
onClick={() => onToolClick(key)}
7382
>
7483
<Tooltip>
@@ -77,15 +86,29 @@ const ToolBar = () => {
7786
size={20}
7887
className={twMerge(
7988
"pointer-events-none",
80-
selectedTool === key && "text-blue-600 transition-all duration-300"
89+
selectedTool === key && "text-blue-600 transition-all duration-300",
90+
styles?.tool?.icon?.className
8191
)}
92+
style={styles?.tool?.icon?.properties}
8293
/>
8394
</TooltipTrigger>
84-
<TooltipContent align="start" alignOffset={30} sideOffset={-39} className="flex gap-3 ml-8">
95+
<TooltipContent
96+
align="start"
97+
alignOffset={30}
98+
sideOffset={-39}
99+
className={twMerge("flex gap-3 ml-8", styles?.tool?.label?.className)}
100+
style={styles?.tool?.label?.properties}
101+
>
85102
{key}
86103
</TooltipContent>
87104
</Tooltip>
88-
<div className="bg-black h-1 w-1 mx-auto left-[45%] opacity-10 absolute bottom-0 transform translate-y-[0.75rem] rotate-[-25deg]" />
105+
<div
106+
className={twMerge(
107+
"bg-black h-1 w-1 mx-auto left-[45%] opacity-10 absolute bottom-0 transform translate-y-[0.75rem] rotate-[-25deg]",
108+
styles?.divider?.className
109+
)}
110+
style={styles?.divider?.properties}
111+
/>
89112
</div>
90113
);
91114
})}
File renamed without changes.

src/hooks/events/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import useDeselection from "./deselection";
2-
import useDuplicate from "./duplicate";
2+
import useDuplicate from "./duplication";
33
import usePolyline from "./polyline";
44
import useWorkspaceClick from "./workspace-click";
55

src/types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { IBooth, IImage, IPolyline, ISeat, ISeatCategory, ISection, IShape, IText } from "./elements";
2+
import { IStyles } from "./styles";
23

34
export * from "./elements";
45

@@ -29,4 +30,5 @@ export interface ISTKProps {
2930
mode: STKMode;
3031
events?: IEvents;
3132
data?: ISTKData;
33+
styles?: IStyles;
3234
}

src/types/styles.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
interface IStyle {
2+
className?: string;
3+
properties?: React.CSSProperties;
4+
}
5+
6+
export interface IStyles {
7+
root?: IStyle;
8+
workspace?: {
9+
container?: IStyle;
10+
root?: IStyle;
11+
};
12+
toolbar?: {
13+
root?: IStyle;
14+
tool?: {
15+
root?: IStyle;
16+
icon?: IStyle;
17+
label?: IStyle;
18+
};
19+
divider?: IStyle;
20+
};
21+
footer: {
22+
root?: IStyle;
23+
title?: IStyle;
24+
meta?: IStyle;
25+
};
26+
}

0 commit comments

Comments
 (0)