Skip to content

Commit

Permalink
Rename InferredAutoLayoutResult that was changed by Figma.
Browse files Browse the repository at this point in the history
  • Loading branch information
bernaferrari committed Sep 12, 2023
1 parent c9ec835 commit 9103f7a
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/backend/src/common/commonPadding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type PaddingType =
};

export const commonPadding = (
node: inferredAutoLayoutResult
node: InferredAutoLayoutResult
): PaddingType | null => {
if ("layoutMode" in node && node.layoutMode !== "NONE") {
const paddingLeft = parseFloat((node.paddingLeft ?? 0).toFixed(2));
Expand Down
6 changes: 3 additions & 3 deletions packages/backend/src/flutter/builderImpl/flutterAutoLayout.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const getMainAxisAlignment = (
node: inferredAutoLayoutResult
node: InferredAutoLayoutResult
): string => {
switch (node.primaryAxisAlignItems) {
case "MIN":
Expand All @@ -14,7 +14,7 @@ export const getMainAxisAlignment = (
};

export const getCrossAxisAlignment = (
node: inferredAutoLayoutResult
node: InferredAutoLayoutResult
): string => {
switch (node.counterAxisAlignItems) {
case "MIN":
Expand All @@ -30,7 +30,7 @@ export const getCrossAxisAlignment = (

const getFlex = (
node: SceneNode,
autoLayout: inferredAutoLayoutResult
autoLayout: InferredAutoLayoutResult
): string =>
node.parent &&
"layoutMode" in node.parent &&
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/flutter/builderImpl/flutterPadding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { commonPadding } from "../../common/commonPadding";

// This must happen before Stack or after the Positioned, but not before.
export const flutterPadding = (node: inferredAutoLayoutResult): string => {
export const flutterPadding = (node: InferredAutoLayoutResult): string => {
if (!("layoutMode" in node)) {
return "";
}
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/flutter/flutterMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ const flutterFrame = (
};

const makeRowColumn = (
autoLayout: inferredAutoLayoutResult,
autoLayout: InferredAutoLayoutResult,
children: string
): string => {
const rowOrColumn = autoLayout.layoutMode === "HORIZONTAL" ? "Row" : "Column";
Expand Down
12 changes: 6 additions & 6 deletions packages/backend/src/html/builderImpl/htmlAutoLayout.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { formatMultipleJSXArray } from "../../common/parseJSX";

const getFlexDirection = (node: inferredAutoLayoutResult): string =>
const getFlexDirection = (node: InferredAutoLayoutResult): string =>
node.layoutMode === "HORIZONTAL" ? "" : "column";

const getJustifyContent = (node: inferredAutoLayoutResult): string => {
const getJustifyContent = (node: InferredAutoLayoutResult): string => {
switch (node.primaryAxisAlignItems) {
case "MIN":
return "flex-start";
Expand All @@ -16,7 +16,7 @@ const getJustifyContent = (node: inferredAutoLayoutResult): string => {
}
};

const getAlignItems = (node: inferredAutoLayoutResult): string => {
const getAlignItems = (node: InferredAutoLayoutResult): string => {
switch (node.counterAxisAlignItems) {
case "MIN":
return "flex-start";
Expand All @@ -29,14 +29,14 @@ const getAlignItems = (node: inferredAutoLayoutResult): string => {
}
};

const getGap = (node: inferredAutoLayoutResult): string | number =>
const getGap = (node: InferredAutoLayoutResult): string | number =>
node.itemSpacing > 0 && node.primaryAxisAlignItems !== "SPACE_BETWEEN"
? node.itemSpacing
: "";

const getFlex = (
node: SceneNode,
autoLayout: inferredAutoLayoutResult
autoLayout: InferredAutoLayoutResult
): string =>
node.parent &&
"layoutMode" in node.parent &&
Expand All @@ -46,7 +46,7 @@ const getFlex = (

export const htmlAutoLayoutProps = (
node: SceneNode,
autoLayout: inferredAutoLayoutResult,
autoLayout: InferredAutoLayoutResult,
isJsx: boolean
): string[] =>
formatMultipleJSXArray(
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/html/builderImpl/htmlPadding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { commonPadding } from "../../common/commonPadding";
import { formatWithJSX } from "../../common/parseJSX";

export const htmlPadding = (
node: inferredAutoLayoutResult,
node: InferredAutoLayoutResult,
isJsx: boolean
): string[] => {
const padding = commonPadding(node);
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/swiftui/builderImpl/swiftuiPadding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { commonPadding } from "../../common/commonPadding";
import { Modifier } from "./swiftuiParser";

export const swiftuiPadding = (
node: inferredAutoLayoutResult
node: InferredAutoLayoutResult
): Modifier | null => {
if (!("layoutMode" in node)) {
return null;
Expand Down
6 changes: 3 additions & 3 deletions packages/backend/src/swiftui/swiftuiMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const swiftuiFrame = (

const createDirectionalStack = (
children: string,
inferredAutoLayout: inferredAutoLayoutResult
inferredAutoLayout: InferredAutoLayoutResult
): string => {
if (inferredAutoLayout.layoutMode !== "NONE") {
return generateSwiftViewCode(
Expand All @@ -186,7 +186,7 @@ const createDirectionalStack = (
};

const getLayoutAlignment = (
inferredAutoLayout: inferredAutoLayoutResult
inferredAutoLayout: InferredAutoLayoutResult
): string => {
switch (inferredAutoLayout.counterAxisAlignItems) {
case "MIN":
Expand All @@ -202,7 +202,7 @@ const getLayoutAlignment = (
}
};

const getSpacing = (inferredAutoLayout: inferredAutoLayoutResult): number => {
const getSpacing = (inferredAutoLayout: InferredAutoLayoutResult): number => {
const defaultSpacing = 10;
return Math.round(inferredAutoLayout.itemSpacing) !== defaultSpacing
? inferredAutoLayout.itemSpacing
Expand Down
12 changes: 6 additions & 6 deletions packages/backend/src/tailwind/builderImpl/tailwindAutoLayout.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { pxToLayoutSize } from "../conversionTables";

const getFlexDirection = (node: inferredAutoLayoutResult): string =>
const getFlexDirection = (node: InferredAutoLayoutResult): string =>
node.layoutMode === "HORIZONTAL" ? "" : "flex-col";

const getJustifyContent = (node: inferredAutoLayoutResult): string => {
const getJustifyContent = (node: InferredAutoLayoutResult): string => {
switch (node.primaryAxisAlignItems) {
case "MIN":
return "justify-start";
Expand All @@ -16,7 +16,7 @@ const getJustifyContent = (node: inferredAutoLayoutResult): string => {
}
};

const getAlignItems = (node: inferredAutoLayoutResult): string => {
const getAlignItems = (node: InferredAutoLayoutResult): string => {
switch (node.counterAxisAlignItems) {
case "MIN":
return "items-start";
Expand All @@ -29,14 +29,14 @@ const getAlignItems = (node: inferredAutoLayoutResult): string => {
}
};

const getGap = (node: inferredAutoLayoutResult): string =>
const getGap = (node: InferredAutoLayoutResult): string =>
node.itemSpacing > 0 && node.primaryAxisAlignItems !== "SPACE_BETWEEN"
? `gap-${pxToLayoutSize(node.itemSpacing)}`
: "";

const getFlex = (
node: SceneNode,
autoLayout: inferredAutoLayoutResult
autoLayout: InferredAutoLayoutResult
): string =>
node.parent &&
"layoutMode" in node.parent &&
Expand All @@ -46,7 +46,7 @@ const getFlex = (

export const tailwindAutoLayoutProps = (
node: SceneNode,
autoLayout: inferredAutoLayoutResult
autoLayout: InferredAutoLayoutResult
): string =>
Object.values({
flexDirection: getFlexDirection(autoLayout),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { commonPadding } from "../../common/commonPadding";
* https://tailwindcss.com/docs/margin/
* example: px-2 py-8
*/
export const tailwindPadding = (node: inferredAutoLayoutResult): string[] => {
export const tailwindPadding = (node: InferredAutoLayoutResult): string[] => {
const padding = commonPadding(node);
if (!padding) {
return [];
Expand Down

0 comments on commit 9103f7a

Please sign in to comment.