Skip to content

Commit 7fc4820

Browse files
committed
Clean up node width height
1 parent 469f9fe commit 7fc4820

7 files changed

Lines changed: 8 additions & 56 deletions

File tree

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Size } from "types";
22

3-
export const nodeSize = (node: SceneNode, optimizeLayout: boolean): Size => {
3+
export const nodeSize = (node: SceneNode): Size => {
44
if ("layoutSizingHorizontal" in node && "layoutSizingVertical" in node) {
55
const width =
66
node.layoutSizingHorizontal === "FILL"
@@ -19,52 +19,5 @@ export const nodeSize = (node: SceneNode, optimizeLayout: boolean): Size => {
1919
return { width, height };
2020
}
2121

22-
const nodeAuto =
23-
(optimizeLayout && "inferredAutoLayout" in node
24-
? node.inferredAutoLayout
25-
: null) ?? node;
26-
27-
if (
28-
nodeAuto &&
29-
typeof nodeAuto === "object" &&
30-
"layoutMode" in nodeAuto &&
31-
nodeAuto.layoutMode === "NONE"
32-
) {
33-
return { width: node.width, height: node.height };
34-
}
35-
36-
const hasLayout =
37-
"layoutAlign" in node && node.parent && "layoutMode" in node.parent;
38-
39-
if (!hasLayout) {
40-
return { width: node.width, height: node.height };
41-
}
42-
4322
return { width: node.width, height: node.height };
44-
45-
// const isWidthFill =
46-
// (parentLayoutMode === "HORIZONTAL" && nodeAuto.layoutGrow === 1) ||
47-
// (parentLayoutMode === "VERTICAL" && nodeAuto.layoutAlign === "STRETCH");
48-
// const isHeightFill =
49-
// (parentLayoutMode === "HORIZONTAL" && nodeAuto.layoutAlign === "STRETCH") ||
50-
// (parentLayoutMode === "VERTICAL" && nodeAuto.layoutGrow === 1);
51-
// const modesSwapped = parentLayoutMode === "HORIZONTAL";
52-
// const primaryAxisMode = modesSwapped
53-
// ? "counterAxisSizingMode"
54-
// : "primaryAxisSizingMode";
55-
// const counterAxisMode = modesSwapped
56-
// ? "primaryAxisSizingMode"
57-
// : "counterAxisSizingMode";
58-
59-
// return {
60-
// width: isWidthFill
61-
// ? "fill"
62-
// : "layoutMode" in nodeAuto && nodeAuto[primaryAxisMode] === "AUTO"
63-
// ? null
64-
// : node.width,
65-
// height: isHeightFill
66-
// ? "fill"
67-
// : "layoutMode" in nodeAuto && nodeAuto[counterAxisMode] === "AUTO"
68-
// ? null
69-
// : node.height,
7023
};

packages/backend/src/flutter/builderImpl/flutterSize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const flutterSize = (
1212
node: SceneNode,
1313
optimizeLayout: boolean,
1414
): { width: string; height: string; isExpanded: boolean; constraints: Record<string, string> } => {
15-
const size = nodeSize(node, optimizeLayout);
15+
const size = nodeSize(node);
1616
let isExpanded: boolean = false;
1717

1818
const nodeParent =

packages/backend/src/html/builderImpl/htmlSize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const htmlSizePartial = (
1515
};
1616
}
1717

18-
const size = nodeSize(node, optimizeLayout);
18+
const size = nodeSize(node);
1919
console.log("size", size);
2020
const nodeParent =
2121
(node.parent && optimizeLayout && "inferredAutoLayout" in node.parent

packages/backend/src/swiftui/builderImpl/swiftuiSize.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import { numberToFixedString } from "../../common/numToAutoFixed";
33

44
export const swiftuiSize = (
55
node: SceneNode,
6-
optimize: boolean = false,
76
): { width: string; height: string; constraints: string[] } => {
8-
const size = nodeSize(node, optimize);
7+
const size = nodeSize(node);
98

109
const constraintProps: string[] = [];
1110
let width = "";

packages/backend/src/swiftui/swiftuiDefaultBuilder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ export class SwiftuiDefaultBuilder {
138138
return this;
139139
}
140140

141-
size(node: SceneNode, optimize: boolean): this {
142-
const { width, height, constraints } = swiftuiSize(node, optimize);
141+
size(node: SceneNode): this {
142+
const { width, height, constraints } = swiftuiSize(node);
143143
if (width || height) {
144144
this.pushModifier([`frame`, [width, height].filter(Boolean).join(", ")]);
145145
}

packages/backend/src/swiftui/swiftuiMain.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export const swiftuiContainer = (
127127
const result = new SwiftuiDefaultBuilder(kind)
128128
.shapeForeground(node)
129129
.autoLayoutPadding(node, localSettings.optimizeLayout)
130-
.size(node, localSettings.optimizeLayout)
130+
.size(node)
131131
.shapeBackground(node)
132132
.cornerRadius(node)
133133
.shapeBorder(node)

packages/backend/src/tailwind/builderImpl/tailwindSize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const tailwindSizePartial = (
3333
optimizeLayout: boolean,
3434
settings?: TailwindSettings,
3535
): { width: string; height: string; constraints: string } => {
36-
const size = nodeSize(node, optimizeLayout);
36+
const size = nodeSize(node);
3737
const nodeParent =
3838
(node.parent && optimizeLayout && "inferredAutoLayout" in node.parent
3939
? node.parent.inferredAutoLayout

0 commit comments

Comments
 (0)