@seed-design/figma 0.0.23 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/codegen/index.cjs +32 -9
- package/lib/codegen/index.d.ts +19 -7
- package/lib/codegen/index.js +32 -9
- package/lib/codegen/targets/react/index.cjs +224 -116
- package/lib/codegen/targets/react/index.d.ts +9 -3
- package/lib/codegen/targets/react/index.js +224 -116
- package/package.json +3 -3
- package/src/codegen/core/codegen.ts +6 -3
- package/src/codegen/core/jsx.ts +38 -7
- package/src/codegen/targets/figma/shape.ts +3 -1
- package/src/codegen/targets/figma/text.ts +4 -7
- package/src/codegen/targets/react/component/handlers/action-button.ts +8 -5
- package/src/codegen/targets/react/component/handlers/action-chip.ts +9 -8
- package/src/codegen/targets/react/component/handlers/action-sheet.ts +17 -15
- package/src/codegen/targets/react/component/handlers/app-bar.ts +31 -24
- package/src/codegen/targets/react/component/handlers/avatar-stack.ts +6 -5
- package/src/codegen/targets/react/component/handlers/avatar.ts +12 -7
- package/src/codegen/targets/react/component/handlers/badge.ts +4 -3
- package/src/codegen/targets/react/component/handlers/callout.ts +9 -4
- package/src/codegen/targets/react/component/handlers/checkbox.ts +6 -3
- package/src/codegen/targets/react/component/handlers/chip-tabs.ts +8 -5
- package/src/codegen/targets/react/component/handlers/control-chip.ts +14 -8
- package/src/codegen/targets/react/component/handlers/error-state.ts +6 -3
- package/src/codegen/targets/react/component/handlers/extended-action-sheet.ts +22 -20
- package/src/codegen/targets/react/component/handlers/extended-fab.ts +5 -4
- package/src/codegen/targets/react/component/handlers/fab.ts +9 -5
- package/src/codegen/targets/react/component/handlers/help-bubble.ts +9 -5
- package/src/codegen/targets/react/component/handlers/identity-placeholder.ts +4 -4
- package/src/codegen/targets/react/component/handlers/inline-banner.ts +8 -3
- package/src/codegen/targets/react/component/handlers/manner-temp-badge.ts +6 -3
- package/src/codegen/targets/react/component/handlers/multiline-text-field.ts +7 -4
- package/src/codegen/targets/react/component/handlers/progress-circle.ts +6 -3
- package/src/codegen/targets/react/component/handlers/reaction-button.ts +7 -4
- package/src/codegen/targets/react/component/handlers/segmented-control.ts +15 -11
- package/src/codegen/targets/react/component/handlers/select-box.ts +17 -21
- package/src/codegen/targets/react/component/handlers/skeleton.ts +5 -4
- package/src/codegen/targets/react/component/handlers/snackbar.ts +6 -3
- package/src/codegen/targets/react/component/handlers/switch.ts +6 -3
- package/src/codegen/targets/react/component/handlers/tabs.ts +13 -10
- package/src/codegen/targets/react/component/handlers/text-button.ts +3 -2
- package/src/codegen/targets/react/component/handlers/text-field.ts +7 -4
- package/src/codegen/targets/react/component/handlers/toggle-button.ts +8 -5
- package/src/codegen/targets/react/element-factories.ts +59 -0
- package/src/codegen/targets/react/frame.ts +5 -9
- package/src/codegen/targets/react/icon.ts +7 -2
- package/src/codegen/targets/react/instance.ts +2 -2
- package/src/codegen/targets/react/shape.ts +11 -4
- package/src/codegen/targets/react/text.ts +6 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seed-design/figma",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/daangn/seed-design.git",
|
|
@@ -38,13 +38,13 @@
|
|
|
38
38
|
"lint:publish": "bun publint"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@seed-design/css": "0.0.
|
|
41
|
+
"@seed-design/css": "0.0.25",
|
|
42
42
|
"change-case": "^5.4.4",
|
|
43
43
|
"ts-pattern": "^5.7.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@figma/plugin-typings": "^1.110.0",
|
|
47
|
-
"@figma/rest-api-spec": "^0.
|
|
47
|
+
"@figma/rest-api-spec": "^0.30.0",
|
|
48
48
|
"@seed-design/figma-extractor": "^0.0.4",
|
|
49
49
|
"typescript": "^5.8.3"
|
|
50
50
|
},
|
|
@@ -67,9 +67,12 @@ export function createCodeGenerator({
|
|
|
67
67
|
|
|
68
68
|
function generateCode(node: NormalizedSceneNode, options: { shouldPrintSource: boolean }) {
|
|
69
69
|
const jsxTree = generateJsxTree(node);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
|
|
71
|
+
if (!jsxTree) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return stringifyElement(jsxTree, { printSource: options.shouldPrintSource });
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
return { generateJsxTree, generateCode };
|
package/src/codegen/core/jsx.ts
CHANGED
|
@@ -5,22 +5,26 @@ export interface ElementNode {
|
|
|
5
5
|
tag: string;
|
|
6
6
|
props: Record<string, string | number | boolean | ElementNode | object | undefined>;
|
|
7
7
|
children: (ElementNode | string)[];
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
|
|
9
|
+
meta: {
|
|
10
|
+
comment?: string;
|
|
11
|
+
source?: string;
|
|
12
|
+
importPath?: string;
|
|
13
|
+
};
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
export function createElement(
|
|
13
17
|
tag: string,
|
|
14
18
|
props: Record<string, string | number | boolean | object | undefined> = {},
|
|
15
19
|
children?: ElementNode | string | undefined | (ElementNode | string | undefined)[],
|
|
16
|
-
|
|
20
|
+
meta?: ElementNode["meta"],
|
|
17
21
|
): ElementNode {
|
|
18
22
|
return {
|
|
19
23
|
__IS_JSX_ELEMENT_NODE: true,
|
|
20
24
|
tag,
|
|
21
25
|
props,
|
|
22
26
|
children: ensureArray(children).filter(exists),
|
|
23
|
-
|
|
27
|
+
meta: meta ?? {},
|
|
24
28
|
};
|
|
25
29
|
}
|
|
26
30
|
|
|
@@ -53,14 +57,31 @@ export function isElement(node: unknown): node is ElementNode {
|
|
|
53
57
|
}
|
|
54
58
|
|
|
55
59
|
export function stringifyElement(element: ElementNode, options: { printSource?: boolean } = {}) {
|
|
60
|
+
const importMap = new Map<string, Set<string>>();
|
|
61
|
+
|
|
56
62
|
function recursive(node: ElementNode | string, depth: number): string {
|
|
57
63
|
if (typeof node === "string") {
|
|
58
64
|
return node;
|
|
59
65
|
}
|
|
60
66
|
|
|
61
|
-
const {
|
|
67
|
+
const {
|
|
68
|
+
tag,
|
|
69
|
+
props,
|
|
70
|
+
children,
|
|
71
|
+
meta: { comment, source, importPath },
|
|
72
|
+
} = node;
|
|
73
|
+
|
|
74
|
+
if (importPath) {
|
|
75
|
+
const existing = importMap.get(importPath);
|
|
76
|
+
if (existing) {
|
|
77
|
+
existing.add(tag);
|
|
78
|
+
} else {
|
|
79
|
+
importMap.set(importPath, new Set([tag]));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
62
83
|
const propEntries = Object.entries(
|
|
63
|
-
options.printSource ? { ...props, "data-figma-node-id":
|
|
84
|
+
options.printSource ? { ...props, "data-figma-node-id": source } : props,
|
|
64
85
|
);
|
|
65
86
|
const propFragments = propEntries
|
|
66
87
|
.map(([key, value]) => {
|
|
@@ -122,5 +143,15 @@ export function stringifyElement(element: ElementNode, options: { printSource?:
|
|
|
122
143
|
return result;
|
|
123
144
|
}
|
|
124
145
|
|
|
125
|
-
|
|
146
|
+
const jsx = recursive(element, 0);
|
|
147
|
+
|
|
148
|
+
const imports = Array.from(importMap.entries())
|
|
149
|
+
.sort((a, b) => a[0].localeCompare(b[0]))
|
|
150
|
+
.map(([importPath, tags]) => `import { ${Array.from(tags).join(", ")} } from "${importPath}";`)
|
|
151
|
+
.join("\n");
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
imports,
|
|
155
|
+
jsx,
|
|
156
|
+
};
|
|
126
157
|
}
|
|
@@ -21,13 +21,10 @@ export function createTextTransformer({
|
|
|
21
21
|
...fillProps,
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
return createElement(
|
|
25
|
-
|
|
26
|
-
props,
|
|
27
|
-
node.characters,
|
|
28
|
-
hasMultipleFills
|
|
24
|
+
return createElement("Text", props, node.characters, {
|
|
25
|
+
comment: hasMultipleFills
|
|
29
26
|
? "Multiple fills in Text node encountered, only the first fill is used."
|
|
30
|
-
:
|
|
31
|
-
);
|
|
27
|
+
: undefined,
|
|
28
|
+
});
|
|
32
29
|
});
|
|
33
30
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import { camelCase } from "change-case";
|
|
4
4
|
import { match } from "ts-pattern";
|
|
5
5
|
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
6
6
|
import type { ActionButtonProperties } from "@/codegen/component-properties";
|
|
7
7
|
import { handleSizeProp } from "../size";
|
|
8
|
+
import { createLocalSnippetHelper } from "../../element-factories";
|
|
9
|
+
|
|
10
|
+
const { createLocalSnippetElement } = createLocalSnippetHelper("action-button");
|
|
8
11
|
|
|
9
12
|
export const createActionButtonHandler = (ctx: ComponentHandlerDeps) =>
|
|
10
13
|
defineComponentHandler<ActionButtonProperties>(
|
|
@@ -16,7 +19,7 @@ export const createActionButtonHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
16
19
|
.with("Icon Only", () => ({
|
|
17
20
|
layout: "iconOnly",
|
|
18
21
|
children: [
|
|
19
|
-
|
|
22
|
+
createLocalSnippetElement("Icon", {
|
|
20
23
|
svg: ctx.iconHandler.transform(props["Icon#7574:0"]),
|
|
21
24
|
}),
|
|
22
25
|
],
|
|
@@ -24,7 +27,7 @@ export const createActionButtonHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
24
27
|
.with("Icon First", () => ({
|
|
25
28
|
layout: "withText",
|
|
26
29
|
children: [
|
|
27
|
-
|
|
30
|
+
createLocalSnippetElement("PrefixIcon", {
|
|
28
31
|
svg: ctx.iconHandler.transform(props["Prefix Icon#5987:305"]),
|
|
29
32
|
}),
|
|
30
33
|
props["Label#5987:61"].value,
|
|
@@ -34,7 +37,7 @@ export const createActionButtonHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
34
37
|
layout: "withText",
|
|
35
38
|
children: [
|
|
36
39
|
props["Label#5987:61"].value,
|
|
37
|
-
|
|
40
|
+
createLocalSnippetElement("SuffixIcon", {
|
|
38
41
|
svg: ctx.iconHandler.transform(props["Suffix Icon#5987:244"]),
|
|
39
42
|
}),
|
|
40
43
|
],
|
|
@@ -57,6 +60,6 @@ export const createActionButtonHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
57
60
|
layout,
|
|
58
61
|
};
|
|
59
62
|
|
|
60
|
-
return
|
|
63
|
+
return createLocalSnippetElement("ActionButton", commonProps, children);
|
|
61
64
|
},
|
|
62
65
|
);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ActionChipProperties } from "@/codegen/component-properties";
|
|
2
|
+
import { defineComponentHandler } from "@/codegen/core";
|
|
2
3
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
4
|
import { match } from "ts-pattern";
|
|
5
|
+
import { createSeedReactElement } from "../../element-factories";
|
|
4
6
|
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
|
-
import type { ActionChipProperties } from "@/codegen/component-properties";
|
|
6
7
|
import { handleSizeProp } from "../size";
|
|
7
8
|
|
|
8
9
|
export const createActionChipHandler = (ctx: ComponentHandlerDeps) =>
|
|
@@ -15,7 +16,7 @@ export const createActionChipHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
15
16
|
.with("Icon Only", () => ({
|
|
16
17
|
layout: "iconOnly",
|
|
17
18
|
children: [
|
|
18
|
-
|
|
19
|
+
createSeedReactElement("Icon", {
|
|
19
20
|
svg: ctx.iconHandler.transform(props["Icon#8714:0"]),
|
|
20
21
|
}),
|
|
21
22
|
],
|
|
@@ -23,7 +24,7 @@ export const createActionChipHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
23
24
|
.with("Icon First", () => ({
|
|
24
25
|
layout: "withText",
|
|
25
26
|
children: [
|
|
26
|
-
|
|
27
|
+
createSeedReactElement("PrefixIcon", {
|
|
27
28
|
svg: ctx.iconHandler.transform(props["Prefix Icon#8711:0"]),
|
|
28
29
|
}),
|
|
29
30
|
props["Label#7185:0"].value,
|
|
@@ -33,7 +34,7 @@ export const createActionChipHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
33
34
|
layout: "withText",
|
|
34
35
|
children: [
|
|
35
36
|
props["Label#7185:0"].value,
|
|
36
|
-
|
|
37
|
+
createSeedReactElement("SuffixIcon", {
|
|
37
38
|
svg: ctx.iconHandler.transform(props["Suffix Icon#8711:3"]),
|
|
38
39
|
}),
|
|
39
40
|
],
|
|
@@ -41,11 +42,11 @@ export const createActionChipHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
41
42
|
.with("Icon Both", () => ({
|
|
42
43
|
layout: "withText",
|
|
43
44
|
children: [
|
|
44
|
-
|
|
45
|
+
createSeedReactElement("PrefixIcon", {
|
|
45
46
|
svg: ctx.iconHandler.transform(props["Prefix Icon#8711:0"]),
|
|
46
47
|
}),
|
|
47
48
|
props["Label#7185:0"].value,
|
|
48
|
-
|
|
49
|
+
createSeedReactElement("SuffixIcon", {
|
|
49
50
|
svg: ctx.iconHandler.transform(props["Suffix Icon#8711:3"]),
|
|
50
51
|
}),
|
|
51
52
|
],
|
|
@@ -66,6 +67,6 @@ export const createActionChipHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
66
67
|
count: Number(props["Count#7185:21"].value),
|
|
67
68
|
}),
|
|
68
69
|
};
|
|
69
|
-
return
|
|
70
|
+
return createSeedReactElement("ActionChip", commonProps, children);
|
|
70
71
|
},
|
|
71
72
|
);
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ActionSheetItemProperties,
|
|
3
|
+
ActionSheetProperties,
|
|
4
|
+
} from "@/codegen/component-properties";
|
|
1
5
|
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
6
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
7
|
import { findAllInstances } from "@/utils/figma-node";
|
|
4
8
|
import { camelCase } from "change-case";
|
|
5
9
|
import { match } from "ts-pattern";
|
|
10
|
+
import { createLocalSnippetHelper } from "../../element-factories";
|
|
6
11
|
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
ActionSheetProperties,
|
|
10
|
-
} from "@/codegen/component-properties";
|
|
12
|
+
|
|
13
|
+
const { createLocalSnippetElement } = createLocalSnippetHelper("action-sheet");
|
|
11
14
|
|
|
12
15
|
const ACTION_SHEET_ITEM_KEY = "c3cafd3a3fdcd45fecb6971019d88eaf39a2e381";
|
|
13
16
|
const createActionSheetItemHandler = (_ctx: ComponentHandlerDeps) =>
|
|
@@ -24,7 +27,7 @@ const createActionSheetItemHandler = (_ctx: ComponentHandlerDeps) =>
|
|
|
24
27
|
}),
|
|
25
28
|
};
|
|
26
29
|
|
|
27
|
-
return
|
|
30
|
+
return createLocalSnippetElement("ActionSheetItem", commonProps);
|
|
28
31
|
},
|
|
29
32
|
);
|
|
30
33
|
|
|
@@ -60,21 +63,20 @@ export const createActionSheetHandler = (ctx: ComponentHandlerDeps) => {
|
|
|
60
63
|
|
|
61
64
|
const contentChildren = items.map(actionSheetItemHandler.transform);
|
|
62
65
|
|
|
63
|
-
const content =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
contentChildren,
|
|
67
|
-
contentProps.title
|
|
68
|
-
? ""
|
|
66
|
+
const content = createLocalSnippetElement("ActionSheetContent", contentProps, contentChildren, {
|
|
67
|
+
comment: contentProps.title
|
|
68
|
+
? undefined
|
|
69
69
|
: "title을 제공하지 않는 경우 aria-label이나 aria-labelledby 중 하나를 제공해야 합니다.",
|
|
70
|
-
);
|
|
70
|
+
});
|
|
71
71
|
|
|
72
|
-
const trigger =
|
|
72
|
+
const trigger = createLocalSnippetElement(
|
|
73
73
|
"ActionSheetTrigger",
|
|
74
74
|
{ asChild: true },
|
|
75
|
-
createElement("
|
|
75
|
+
createElement("button", undefined, "열기", {
|
|
76
|
+
comment: "ActionSheet을 여는 요소를 제공해주세요.",
|
|
77
|
+
}),
|
|
76
78
|
);
|
|
77
79
|
|
|
78
|
-
return
|
|
80
|
+
return createLocalSnippetElement("ActionSheet", undefined, [trigger, content]);
|
|
79
81
|
});
|
|
80
82
|
};
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
|
-
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
|
-
import type { NormalizedInstanceNode, NormalizedTextNode } from "@/normalizer";
|
|
4
|
-
import { findAll, findAllInstances, findOne } from "@/utils/figma-node";
|
|
5
|
-
import { match } from "ts-pattern";
|
|
6
|
-
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
7
1
|
import type {
|
|
8
2
|
AppBarLeftProperties,
|
|
9
3
|
AppBarMainProperties,
|
|
10
4
|
AppBarProperties,
|
|
11
5
|
AppBarRightProperties,
|
|
12
6
|
} from "@/codegen/component-properties";
|
|
7
|
+
import { defineComponentHandler } from "@/codegen/core";
|
|
8
|
+
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
9
|
+
import type { NormalizedInstanceNode, NormalizedTextNode } from "@/normalizer";
|
|
10
|
+
import { findAll, findAllInstances, findOne } from "@/utils/figma-node";
|
|
11
|
+
import { match } from "ts-pattern";
|
|
12
|
+
import { createLocalSnippetHelper } from "../../element-factories";
|
|
13
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
14
|
+
|
|
15
|
+
const { createLocalSnippetElement } = createLocalSnippetHelper("app-bar");
|
|
13
16
|
|
|
14
17
|
const APP_BAR_MAIN_KEY = "336b49b26c3933485d87cc460b06c390976ea58e";
|
|
15
18
|
const createAppBarMainHandler = (_ctx: ComponentHandlerDeps) =>
|
|
@@ -39,12 +42,9 @@ const createAppBarMainHandler = (_ctx: ComponentHandlerDeps) =>
|
|
|
39
42
|
layout,
|
|
40
43
|
};
|
|
41
44
|
|
|
42
|
-
return
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
undefined,
|
|
46
|
-
title === undefined ? "Title을 제공해주세요." : undefined,
|
|
47
|
-
);
|
|
45
|
+
return createLocalSnippetElement("AppBarMain", commonProps, undefined, {
|
|
46
|
+
comment: title === undefined ? "Title을 제공해주세요." : undefined,
|
|
47
|
+
});
|
|
48
48
|
},
|
|
49
49
|
);
|
|
50
50
|
|
|
@@ -56,9 +56,9 @@ const createAppBarLeftHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
56
56
|
const children = (() => {
|
|
57
57
|
switch (props.Action.value) {
|
|
58
58
|
case "Back":
|
|
59
|
-
return
|
|
59
|
+
return createLocalSnippetElement("AppBarBackButton");
|
|
60
60
|
case "Close":
|
|
61
|
-
return
|
|
61
|
+
return createLocalSnippetElement("AppBarCloseButton");
|
|
62
62
|
case "Other": {
|
|
63
63
|
const iconNode = findOne(
|
|
64
64
|
node,
|
|
@@ -69,17 +69,19 @@ const createAppBarLeftHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
69
69
|
return undefined;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
return
|
|
72
|
+
return createLocalSnippetElement(
|
|
73
73
|
"AppBarIconButton",
|
|
74
74
|
undefined,
|
|
75
75
|
ctx.iconHandler.transform(iconNode),
|
|
76
|
-
|
|
76
|
+
{
|
|
77
|
+
comment: "aria-label 또는 aria-labelledby를 제공해주세요.",
|
|
78
|
+
},
|
|
77
79
|
);
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
82
|
})();
|
|
81
83
|
|
|
82
|
-
return
|
|
84
|
+
return createLocalSnippetElement("AppBarLeft", undefined, children);
|
|
83
85
|
});
|
|
84
86
|
|
|
85
87
|
const APP_BAR_RIGHT_KEY = "9e157fc2d1f89ffee938a5bc62f4a58064fec44e";
|
|
@@ -104,18 +106,20 @@ const createAppBarRightHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
104
106
|
) as NormalizedInstanceNode[];
|
|
105
107
|
|
|
106
108
|
return iconNodes.map((iconNode) =>
|
|
107
|
-
|
|
109
|
+
createLocalSnippetElement(
|
|
108
110
|
"AppBarIconButton",
|
|
109
111
|
undefined,
|
|
110
112
|
ctx.iconHandler.transform(iconNode),
|
|
111
|
-
|
|
113
|
+
{
|
|
114
|
+
comment: "aria-label 또는 aria-labelledby를 제공해주세요.",
|
|
115
|
+
},
|
|
112
116
|
),
|
|
113
117
|
);
|
|
114
118
|
}
|
|
115
119
|
}
|
|
116
120
|
})();
|
|
117
121
|
|
|
118
|
-
return
|
|
122
|
+
return createLocalSnippetElement("AppBarRight", undefined, children);
|
|
119
123
|
});
|
|
120
124
|
|
|
121
125
|
export const createAppBarHandler = (ctx: ComponentHandlerDeps) => {
|
|
@@ -165,13 +169,16 @@ export const createAppBarHandler = (ctx: ComponentHandlerDeps) => {
|
|
|
165
169
|
const onlyRightNode = rightNode.length === 1 ? rightNode[0] : undefined;
|
|
166
170
|
const right = onlyRightNode ? appBarRightHandler.transform(onlyRightNode) : undefined;
|
|
167
171
|
|
|
168
|
-
return
|
|
172
|
+
return createLocalSnippetElement(
|
|
169
173
|
"AppBar",
|
|
170
174
|
{ theme, tone },
|
|
171
175
|
[left, main, right].filter(Boolean),
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
176
|
+
{
|
|
177
|
+
comment:
|
|
178
|
+
tone === "transparent"
|
|
179
|
+
? '<AppScreen layerOffsetTop="none">으로 상단 패딩을 제거할 수 있습니다.'
|
|
180
|
+
: undefined,
|
|
181
|
+
},
|
|
175
182
|
);
|
|
176
183
|
});
|
|
177
184
|
};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AvatarProperties, AvatarStackProperties } from "@/codegen/component-properties";
|
|
2
|
+
import { defineComponentHandler } from "@/codegen/core";
|
|
2
3
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
4
|
import { findAllInstances } from "@/utils/figma-node";
|
|
5
|
+
import { createLocalSnippetHelper } from "../../element-factories";
|
|
4
6
|
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
|
-
import type { AvatarProperties, AvatarStackProperties } from "@/codegen/component-properties";
|
|
6
7
|
import { createAvatarHandler } from "./avatar";
|
|
7
8
|
|
|
9
|
+
const { createLocalSnippetElement } = createLocalSnippetHelper("avatar");
|
|
10
|
+
|
|
8
11
|
export const createAvatarStackHandler = (ctx: ComponentHandlerDeps) => {
|
|
9
12
|
const avatarHandler = createAvatarHandler(ctx);
|
|
10
13
|
|
|
@@ -18,12 +21,10 @@ export const createAvatarStackHandler = (ctx: ComponentHandlerDeps) => {
|
|
|
18
21
|
|
|
19
22
|
const commonProps = {
|
|
20
23
|
size: props.Size.value,
|
|
21
|
-
// TODO: 구현될 예정
|
|
22
|
-
// topItem: camelCase(props["Top Item"].value),
|
|
23
24
|
};
|
|
24
25
|
|
|
25
26
|
const avatarStackChildren = avatarNodes.map(avatarHandler.transform);
|
|
26
27
|
|
|
27
|
-
return
|
|
28
|
+
return createLocalSnippetElement("AvatarStack", commonProps, avatarStackChildren);
|
|
28
29
|
});
|
|
29
30
|
};
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
|
-
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
|
-
import { findAllInstances } from "@/utils/figma-node";
|
|
4
|
-
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
1
|
import type {
|
|
6
2
|
AvatarProperties,
|
|
7
3
|
IdentityPlaceholderProperties,
|
|
8
4
|
} from "@/codegen/component-properties";
|
|
5
|
+
import { defineComponentHandler } from "@/codegen/core";
|
|
6
|
+
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
7
|
+
import { findAllInstances } from "@/utils/figma-node";
|
|
8
|
+
import { createLocalSnippetHelper } from "../../element-factories";
|
|
9
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
9
10
|
import { createIdentityPlaceholderHandler } from "./identity-placeholder";
|
|
10
11
|
|
|
12
|
+
const { createLocalSnippetElement } = createLocalSnippetHelper("avatar");
|
|
13
|
+
|
|
11
14
|
export const createAvatarHandler = (ctx: ComponentHandlerDeps) => {
|
|
12
15
|
const identityPlaceholderHandler = createIdentityPlaceholderHandler(ctx);
|
|
13
16
|
|
|
@@ -31,11 +34,13 @@ export const createAvatarHandler = (ctx: ComponentHandlerDeps) => {
|
|
|
31
34
|
size: props.Size.value,
|
|
32
35
|
};
|
|
33
36
|
|
|
34
|
-
return
|
|
37
|
+
return createLocalSnippetElement(
|
|
35
38
|
"Avatar",
|
|
36
39
|
commonProps,
|
|
37
|
-
props["Show Badge#1398:26"].value ?
|
|
38
|
-
|
|
40
|
+
props["Show Badge#1398:26"].value ? createLocalSnippetElement("AvatarBadge", {}) : undefined,
|
|
41
|
+
{
|
|
42
|
+
comment: avatarHasSrc ? "alt 텍스트를 제공해야 합니다." : undefined,
|
|
43
|
+
},
|
|
39
44
|
);
|
|
40
45
|
});
|
|
41
46
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { BadgeProperties } from "@/codegen/component-properties";
|
|
2
|
+
import { defineComponentHandler } from "@/codegen/core";
|
|
2
3
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
4
|
import { camelCase } from "change-case";
|
|
5
|
+
import { createSeedReactElement } from "../../element-factories";
|
|
4
6
|
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
|
-
import type { BadgeProperties } from "@/codegen/component-properties";
|
|
6
7
|
import { handleSizeProp } from "../size";
|
|
7
8
|
|
|
8
9
|
export const createBadgeHandler = (_ctx: ComponentHandlerDeps) =>
|
|
@@ -14,5 +15,5 @@ export const createBadgeHandler = (_ctx: ComponentHandlerDeps) =>
|
|
|
14
15
|
shape: camelCase(props.Shape.value),
|
|
15
16
|
};
|
|
16
17
|
|
|
17
|
-
return
|
|
18
|
+
return createSeedReactElement("Badge", commonProps, props["Label#1584:0"].value);
|
|
18
19
|
});
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { CalloutProperties } from "@/codegen/component-properties";
|
|
2
|
+
import { defineComponentHandler } from "@/codegen/core";
|
|
2
3
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
4
|
import type { NormalizedTextNode } from "@/normalizer";
|
|
4
5
|
import { camelCase } from "change-case";
|
|
6
|
+
import { createLocalSnippetHelper } from "../../element-factories";
|
|
5
7
|
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
6
|
-
|
|
8
|
+
|
|
9
|
+
const { createLocalSnippetElement } = createLocalSnippetHelper("callout");
|
|
7
10
|
|
|
8
11
|
export const createCalloutHandler = (ctx: ComponentHandlerDeps) =>
|
|
9
12
|
defineComponentHandler<CalloutProperties>(
|
|
@@ -25,7 +28,9 @@ export const createCalloutHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
25
28
|
const textNode = children.find((child) => child.type === "TEXT") as NormalizedTextNode | null;
|
|
26
29
|
|
|
27
30
|
if (!textNode) {
|
|
28
|
-
return
|
|
31
|
+
return createLocalSnippetElement(tag, undefined, undefined, {
|
|
32
|
+
comment: "내용을 제공해주세요.",
|
|
33
|
+
});
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
const slices = textNode.segments;
|
|
@@ -82,6 +87,6 @@ export const createCalloutHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
82
87
|
}),
|
|
83
88
|
};
|
|
84
89
|
|
|
85
|
-
return
|
|
90
|
+
return createLocalSnippetElement(tag, commonProps);
|
|
86
91
|
},
|
|
87
92
|
);
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { CheckboxProperties } from "@/codegen/component-properties";
|
|
2
|
+
import { defineComponentHandler } from "@/codegen/core";
|
|
2
3
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
4
|
import { camelCase } from "change-case";
|
|
5
|
+
import { createLocalSnippetHelper } from "../../element-factories";
|
|
4
6
|
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
|
-
import type { CheckboxProperties } from "@/codegen/component-properties";
|
|
6
7
|
import { handleSizeProp } from "../size";
|
|
7
8
|
|
|
9
|
+
const { createLocalSnippetElement } = createLocalSnippetHelper("checkbox");
|
|
10
|
+
|
|
8
11
|
export const createCheckboxHandler = (_ctx: ComponentHandlerDeps) =>
|
|
9
12
|
defineComponentHandler<CheckboxProperties>(
|
|
10
13
|
metadata.checkbox.key,
|
|
@@ -28,6 +31,6 @@ export const createCheckboxHandler = (_ctx: ComponentHandlerDeps) =>
|
|
|
28
31
|
}),
|
|
29
32
|
};
|
|
30
33
|
|
|
31
|
-
return
|
|
34
|
+
return createLocalSnippetElement("Checkbox", commonProps);
|
|
32
35
|
},
|
|
33
36
|
);
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ChipTabsItemProperties, ChipTabsProperties } from "@/codegen/component-properties";
|
|
2
|
+
import { defineComponentHandler } from "@/codegen/core";
|
|
2
3
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
4
|
import { findAllInstances } from "@/utils/figma-node";
|
|
4
5
|
import { camelCase } from "change-case";
|
|
6
|
+
import { createLocalSnippetHelper } from "../../element-factories";
|
|
5
7
|
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
6
|
-
|
|
8
|
+
|
|
9
|
+
const { createLocalSnippetElement } = createLocalSnippetHelper("chip-tabs");
|
|
7
10
|
|
|
8
11
|
const CHIP_TABS_ITEM_KEY = "fa80168b02051fbb0ba032238bd76d840dbe2e15";
|
|
9
12
|
const createChipTabsItemHandler = (_ctx: ComponentHandlerDeps) =>
|
|
@@ -19,7 +22,7 @@ const createChipTabsItemHandler = (_ctx: ComponentHandlerDeps) =>
|
|
|
19
22
|
}),
|
|
20
23
|
};
|
|
21
24
|
|
|
22
|
-
return
|
|
25
|
+
return createLocalSnippetElement("ChipTabsTrigger", commonProps, props["Label#8876:0"].value);
|
|
23
26
|
},
|
|
24
27
|
);
|
|
25
28
|
|
|
@@ -36,7 +39,7 @@ export const createChipTabsHandler = (ctx: ComponentHandlerDeps) => {
|
|
|
36
39
|
chipTabsItem.componentProperties.State.value.split("-").includes("Selected"),
|
|
37
40
|
);
|
|
38
41
|
|
|
39
|
-
const chipTabsList =
|
|
42
|
+
const chipTabsList = createLocalSnippetElement(
|
|
40
43
|
"ChipTabsList",
|
|
41
44
|
undefined,
|
|
42
45
|
chipTabsItems.map(chipTabsItemHandler.transform),
|
|
@@ -49,6 +52,6 @@ export const createChipTabsHandler = (ctx: ComponentHandlerDeps) => {
|
|
|
49
52
|
}),
|
|
50
53
|
};
|
|
51
54
|
|
|
52
|
-
return
|
|
55
|
+
return createLocalSnippetElement("ChipTabs", commonProps, chipTabsList);
|
|
53
56
|
});
|
|
54
57
|
};
|