Skip to content

Commit 23f3f35

Browse files
committed
Fix rotation on svg
1 parent 95428fd commit 23f3f35

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

packages/backend/src/common/commonPosition.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
import { HTMLSettings, TailwindSettings } from "types";
2+
13
export const getCommonPositionValue = (
24
node: SceneNode,
5+
settings?: HTMLSettings | TailwindSettings,
36
): { x: number; y: number } => {
47
if (node.parent && node.parent.absoluteBoundingBox) {
58
const x = node.absoluteBoundingBox.x - node.parent.absoluteBoundingBox.x;
69
const y = node.absoluteBoundingBox.y - node.parent.absoluteBoundingBox.y;
710

11+
if (settings?.embedVectors && node.svg) {
12+
// When embedding vectors, we need to use the absolute position, since it already includes the rotation.
13+
return { x: x, y: y };
14+
}
15+
816
const rect = calculateRectangleFromBoundingBox(
917
{
1018
width: node.absoluteBoundingBox.width,

packages/backend/src/html/htmlDefaultBuilder.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,9 @@ export class HtmlDefaultBuilder {
259259
const { node, isJSX } = this;
260260
const isAbsolutePosition = commonIsAbsolutePosition(node);
261261
if (isAbsolutePosition) {
262-
const { x, y } = getCommonPositionValue(node);
262+
const { x, y } = getCommonPositionValue(node, this.settings);
263+
264+
console.log("for node", node.name, x, y);
263265

264266
this.addStyles(
265267
formatWithJSX("left", isJSX, x),

packages/backend/src/tailwind/tailwindDefaultBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class TailwindDefaultBuilder {
122122
position(): this {
123123
const { node } = this;
124124
if (commonIsAbsolutePosition(node)) {
125-
const { x, y } = getCommonPositionValue(node);
125+
const { x, y } = getCommonPositionValue(node, this.settings);
126126

127127
const parsedX = numberToFixedString(x);
128128
const parsedY = numberToFixedString(y);

0 commit comments

Comments
 (0)