Skip to content

Commit f52dbfb

Browse files
cleaning
1 parent b494398 commit f52dbfb

8 files changed

Lines changed: 73 additions & 76 deletions

File tree

editor-packages/editor-canvas/canvas/canvas.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ export function Canvas({
320320
).map((h) => ({
321321
id: h.id,
322322
xywh: [h.absoluteX, h.absoluteY, h.width, h.height],
323+
rotation: h.rotation,
323324
}))
324325
: []
325326
}

editor-packages/editor-canvas/canvas/hud-surface.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface DisplayNodeMeta {
2222
absoluteY: number;
2323
width: number;
2424
height: number;
25+
rotation: number;
2526
}
2627

2728
export function HudSurface({
@@ -41,7 +42,7 @@ export function HudSurface({
4142
}: {
4243
offset: XY;
4344
zoom: number;
44-
highlights: { id: string; xywh: XYWH }[];
45+
highlights: { id: string; xywh: XYWH; rotation: number }[];
4546
labelDisplayNodes: DisplayNodeMeta[];
4647
selectedNodes: DisplayNodeMeta[];
4748
hide: boolean;
@@ -102,6 +103,7 @@ export function HudSurface({
102103
key={h.id}
103104
type="xywhr"
104105
xywh={h.xywh}
106+
rotation={h.rotation}
105107
zoom={zoom}
106108
width={2}
107109
/>
@@ -121,6 +123,7 @@ export function HudSurface({
121123
key={s.id}
122124
type="xywhr"
123125
xywh={xywh}
126+
rotation={s.rotation}
124127
zoom={zoom}
125128
width={1}
126129
/>

editor-packages/editor-canvas/overlay/hover-outline-hightlight.tsx

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,27 @@ import React from "react";
22
import { color_layer_highlight } from "../theme";
33
import { get_boinding_box } from "./math";
44
import { OulineSide } from "./outline-side";
5+
import { OverlayContainer } from "./overlay-container";
56
import type { OutlineProps } from "./types";
67

78
export function HoverOutlineHighlight({ width = 1, ...props }: OutlineProps) {
8-
const { xywh, zoom } = props;
9+
const { xywh, zoom, rotation } = props;
910
const bbox = get_boinding_box({ xywh, scale: zoom });
1011
const wh: [number, number] = [xywh[2], xywh[3]];
12+
const vprops = {
13+
wh: wh,
14+
zoom: props.zoom,
15+
width: width,
16+
box: bbox,
17+
color: color_layer_highlight,
18+
};
19+
1120
return (
12-
<>
13-
<OulineSide
14-
orientation="l"
15-
wh={wh}
16-
zoom={props.zoom}
17-
width={width}
18-
box={bbox}
19-
color={color_layer_highlight}
20-
/>
21-
<OulineSide
22-
orientation="t"
23-
wh={wh}
24-
zoom={props.zoom}
25-
width={width}
26-
box={bbox}
27-
color={color_layer_highlight}
28-
/>
29-
<OulineSide
30-
orientation="b"
31-
wh={wh}
32-
zoom={props.zoom}
33-
width={width}
34-
box={bbox}
35-
color={color_layer_highlight}
36-
/>
37-
<OulineSide
38-
orientation="r"
39-
wh={wh}
40-
zoom={props.zoom}
41-
width={width}
42-
box={bbox}
43-
color={color_layer_highlight}
44-
/>
45-
</>
21+
<OverlayContainer xywh={bbox} rotation={rotation}>
22+
<OulineSide orientation="l" {...vprops} />
23+
<OulineSide orientation="t" {...vprops} />
24+
<OulineSide orientation="b" {...vprops} />
25+
<OulineSide orientation="r" {...vprops} />
26+
</OverlayContainer>
4627
);
4728
}

editor-packages/editor-canvas/overlay/math.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export function get_boinding_box({
66
scale: number;
77
}): [number, number, number, number] {
88
const [x, y, w, h] = xywh;
9+
10+
// return the bounding box in [number, number, number, number] form with givven x, y, w, h, rotation and scale.
911
const [x1, y1, x2, y2] = [
1012
x * scale,
1113
y * scale,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import React from "react";
2+
3+
/**
4+
* @default - TODO: rotation not supported
5+
* @returns
6+
*/
7+
export function OverlayContainer({
8+
xywh,
9+
rotation = 0,
10+
children,
11+
}: {
12+
xywh: [number, number, number, number];
13+
rotation: number;
14+
children: React.ReactNode;
15+
}) {
16+
// const [x, y, w, h] = xywh;
17+
return (
18+
<div
19+
id="overlay-container"
20+
style={{
21+
pointerEvents: "none",
22+
willChange: "transform, opacity",
23+
// transformOrigin: `${x}px ${y}px`,
24+
// transform: `rotate(${-rotation}deg)`,
25+
}}
26+
>
27+
{children}
28+
</div>
29+
);
30+
}

editor-packages/editor-canvas/overlay/readonly-select-hightlight.tsx

Lines changed: 16 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,30 @@ import type { OutlineProps } from "./types";
33
import { color_layer_readonly_highlight } from "../theme";
44
import { get_boinding_box } from "./math";
55
import { OulineSide } from "./outline-side";
6+
import { OverlayContainer } from "./overlay-container";
67

78
export function ReadonlySelectHightlight({
89
width = 1,
910
...props
1011
}: OutlineProps) {
11-
const { xywh, zoom } = props;
12+
const { xywh, zoom, rotation } = props;
1213
const bbox = get_boinding_box({ xywh, scale: zoom });
1314
const wh: [number, number] = [xywh[2], xywh[3]];
1415

1516
const handle_outline_width = width;
1617
const handle_size = 3;
1718
const dot_size = 4;
1819

20+
const sideprops = {
21+
wh: wh,
22+
zoom: props.zoom,
23+
width: width,
24+
box: bbox,
25+
color: color_layer_readonly_highlight,
26+
};
27+
1928
return (
20-
<div
21-
style={{
22-
pointerEvents: "none",
23-
}}
24-
>
29+
<OverlayContainer xywh={bbox} rotation={rotation}>
2530
<>
2631
<ReadonlyHandle
2732
box={bbox}
@@ -83,40 +88,12 @@ export function ReadonlySelectHightlight({
8388
/>
8489
</>
8590
<>
86-
<OulineSide
87-
orientation="l"
88-
wh={wh}
89-
zoom={props.zoom}
90-
width={width}
91-
box={bbox}
92-
color={color_layer_readonly_highlight}
93-
/>
94-
<OulineSide
95-
orientation="t"
96-
wh={wh}
97-
zoom={props.zoom}
98-
width={width}
99-
box={bbox}
100-
color={color_layer_readonly_highlight}
101-
/>
102-
<OulineSide
103-
orientation="b"
104-
wh={wh}
105-
zoom={props.zoom}
106-
width={width}
107-
box={bbox}
108-
color={color_layer_readonly_highlight}
109-
/>
110-
<OulineSide
111-
orientation="r"
112-
wh={wh}
113-
zoom={props.zoom}
114-
width={width}
115-
box={bbox}
116-
color={color_layer_readonly_highlight}
117-
/>
91+
<OulineSide orientation="l" {...sideprops} />
92+
<OulineSide orientation="t" {...sideprops} />
93+
<OulineSide orientation="b" {...sideprops} />
94+
<OulineSide orientation="r" {...sideprops} />
11895
</>
119-
</div>
96+
</OverlayContainer>
12097
);
12198
}
12299

packages/builder-web-core/widgets-native/html-svg/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,12 @@ export class SvgElement extends StylableJsxWidget {
202202

203203
// @override
204204
get finalStyle() {
205+
const super_finalStyle = super.finalStyle;
205206
return {
206-
...super.finalStyle,
207+
...super_finalStyle,
207208
// TODO: this is a hot fix of svg & path's constraint handling
208209
// width & height for the svg must be preserved. (it wont' follow the constraints anyway.)
210+
// it can also be 100%
209211
width: css.length(this.width),
210212
height: css.length(this.height),
211213
};

packages/designto-web/tokens-to-web-widget/compose-wrapped-with-rotation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export function compose_wrapped_with_rotation(
1818
// rotation data needs to be inverted
1919
transform: css.rotation(-widget.rotation),
2020
// this is where the figma's rotation data is originated from.
21+
// see docs/figma-rotation.md
2122
"transform-origin": "top left",
2223
});
2324
return child;

0 commit comments

Comments
 (0)