Skip to content

Commit 4436712

Browse files
committed
Fix inferredAutoLayout.
1 parent 0e0acc1 commit 4436712

File tree

6 files changed

+10
-16
lines changed

6 files changed

+10
-16
lines changed

apps/plugin/plugin-src/code.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ switch (figma.mode) {
111111

112112
figma.codegen.on("generate", ({ language, node }) => {
113113
const convertedSelection = convertIntoNodes([node], null);
114-
console.log("language is", language);
115114

116115
switch (language) {
117116
case "html":

packages/backend/src/common/commonPosition.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ export const commonIsAbsolutePosition = (
131131
"layoutMode" in node.parent &&
132132
node.parent.inferredAutoLayout !== null
133133
) {
134-
return this;
134+
return false;
135135
}
136136

137137
if ("layoutAlign" in node) {
138138
if (!node.parent || node.parent === undefined) {
139-
return this;
139+
return false;
140140
}
141141

142142
const parentLayoutIsNone =

packages/backend/src/html/htmlDefaultBuilder.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ export class HtmlDefaultBuilder {
137137
position(node: SceneNode, optimizeLayout: boolean): this {
138138
if (commonIsAbsolutePosition(node, optimizeLayout)) {
139139
const { x, y } = getCommonPositionValue(node);
140-
141140
this.addStyles(
142141
formatWithJSX("left", this.isJSX, x),
143142
formatWithJSX("top", this.isJSX, y),
@@ -147,8 +146,8 @@ export class HtmlDefaultBuilder {
147146
if (
148147
node.type === "GROUP" ||
149148
("layoutMode" in node &&
150-
(optimizeLayout ? node.inferredAutoLayout : node)?.layoutMode ===
151-
"NONE")
149+
((optimizeLayout ? node.inferredAutoLayout : null) ?? node)
150+
?.layoutMode === "NONE")
152151
) {
153152
this.addStyles(formatWithJSX("position", this.isJSX, "relative"));
154153
}
@@ -219,12 +218,8 @@ export class HtmlDefaultBuilder {
219218
return this;
220219
}
221220

222-
size(node: SceneNode, optimizedLayout: boolean): this {
223-
const { width, height } = htmlSizePartial(
224-
node,
225-
this.isJSX,
226-
optimizedLayout
227-
);
221+
size(node: SceneNode, optimize: boolean): this {
222+
const { width, height } = htmlSizePartial(node, this.isJSX, optimize);
228223

229224
if (node.type === "TEXT") {
230225
switch (node.textAutoResize) {

packages/backend/src/swiftui/swiftuiDefaultBuilder.ts

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

140-
size(node: SceneNode): this {
141-
const { width, height } = swiftuiSize(node);
140+
size(node: SceneNode, optimize: boolean): this {
141+
const { width, height } = swiftuiSize(node, optimize);
142142
const sizes = [width, height].filter((d) => d);
143143
if (sizes.length > 0) {
144144
this.pushModifier([`frame`, sizes.join(", ")]);

packages/backend/src/swiftui/swiftuiMain.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export const swiftuiContainer = (
116116
const result = new SwiftuiDefaultBuilder(kind)
117117
.shapeForeground(node)
118118
.autoLayoutPadding(node, localSettings.optimizeLayout)
119-
.size(node)
119+
.size(node, localSettings.optimizeLayout)
120120
.shapeBackground(node)
121121
.cornerRadius(node)
122122
.shapeBorder(node)

packages/backend/src/tailwind/tailwindDefaultBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export class TailwindDefaultBuilder {
107107
} else if (
108108
node.type === "GROUP" ||
109109
("layoutMode" in node &&
110-
(optimizeLayout ? node.inferredAutoLayout : node)?.layoutMode ===
110+
((optimizeLayout ? node.inferredAutoLayout : null) ?? node)?.layoutMode ===
111111
"NONE")
112112
) {
113113
this.addAttributes("relative");

0 commit comments

Comments
 (0)