@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
|
@@ -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 } from "@/normalizer";
|
|
4
|
-
import { camelCase } from "change-case";
|
|
5
|
-
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
6
1
|
import type {
|
|
7
2
|
TabsFillItemProperties,
|
|
8
3
|
TabsHugItemProperties,
|
|
9
4
|
TabsProperties,
|
|
10
5
|
} from "@/codegen/component-properties";
|
|
6
|
+
import { defineComponentHandler } from "@/codegen/core";
|
|
7
|
+
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
8
|
+
import type { NormalizedInstanceNode } from "@/normalizer";
|
|
9
|
+
import { camelCase } from "change-case";
|
|
10
|
+
import { createLocalSnippetHelper } from "../../element-factories";
|
|
11
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
11
12
|
import { handleSizeProp } from "../size";
|
|
12
13
|
|
|
14
|
+
const { createLocalSnippetElement } = createLocalSnippetHelper("tabs");
|
|
15
|
+
|
|
13
16
|
const TABS_HUG_ITEM_KEY = "c242492543b327ceb84fa9933841512fc62a898c";
|
|
14
17
|
const createTabsHugItemHandler = (_ctx: ComponentHandlerDeps) =>
|
|
15
18
|
defineComponentHandler<TabsHugItemProperties>(
|
|
@@ -27,7 +30,7 @@ const createTabsHugItemHandler = (_ctx: ComponentHandlerDeps) =>
|
|
|
27
30
|
}),
|
|
28
31
|
};
|
|
29
32
|
|
|
30
|
-
return
|
|
33
|
+
return createLocalSnippetElement("TabsTrigger", commonProps, props["Label#4478:2"].value);
|
|
31
34
|
},
|
|
32
35
|
);
|
|
33
36
|
|
|
@@ -48,7 +51,7 @@ const createTabsFillItemHandler = (_ctx: ComponentHandlerDeps) =>
|
|
|
48
51
|
}),
|
|
49
52
|
};
|
|
50
53
|
|
|
51
|
-
return
|
|
54
|
+
return createLocalSnippetElement("TabsTrigger", commonProps, props["Label#4478:2"].value);
|
|
52
55
|
},
|
|
53
56
|
);
|
|
54
57
|
|
|
@@ -96,7 +99,7 @@ export const createTabsHandler = (ctx: ComponentHandlerDeps) => {
|
|
|
96
99
|
componentProperties.State.value.split("-").includes("Selected"),
|
|
97
100
|
)?.node;
|
|
98
101
|
|
|
99
|
-
const tabTriggerList =
|
|
102
|
+
const tabTriggerList = createLocalSnippetElement(
|
|
100
103
|
"TabsList",
|
|
101
104
|
undefined,
|
|
102
105
|
tabsItems.map(({ triggerLayout, node }) => {
|
|
@@ -112,7 +115,7 @@ export const createTabsHandler = (ctx: ComponentHandlerDeps) => {
|
|
|
112
115
|
const tabContents = tabsItems.map(({ node }) => {
|
|
113
116
|
const value = node.componentProperties["Label#4478:2"].value;
|
|
114
117
|
|
|
115
|
-
return
|
|
118
|
+
return createLocalSnippetElement("TabsContent", { value }, "{/* TODO: 컨텐츠 추가 */}");
|
|
116
119
|
});
|
|
117
120
|
|
|
118
121
|
const commonProps = {
|
|
@@ -123,6 +126,6 @@ export const createTabsHandler = (ctx: ComponentHandlerDeps) => {
|
|
|
123
126
|
}),
|
|
124
127
|
};
|
|
125
128
|
|
|
126
|
-
return
|
|
129
|
+
return createLocalSnippetElement("TabsRoot", commonProps, [tabTriggerList, ...tabContents]);
|
|
127
130
|
});
|
|
128
131
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { TextButtonProperties } from "@/codegen/component-properties";
|
|
2
|
-
import {
|
|
2
|
+
import { defineComponentHandler } from "@/codegen/core";
|
|
3
3
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
4
4
|
import type { NormalizedInstanceNode } from "@/normalizer";
|
|
5
5
|
import { findOne } from "@/utils/figma-node";
|
|
6
6
|
import { camelCase } from "change-case";
|
|
7
7
|
import { match } from "ts-pattern";
|
|
8
|
+
import { createSeedReactElement } from "../../element-factories";
|
|
8
9
|
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
9
10
|
import { handleSizeProp } from "../size";
|
|
10
11
|
|
|
@@ -44,5 +45,5 @@ export const createTextButtonHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
44
45
|
}),
|
|
45
46
|
};
|
|
46
47
|
|
|
47
|
-
return
|
|
48
|
+
return createSeedReactElement("TextButton", commonProps, children);
|
|
48
49
|
});
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TextFieldProperties } from "@/codegen/component-properties";
|
|
2
|
+
import { defineComponentHandler } from "@/codegen/core";
|
|
2
3
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
4
|
+
import { createLocalSnippetHelper } from "../../element-factories";
|
|
3
5
|
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
4
|
-
import type { TextFieldProperties } from "@/codegen/component-properties";
|
|
5
6
|
import { handleSizeProp } from "../size";
|
|
6
7
|
|
|
8
|
+
const { createLocalSnippetElement } = createLocalSnippetHelper("text-field");
|
|
9
|
+
|
|
7
10
|
export const createTextFieldHandler = (ctx: ComponentHandlerDeps) =>
|
|
8
11
|
defineComponentHandler<TextFieldProperties>(
|
|
9
12
|
metadata.textField.key,
|
|
@@ -101,8 +104,8 @@ export const createTextFieldHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
101
104
|
placeholder,
|
|
102
105
|
};
|
|
103
106
|
|
|
104
|
-
const TextFieldChildren =
|
|
107
|
+
const TextFieldChildren = createLocalSnippetElement("TextFieldInput", inputProps);
|
|
105
108
|
|
|
106
|
-
return
|
|
109
|
+
return createLocalSnippetElement("TextField", commonProps, TextFieldChildren);
|
|
107
110
|
},
|
|
108
111
|
);
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ToggleButtonProperties } 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, createSeedReactElement } from "../../element-factories";
|
|
4
6
|
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
|
-
import type { ToggleButtonProperties } from "@/codegen/component-properties";
|
|
6
7
|
import { handleSizeProp } from "../size";
|
|
7
8
|
|
|
9
|
+
const { createLocalSnippetElement } = createLocalSnippetHelper("toggle-button");
|
|
10
|
+
|
|
8
11
|
export const createToggleButtonHandler = (ctx: ComponentHandlerDeps) =>
|
|
9
12
|
defineComponentHandler<ToggleButtonProperties>(
|
|
10
13
|
metadata.toggleButton.key,
|
|
@@ -25,15 +28,15 @@ export const createToggleButtonHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
25
28
|
}),
|
|
26
29
|
};
|
|
27
30
|
|
|
28
|
-
return
|
|
31
|
+
return createLocalSnippetElement("ToggleButton", commonProps, [
|
|
29
32
|
props["Show Prefix Icon#6122:392"].value
|
|
30
|
-
?
|
|
33
|
+
? createSeedReactElement("PrefixIcon", {
|
|
31
34
|
svg: ctx.iconHandler.transform(props["Prefix Icon#6122:98"]),
|
|
32
35
|
})
|
|
33
36
|
: undefined,
|
|
34
37
|
props["Label#6122:49"].value,
|
|
35
38
|
props["Show Suffix Icon#6122:147"].value
|
|
36
|
-
?
|
|
39
|
+
? createSeedReactElement("SuffixIcon", {
|
|
37
40
|
svg: ctx.iconHandler.transform(props["Suffix Icon#6122:343"]),
|
|
38
41
|
})
|
|
39
42
|
: undefined,
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createElement, type ElementNode } from "@/codegen/core";
|
|
2
|
+
|
|
3
|
+
const SEED_REACT_IMPORT_PATH = "@seed-design/react";
|
|
4
|
+
const LOCAL_SNIPPET_BASE_PATH = "@/seed-design/ui";
|
|
5
|
+
const MONOCHROME_ICON_IMPORT_PATH = "@karrotmarket/react-monochrome-icon";
|
|
6
|
+
const MULTICOLOR_ICON_IMPORT_PATH = "@karrotmarket/react-multicolor-icon";
|
|
7
|
+
|
|
8
|
+
type CreateElementArgs = Parameters<typeof createElement>;
|
|
9
|
+
|
|
10
|
+
export function createSeedReactElement(
|
|
11
|
+
tag: CreateElementArgs[0],
|
|
12
|
+
props?: CreateElementArgs[1],
|
|
13
|
+
children?: CreateElementArgs[2],
|
|
14
|
+
meta?: CreateElementArgs[3],
|
|
15
|
+
): ElementNode {
|
|
16
|
+
return createElement(tag, props, children, {
|
|
17
|
+
importPath: SEED_REACT_IMPORT_PATH,
|
|
18
|
+
...meta,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function createMonochromeIconElement(
|
|
23
|
+
tag: CreateElementArgs[0],
|
|
24
|
+
props?: CreateElementArgs[1],
|
|
25
|
+
children?: CreateElementArgs[2],
|
|
26
|
+
meta?: CreateElementArgs[3],
|
|
27
|
+
): ElementNode {
|
|
28
|
+
return createElement(tag, props, children, {
|
|
29
|
+
...meta,
|
|
30
|
+
importPath: MONOCHROME_ICON_IMPORT_PATH,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function createMulticolorIconElement(
|
|
35
|
+
tag: CreateElementArgs[0],
|
|
36
|
+
props?: CreateElementArgs[1],
|
|
37
|
+
children?: CreateElementArgs[2],
|
|
38
|
+
meta?: CreateElementArgs[3],
|
|
39
|
+
): ElementNode {
|
|
40
|
+
return createElement(tag, props, children, { ...meta, importPath: MULTICOLOR_ICON_IMPORT_PATH });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function createLocalSnippetHelper(moduleName: string) {
|
|
44
|
+
function createLocalSnippetElement(
|
|
45
|
+
tag: CreateElementArgs[0],
|
|
46
|
+
props?: CreateElementArgs[1],
|
|
47
|
+
children?: CreateElementArgs[2],
|
|
48
|
+
meta?: CreateElementArgs[3],
|
|
49
|
+
): ElementNode {
|
|
50
|
+
return createElement(tag, props, children, {
|
|
51
|
+
importPath: `${LOCAL_SNIPPET_BASE_PATH}/${moduleName}`,
|
|
52
|
+
...meta,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
createLocalSnippetElement,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -3,12 +3,8 @@ import type {
|
|
|
3
3
|
NormalizedFrameNode,
|
|
4
4
|
NormalizedInstanceNode,
|
|
5
5
|
} from "@/normalizer";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
createElement,
|
|
9
|
-
defineElementTransformer,
|
|
10
|
-
type ElementTransformer,
|
|
11
|
-
} from "../../core";
|
|
6
|
+
import { cloneElement, defineElementTransformer, type ElementTransformer } from "../../core";
|
|
7
|
+
import { createSeedReactElement } from "./element-factories";
|
|
12
8
|
import type { ContainerLayoutProps, PropsConverters } from "./props";
|
|
13
9
|
|
|
14
10
|
export interface FrameTransformerDeps {
|
|
@@ -58,17 +54,17 @@ export function createFrameTransformer({
|
|
|
58
54
|
if (layoutComponent === "VStack") {
|
|
59
55
|
const { direction, ...rest } = props;
|
|
60
56
|
|
|
61
|
-
return
|
|
57
|
+
return createSeedReactElement("VStack", rest, processedChildren);
|
|
62
58
|
}
|
|
63
59
|
|
|
64
60
|
if (layoutComponent === "HStack") {
|
|
65
61
|
const { direction, ...rest } = props;
|
|
66
62
|
|
|
67
|
-
return
|
|
63
|
+
return createSeedReactElement("HStack", rest, processedChildren);
|
|
68
64
|
}
|
|
69
65
|
|
|
70
66
|
if (layoutComponent === "Box") {
|
|
71
|
-
return
|
|
67
|
+
return createSeedReactElement("Box", props, processedChildren);
|
|
72
68
|
}
|
|
73
69
|
},
|
|
74
70
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IconService } from "@/entities";
|
|
2
2
|
import { pascalCase } from "change-case";
|
|
3
3
|
import { type ElementNode, createElement } from "../../core";
|
|
4
|
+
import { createMonochromeIconElement, createMulticolorIconElement } from "./element-factories";
|
|
4
5
|
|
|
5
6
|
export interface IconHandler {
|
|
6
7
|
isIconInstance: (node: { componentKey: string }) => boolean;
|
|
@@ -36,11 +37,15 @@ export function createIconHandler({
|
|
|
36
37
|
return createElement("UnknownIcon");
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
const { name, weight } = iconData;
|
|
40
|
+
const { name, weight, type } = iconData;
|
|
40
41
|
|
|
41
42
|
const tagName = iconNameFormatter({ name, weight });
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
if (type === "multicolor") {
|
|
45
|
+
return createMulticolorIconElement(tagName);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return createMonochromeIconElement(tagName);
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
return {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { NormalizedInstanceNode } from "@/normalizer";
|
|
2
2
|
import {
|
|
3
|
-
createElement,
|
|
4
3
|
defineElementTransformer,
|
|
5
4
|
type ComponentHandler,
|
|
6
5
|
type ElementTransformer,
|
|
7
6
|
} from "../../core";
|
|
7
|
+
import { createSeedReactElement } from "./element-factories";
|
|
8
8
|
import type { IconHandler } from "./icon";
|
|
9
9
|
import type { PropsConverters } from "./props";
|
|
10
10
|
|
|
@@ -29,7 +29,7 @@ export function createInstanceTransformer({
|
|
|
29
29
|
...propsConverters.iconSelfLayout(node),
|
|
30
30
|
...propsConverters.vectorChildrenFill(node),
|
|
31
31
|
};
|
|
32
|
-
return
|
|
32
|
+
return createSeedReactElement("Icon", { svg: iconHandler.transform(node), ...props });
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
const componentHandler = componentSetKey
|
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
NormalizedVectorNode,
|
|
5
5
|
} from "@/normalizer";
|
|
6
6
|
import { createElement, defineElementTransformer, type ElementTransformer } from "../../core";
|
|
7
|
+
import { createSeedReactElement } from "./element-factories";
|
|
7
8
|
import type { PropsConverters } from "./props";
|
|
8
9
|
|
|
9
10
|
export interface RectangleTransformerDeps {
|
|
@@ -14,23 +15,29 @@ export function createRectangleTransformer({
|
|
|
14
15
|
propsConverters,
|
|
15
16
|
}: RectangleTransformerDeps): ElementTransformer<NormalizedRectangleNode> {
|
|
16
17
|
return defineElementTransformer((node: NormalizedRectangleNode) => {
|
|
17
|
-
return
|
|
18
|
+
return createSeedReactElement(
|
|
18
19
|
"Box",
|
|
19
20
|
{ ...propsConverters.selfLayout(node), background: "palette.gray200" },
|
|
20
21
|
undefined,
|
|
21
|
-
|
|
22
|
+
{
|
|
23
|
+
comment: "Rectangle Node Placeholder",
|
|
24
|
+
},
|
|
22
25
|
);
|
|
23
26
|
});
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
export function createVectorTransformer(): ElementTransformer<NormalizedVectorNode> {
|
|
27
30
|
return defineElementTransformer(() => {
|
|
28
|
-
return createElement("svg", {}, [],
|
|
31
|
+
return createElement("svg", {}, [], {
|
|
32
|
+
comment: "Vector Node Placeholder",
|
|
33
|
+
});
|
|
29
34
|
});
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
export function createBooleanOperationTransformer(): ElementTransformer<NormalizedBooleanOperationNode> {
|
|
33
38
|
return defineElementTransformer(() => {
|
|
34
|
-
return createElement("svg", {}, [],
|
|
39
|
+
return createElement("svg", {}, [], {
|
|
40
|
+
comment: "Boolean Operation Node Placeholder",
|
|
41
|
+
});
|
|
35
42
|
});
|
|
36
43
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { NormalizedTextNode } from "@/normalizer";
|
|
2
2
|
import { compactObject } from "@/utils/common";
|
|
3
|
-
import {
|
|
3
|
+
import { defineElementTransformer, type ElementTransformer } from "../../core";
|
|
4
|
+
import { createSeedReactElement } from "./element-factories";
|
|
4
5
|
import type { PropsConverters } from "./props";
|
|
5
6
|
|
|
6
7
|
export interface TextTransformerDeps {
|
|
@@ -21,13 +22,10 @@ export function createTextTransformer({
|
|
|
21
22
|
...fillProps,
|
|
22
23
|
});
|
|
23
24
|
|
|
24
|
-
return
|
|
25
|
-
|
|
26
|
-
props,
|
|
27
|
-
node.characters.replace(/\n/g, "<br />"),
|
|
28
|
-
hasMultipleFills
|
|
25
|
+
return createSeedReactElement("Text", props, node.characters.replace(/\n/g, "<br />"), {
|
|
26
|
+
comment: hasMultipleFills
|
|
29
27
|
? "Multiple fills in Text node encountered, only the first fill is used."
|
|
30
|
-
:
|
|
31
|
-
);
|
|
28
|
+
: undefined,
|
|
29
|
+
});
|
|
32
30
|
});
|
|
33
31
|
}
|