Skip to content

Commit

Permalink
fix: comment 이전 공백 제거, Text 줄바꿈 핸들
Browse files Browse the repository at this point in the history
  • Loading branch information
te6-in committed Jan 16, 2025
1 parent dcc639f commit 1aff2ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tools/figma-codegen/src/codegen/generate-code.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { camelCase } from "change-case";
import { createBackgroundProps, createBorderProps, createColorProps } from "./color";
import { createBackgroundProps, createBorderProps } from "./color";
import { componentHandlerMap } from "./component";
import { createIconTagNameFromKey, createMonochromeIconFillProps, isIconComponent } from "./icon";
import type { ElementNode } from "./jsx";
Expand Down Expand Up @@ -96,7 +96,7 @@ export function generateCode(selection: SceneNode) {
...(lineHeight ? { lineHeight } : {}),
...(color ? { color } : {}),
},
segment.characters,
segment.characters.replace(/\n/g, "<br />"),
`${
unavailableProps.length > 0
? `${unavailableProps.join(", ")} 프로퍼티는 반영되지 않았습니다. `
Expand Down
4 changes: 2 additions & 2 deletions tools/figma-codegen/src/codegen/jsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function stringifyElement(element: ElementNode) {
}`;

if (children == null || children.length === 0) {
return `<${tag}${propsString} />${comment ? ` {/* ${comment} */}` : ""}`;
return `<${tag}${propsString} />${comment ? `{/* ${comment} */}` : ""}`;
}

const result = [
Expand All @@ -94,7 +94,7 @@ export function stringifyElement(element: ElementNode) {
.filter(exists)
.map((child) => recursive(child, depth + 1))
.map((str) => " ".repeat(depth + 1) + str),
`${" ".repeat(depth)}</${tag}>${comment ? ` {/* ${comment} */}` : ""}`,
`${" ".repeat(depth)}</${tag}>${comment ? `{/* ${comment} */}` : ""}`,
].join("\n");

return result;
Expand Down

0 comments on commit 1aff2ed

Please sign in to comment.