Skip to content

Commit 38ab961

Browse files
committed
Feat: added section style overrides
1 parent 99354f4 commit 38ab961

File tree

4 files changed

+34
-36
lines changed

4 files changed

+34
-36
lines changed

src/components/workspace/elements/polyline.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,18 @@ const Polyline: React.FC<IPolylineProps> = forwardRef(
7676
style={{
7777
color: sectionObject?.color ?? color ?? "transparent",
7878
stroke: sectionObject?.stroke ?? stroke,
79-
...consumer.styles?.elements?.shape?.base?.properties
79+
...consumer.styles?.elements?.shape?.base?.properties,
80+
...(sectionObject && consumer.styles?.elements?.section?.base?.properties),
81+
...(sectionObject?.freeSeating && consumer.styles?.elements?.section?.freeSeating?.properties)
8082
}}
8183
{...{ [dataAttributes.section]: section }}
82-
className={twMerge(props.className, consumer.styles?.elements?.shape?.base?.className)}
84+
className={twMerge(
85+
props.className,
86+
consumer.styles?.elements?.shape?.base?.className,
87+
consumer.mode === "user" && sectionObject && "cursor-pointer filter hover:brightness-[1.05]",
88+
sectionObject && consumer.styles?.elements?.section?.base?.className,
89+
sectionObject?.freeSeating && consumer.styles?.elements?.section?.freeSeating?.className
90+
)}
8391
/>
8492
);
8593
}

src/components/workspace/elements/text.tsx

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { forwardRef } from "react";
22
import { twMerge } from "tailwind-merge";
3-
import { dataAttributes, selectors } from "@/constants";
3+
import { dataAttributes } from "@/constants";
44
import { ISTKProps, IText } from "@/types";
5-
import { d3Extended, getRelativeClickCoordsWithTransform } from "@/utils";
6-
import { panAndZoomToArea } from "../zoom";
75

86
export const textFontSize = 35;
97

@@ -34,21 +32,7 @@ const Text: React.FC<ITextProps> = forwardRef(
3432
},
3533
ref: any
3634
) => {
37-
const localOnClick = (e) => {
38-
onClick(e);
39-
if (embraceOffset) {
40-
const visibilityOffset = +d3Extended.select(selectors.workspaceGroup).attr(dataAttributes.visibilityOffset);
41-
if (visibilityOffset > 0) {
42-
const coords = getRelativeClickCoordsWithTransform(e);
43-
panAndZoomToArea({
44-
k: visibilityOffset,
45-
x: coords.x,
46-
y: coords.y
47-
});
48-
}
49-
}
50-
};
51-
35+
console.log(color);
5236
return (
5337
<text
5438
ref={ref}
@@ -58,12 +42,14 @@ const Text: React.FC<ITextProps> = forwardRef(
5842
fontSize={fontSize}
5943
fontWeight={fontWeight}
6044
letterSpacing={letterSpacing}
61-
stroke={color}
62-
color={color}
6345
{...props}
64-
onClick={localOnClick}
65-
className={twMerge(props.className, consumer.styles?.elements?.text?.base?.className)}
66-
style={consumer.styles?.elements?.text?.base?.properties}
46+
onClick={onClick}
47+
className={twMerge(
48+
props.className,
49+
consumer.styles?.elements?.text?.base?.className,
50+
consumer.mode === "user" && "pointer-events-none"
51+
)}
52+
style={{ ...consumer.styles?.elements?.text?.base?.properties, stroke: color, color }}
6753
{...{ [dataAttributes.embraceOffset]: embraceOffset }}
6854
>
6955
{label}

src/components/workspace/index.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,6 @@ export const Workspace: React.FC<ISTKProps> = (props) => {
9393
{...elementProps(e)}
9494
/>
9595
))}
96-
{text.map((e) => (
97-
<Element
98-
key={e.id}
99-
type={ElementType.Text}
100-
fontSize={e.fontSize}
101-
fontWeight={e.fontWeight}
102-
letterSpacing={e.letterSpacing}
103-
embraceOffset={e.embraceOffset}
104-
{...elementProps(e)}
105-
/>
106-
))}
10796
{polylines.map((e) => (
10897
<Element
10998
key={e.id}
@@ -125,6 +114,17 @@ export const Workspace: React.FC<ISTKProps> = (props) => {
125114
{...elementProps(e)}
126115
/>
127116
))}
117+
{text.map((e) => (
118+
<Element
119+
key={e.id}
120+
type={ElementType.Text}
121+
fontSize={e.fontSize}
122+
fontWeight={e.fontWeight}
123+
letterSpacing={e.letterSpacing}
124+
embraceOffset={e.embraceOffset}
125+
{...elementProps(e)}
126+
/>
127+
))}
128128
{selectedPolylineId && <line id={ids.templine} className="stroke-2 stroke-black fill-white" />}
129129
</g>
130130
</svg>

src/types/styles.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ export interface IStyles {
7171
unselected?: IStyle;
7272
base?: IStyle;
7373
};
74+
section?: {
75+
base?: IStyle;
76+
freeSeating?: IStyle;
77+
};
7478
image?: {
7579
selected?: IStyle;
7680
unselected?: IStyle;

0 commit comments

Comments
 (0)