@seed-design/figma 0.0.21 → 0.0.23
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 +8012 -0
- package/lib/codegen/index.d.ts +1828 -0
- package/lib/codegen/index.js +7983 -0
- package/lib/codegen/targets/react/index.cjs +12198 -0
- package/lib/codegen/targets/react/index.d.ts +267 -0
- package/lib/codegen/targets/react/index.js +12180 -0
- package/lib/index.cjs +79 -2741
- package/lib/index.d.ts +17 -1937
- package/lib/index.js +61 -2715
- package/package.json +12 -2
- package/src/codegen/{targets/react/component/properties.type.ts → component-properties.ts} +43 -43
- package/src/codegen/core/codegen.ts +17 -6
- package/src/codegen/core/{component.ts → component-handler.ts} +3 -3
- package/src/codegen/core/component-type-helper.ts +35 -0
- package/src/codegen/core/index.ts +14 -14
- package/src/codegen/core/{props.ts → props-converter.ts} +10 -13
- package/src/codegen/core/{value.ts → value-resolver.ts} +87 -50
- package/src/codegen/default-services.ts +44 -0
- package/src/codegen/index.ts +1 -44
- package/src/codegen/targets/figma/frame.ts +8 -8
- package/src/codegen/targets/figma/index.ts +1 -1
- package/src/codegen/targets/figma/pipeline.ts +94 -0
- package/src/codegen/targets/figma/props.ts +59 -70
- package/src/codegen/targets/figma/shape.ts +18 -18
- package/src/codegen/targets/figma/text.ts +6 -6
- package/src/codegen/targets/figma/value-resolver.ts +19 -0
- package/src/codegen/targets/react/component/deps.interface.ts +5 -4
- package/src/codegen/targets/react/component/{transformers → handlers}/action-button.ts +8 -14
- package/src/codegen/targets/react/component/{transformers → handlers}/action-chip.ts +10 -20
- package/src/codegen/targets/react/component/{transformers → handlers}/action-sheet.ts +13 -10
- package/src/codegen/targets/react/component/{transformers → handlers}/app-bar.ts +28 -36
- package/src/codegen/targets/react/component/handlers/avatar-stack.ts +29 -0
- package/src/codegen/targets/react/component/{transformers → handlers}/avatar.ts +12 -9
- package/src/codegen/targets/react/component/handlers/badge.ts +18 -0
- package/src/codegen/targets/react/component/{transformers → handlers}/callout.ts +6 -8
- package/src/codegen/targets/react/component/{transformers → handlers}/checkbox.ts +5 -5
- package/src/codegen/targets/react/component/{transformers → handlers}/chip-tabs.ts +10 -10
- package/src/codegen/targets/react/component/{transformers → handlers}/control-chip.ts +10 -20
- package/src/codegen/targets/react/component/{transformers → handlers}/error-state.ts +9 -9
- package/src/codegen/targets/react/component/{transformers → handlers}/extended-action-sheet.ts +16 -18
- package/src/codegen/targets/react/component/{transformers → handlers}/extended-fab.ts +6 -6
- package/src/codegen/targets/react/component/handlers/fab.ts +18 -0
- package/src/codegen/targets/react/component/{transformers → handlers}/help-bubble.ts +5 -5
- package/src/codegen/targets/react/component/{transformers → handlers}/identity-placeholder.ts +5 -5
- package/src/codegen/targets/react/component/{transformers → handlers}/inline-banner.ts +7 -10
- package/src/codegen/targets/react/component/{transformers → handlers}/manner-temp-badge.ts +5 -5
- package/src/codegen/targets/react/component/{transformers → handlers}/multiline-text-field.ts +5 -5
- package/src/codegen/targets/react/component/{transformers → handlers}/progress-circle.ts +5 -5
- package/src/codegen/targets/react/component/{transformers → handlers}/reaction-button.ts +6 -6
- package/src/codegen/targets/react/component/{transformers → handlers}/segmented-control.ts +10 -10
- package/src/codegen/targets/react/component/{transformers → handlers}/select-box.ts +10 -10
- package/src/codegen/targets/react/component/handlers/skeleton.ts +25 -0
- package/src/codegen/targets/react/component/{transformers → handlers}/snackbar.ts +5 -5
- package/src/codegen/targets/react/component/{transformers → handlers}/switch.ts +5 -5
- package/src/codegen/targets/react/component/{transformers → handlers}/tabs.ts +15 -15
- package/src/codegen/targets/react/component/{transformers → handlers}/text-button.ts +7 -13
- package/src/codegen/targets/react/component/{transformers → handlers}/text-field.ts +9 -9
- package/src/codegen/targets/react/component/{transformers → handlers}/toggle-button.ts +7 -11
- package/src/codegen/targets/react/component/index.ts +79 -75
- package/src/codegen/targets/react/frame.ts +8 -8
- package/src/codegen/targets/react/icon.ts +50 -0
- package/src/codegen/targets/react/index.ts +1 -1
- package/src/codegen/targets/react/instance.ts +19 -50
- package/src/codegen/targets/react/pipeline.ts +124 -0
- package/src/codegen/targets/react/props.ts +95 -73
- package/src/codegen/targets/react/shape.ts +5 -5
- package/src/codegen/targets/react/text.ts +6 -6
- package/src/codegen/targets/react/value-resolver.ts +32 -0
- package/src/entities/icon.repository.ts +2 -2
- package/src/entities/icon.service.ts +9 -20
- package/src/entities/style.service.ts +5 -17
- package/src/entities/variable.service.ts +36 -68
- package/src/utils/figma-variable.ts +39 -3
- package/src/codegen/core/component.types.ts +0 -29
- package/src/codegen/targets/figma/context.ts +0 -139
- package/src/codegen/targets/react/component/transformers/avatar-stack.ts +0 -29
- package/src/codegen/targets/react/component/transformers/badge.ts +0 -21
- package/src/codegen/targets/react/component/transformers/fab.ts +0 -18
- package/src/codegen/targets/react/component/transformers/skeleton.ts +0 -51
- package/src/codegen/targets/react/context.ts +0 -176
- /package/src/codegen/core/{element.ts → element-transformer.ts} +0 -0
|
@@ -4,35 +4,35 @@ import type {
|
|
|
4
4
|
NormalizedVectorNode,
|
|
5
5
|
} from "@/normalizer";
|
|
6
6
|
import { createElement, defineElementTransformer, type ElementTransformer } from "../../core";
|
|
7
|
-
import type {
|
|
7
|
+
import type { PropsConverters } from "./props";
|
|
8
8
|
|
|
9
9
|
export interface RectangleTransformerDeps {
|
|
10
|
-
|
|
10
|
+
propsConverters: PropsConverters;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export function createRectangleTransformer({
|
|
14
|
-
|
|
14
|
+
propsConverters,
|
|
15
15
|
}: RectangleTransformerDeps): ElementTransformer<NormalizedRectangleNode> {
|
|
16
|
-
return defineElementTransformer((node: NormalizedRectangleNode
|
|
17
|
-
return createElement("Rectangle", { ...
|
|
16
|
+
return defineElementTransformer((node: NormalizedRectangleNode) => {
|
|
17
|
+
return createElement("Rectangle", { ...propsConverters.selfLayout(node) });
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export interface VectorTransformerDeps {
|
|
22
|
-
|
|
22
|
+
propsConverters: PropsConverters;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export function createVectorTransformer({
|
|
26
|
-
|
|
26
|
+
propsConverters,
|
|
27
27
|
}: VectorTransformerDeps): ElementTransformer<NormalizedVectorNode> {
|
|
28
|
-
return defineElementTransformer((node
|
|
28
|
+
return defineElementTransformer((node) => {
|
|
29
29
|
return createElement(
|
|
30
30
|
"Vector",
|
|
31
31
|
{
|
|
32
|
-
...
|
|
33
|
-
...
|
|
34
|
-
...
|
|
35
|
-
...
|
|
32
|
+
...propsConverters.selfLayout(node),
|
|
33
|
+
...propsConverters.radius(node),
|
|
34
|
+
...propsConverters.stroke(node),
|
|
35
|
+
...propsConverters.shapeFill(node),
|
|
36
36
|
},
|
|
37
37
|
[],
|
|
38
38
|
"Vector Node Placeholder",
|
|
@@ -41,20 +41,20 @@ export function createVectorTransformer({
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export interface BooleanOperationTransformerDeps {
|
|
44
|
-
|
|
44
|
+
propsConverters: PropsConverters;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export function createBooleanOperationTransformer({
|
|
48
|
-
|
|
48
|
+
propsConverters,
|
|
49
49
|
}: BooleanOperationTransformerDeps): ElementTransformer<NormalizedBooleanOperationNode> {
|
|
50
50
|
return defineElementTransformer((node, traverse) => {
|
|
51
51
|
return createElement(
|
|
52
52
|
"BooleanOperation",
|
|
53
53
|
{
|
|
54
|
-
...
|
|
55
|
-
...
|
|
56
|
-
...
|
|
57
|
-
...
|
|
54
|
+
...propsConverters.selfLayout(node),
|
|
55
|
+
...propsConverters.radius(node),
|
|
56
|
+
...propsConverters.stroke(node),
|
|
57
|
+
...propsConverters.shapeFill(node),
|
|
58
58
|
},
|
|
59
59
|
node.children.map(traverse),
|
|
60
60
|
);
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type { NormalizedTextNode } from "@/normalizer";
|
|
2
2
|
import { compactObject } from "@/utils/common";
|
|
3
3
|
import { createElement, defineElementTransformer, type ElementTransformer } from "../../core";
|
|
4
|
-
import type {
|
|
4
|
+
import type { PropsConverters } from "./props";
|
|
5
5
|
|
|
6
6
|
export interface TextTransformerDeps {
|
|
7
|
-
|
|
7
|
+
propsConverters: PropsConverters;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export function createTextTransformer({
|
|
11
|
-
|
|
11
|
+
propsConverters,
|
|
12
12
|
}: TextTransformerDeps): ElementTransformer<NormalizedTextNode> {
|
|
13
|
-
return defineElementTransformer((node: NormalizedTextNode
|
|
13
|
+
return defineElementTransformer((node: NormalizedTextNode) => {
|
|
14
14
|
const hasMultipleFills = node.fills.length > 1;
|
|
15
15
|
|
|
16
|
-
const fillProps =
|
|
17
|
-
const typeStyleProps =
|
|
16
|
+
const fillProps = propsConverters.textFill(node);
|
|
17
|
+
const typeStyleProps = propsConverters.typeStyle(node);
|
|
18
18
|
|
|
19
19
|
const props = compactObject({
|
|
20
20
|
...typeStyleProps,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ValueResolver } from "@/codegen/core";
|
|
2
|
+
import { toCssRgba } from "@/utils/css";
|
|
3
|
+
|
|
4
|
+
export type FigmaValueResolver = ValueResolver<string, number, number, number>;
|
|
5
|
+
|
|
6
|
+
export const defaultVariableNameFormatter = ({ slug }: { slug: string[] }) =>
|
|
7
|
+
slug
|
|
8
|
+
.filter((s) => s !== "dimension")
|
|
9
|
+
.map((s) => s.replaceAll(",", "_"))
|
|
10
|
+
.join("/");
|
|
11
|
+
|
|
12
|
+
export const defaultStyleNameFormatter = ({ slug }: { slug: string[] }) => slug[slug.length - 1]!;
|
|
13
|
+
|
|
14
|
+
export const defaultRawValueFormatters = {
|
|
15
|
+
color: (value: RGBA) => toCssRgba(value),
|
|
16
|
+
dimension: (value: number) => value,
|
|
17
|
+
fontDimension: (value: number) => value,
|
|
18
|
+
fontWeight: (value: number) => value,
|
|
19
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IconHandler } from "../icon";
|
|
2
|
+
import type { ReactValueResolver } from "../value-resolver";
|
|
2
3
|
|
|
3
|
-
export interface
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export interface ComponentHandlerDeps {
|
|
5
|
+
iconHandler: IconHandler;
|
|
6
|
+
valueResolver: ReactValueResolver;
|
|
6
7
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, 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
|
-
import type {
|
|
6
|
-
import type { ActionButtonProperties } from "
|
|
5
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
6
|
+
import type { ActionButtonProperties } from "@/codegen/component-properties";
|
|
7
7
|
import { handleSizeProp } from "../size";
|
|
8
8
|
|
|
9
|
-
export const
|
|
10
|
-
|
|
9
|
+
export const createActionButtonHandler = (ctx: ComponentHandlerDeps) =>
|
|
10
|
+
defineComponentHandler<ActionButtonProperties>(
|
|
11
11
|
metadata.actionButton.key,
|
|
12
12
|
({ componentProperties: props }) => {
|
|
13
13
|
const states = props.State.value.split("-");
|
|
@@ -17,9 +17,7 @@ export const createActionButtonTransformer = (ctx: SeedComponentTransformerDeps)
|
|
|
17
17
|
layout: "iconOnly",
|
|
18
18
|
children: [
|
|
19
19
|
createElement("Icon", {
|
|
20
|
-
svg:
|
|
21
|
-
ctx.iconService.createIconTagName(props["Icon#7574:0"].componentKey),
|
|
22
|
-
),
|
|
20
|
+
svg: ctx.iconHandler.transform(props["Icon#7574:0"]),
|
|
23
21
|
}),
|
|
24
22
|
],
|
|
25
23
|
}))
|
|
@@ -27,9 +25,7 @@ export const createActionButtonTransformer = (ctx: SeedComponentTransformerDeps)
|
|
|
27
25
|
layout: "withText",
|
|
28
26
|
children: [
|
|
29
27
|
createElement("PrefixIcon", {
|
|
30
|
-
svg:
|
|
31
|
-
ctx.iconService.createIconTagName(props["Prefix Icon#5987:305"].componentKey),
|
|
32
|
-
),
|
|
28
|
+
svg: ctx.iconHandler.transform(props["Prefix Icon#5987:305"]),
|
|
33
29
|
}),
|
|
34
30
|
props["Label#5987:61"].value,
|
|
35
31
|
],
|
|
@@ -39,9 +35,7 @@ export const createActionButtonTransformer = (ctx: SeedComponentTransformerDeps)
|
|
|
39
35
|
children: [
|
|
40
36
|
props["Label#5987:61"].value,
|
|
41
37
|
createElement("SuffixIcon", {
|
|
42
|
-
svg:
|
|
43
|
-
ctx.iconService.createIconTagName(props["Suffix Icon#5987:244"].componentKey),
|
|
44
|
-
),
|
|
38
|
+
svg: ctx.iconHandler.transform(props["Suffix Icon#5987:244"]),
|
|
45
39
|
}),
|
|
46
40
|
],
|
|
47
41
|
}))
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import { match } from "ts-pattern";
|
|
4
|
-
import type {
|
|
5
|
-
import type { ActionChipProperties } from "
|
|
4
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
|
+
import type { ActionChipProperties } from "@/codegen/component-properties";
|
|
6
6
|
import { handleSizeProp } from "../size";
|
|
7
7
|
|
|
8
|
-
export const
|
|
9
|
-
|
|
8
|
+
export const createActionChipHandler = (ctx: ComponentHandlerDeps) =>
|
|
9
|
+
defineComponentHandler<ActionChipProperties>(
|
|
10
10
|
metadata.actionChip.key,
|
|
11
11
|
({ componentProperties: props }) => {
|
|
12
12
|
const states = props.State.value.split("-");
|
|
@@ -16,9 +16,7 @@ export const createActionChipTransformer = (ctx: SeedComponentTransformerDeps) =
|
|
|
16
16
|
layout: "iconOnly",
|
|
17
17
|
children: [
|
|
18
18
|
createElement("Icon", {
|
|
19
|
-
svg:
|
|
20
|
-
ctx.iconService.createIconTagName(props["Icon#8714:0"].componentKey),
|
|
21
|
-
),
|
|
19
|
+
svg: ctx.iconHandler.transform(props["Icon#8714:0"]),
|
|
22
20
|
}),
|
|
23
21
|
],
|
|
24
22
|
}))
|
|
@@ -26,9 +24,7 @@ export const createActionChipTransformer = (ctx: SeedComponentTransformerDeps) =
|
|
|
26
24
|
layout: "withText",
|
|
27
25
|
children: [
|
|
28
26
|
createElement("PrefixIcon", {
|
|
29
|
-
svg:
|
|
30
|
-
ctx.iconService.createIconTagName(props["Prefix Icon#8711:0"].componentKey),
|
|
31
|
-
),
|
|
27
|
+
svg: ctx.iconHandler.transform(props["Prefix Icon#8711:0"]),
|
|
32
28
|
}),
|
|
33
29
|
props["Label#7185:0"].value,
|
|
34
30
|
],
|
|
@@ -38,9 +34,7 @@ export const createActionChipTransformer = (ctx: SeedComponentTransformerDeps) =
|
|
|
38
34
|
children: [
|
|
39
35
|
props["Label#7185:0"].value,
|
|
40
36
|
createElement("SuffixIcon", {
|
|
41
|
-
svg:
|
|
42
|
-
ctx.iconService.createIconTagName(props["Suffix Icon#8711:3"].componentKey),
|
|
43
|
-
),
|
|
37
|
+
svg: ctx.iconHandler.transform(props["Suffix Icon#8711:3"]),
|
|
44
38
|
}),
|
|
45
39
|
],
|
|
46
40
|
}))
|
|
@@ -48,15 +42,11 @@ export const createActionChipTransformer = (ctx: SeedComponentTransformerDeps) =
|
|
|
48
42
|
layout: "withText",
|
|
49
43
|
children: [
|
|
50
44
|
createElement("PrefixIcon", {
|
|
51
|
-
svg:
|
|
52
|
-
ctx.iconService.createIconTagName(props["Prefix Icon#8711:0"].componentKey),
|
|
53
|
-
),
|
|
45
|
+
svg: ctx.iconHandler.transform(props["Prefix Icon#8711:0"]),
|
|
54
46
|
}),
|
|
55
47
|
props["Label#7185:0"].value,
|
|
56
48
|
createElement("SuffixIcon", {
|
|
57
|
-
svg:
|
|
58
|
-
ctx.iconService.createIconTagName(props["Suffix Icon#8711:3"].componentKey),
|
|
59
|
-
),
|
|
49
|
+
svg: ctx.iconHandler.transform(props["Suffix Icon#8711:3"]),
|
|
60
50
|
}),
|
|
61
51
|
],
|
|
62
52
|
}))
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import { findAllInstances } from "@/utils/figma-node";
|
|
4
4
|
import { camelCase } from "change-case";
|
|
5
5
|
import { match } from "ts-pattern";
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
6
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
7
|
+
import type {
|
|
8
|
+
ActionSheetItemProperties,
|
|
9
|
+
ActionSheetProperties,
|
|
10
|
+
} from "@/codegen/component-properties";
|
|
8
11
|
|
|
9
12
|
const ACTION_SHEET_ITEM_KEY = "c3cafd3a3fdcd45fecb6971019d88eaf39a2e381";
|
|
10
|
-
const
|
|
11
|
-
|
|
13
|
+
const createActionSheetItemHandler = (_ctx: ComponentHandlerDeps) =>
|
|
14
|
+
defineComponentHandler<ActionSheetItemProperties>(
|
|
12
15
|
ACTION_SHEET_ITEM_KEY,
|
|
13
16
|
({ componentProperties: props }) => {
|
|
14
17
|
const states = props.State.value.split("-");
|
|
@@ -25,10 +28,10 @@ const createActionSheetItemTransformer = (_ctx: SeedComponentTransformerDeps) =>
|
|
|
25
28
|
},
|
|
26
29
|
);
|
|
27
30
|
|
|
28
|
-
export const
|
|
29
|
-
const
|
|
31
|
+
export const createActionSheetHandler = (ctx: ComponentHandlerDeps) => {
|
|
32
|
+
const actionSheetItemHandler = createActionSheetItemHandler(ctx);
|
|
30
33
|
|
|
31
|
-
return
|
|
34
|
+
return defineComponentHandler<ActionSheetProperties>(metadata.actionSheet.key, (node) => {
|
|
32
35
|
const { componentProperties: props } = node;
|
|
33
36
|
|
|
34
37
|
const contentProps = match(props.Header.value)
|
|
@@ -52,10 +55,10 @@ export const createActionSheetTransformer = (ctx: SeedComponentTransformerDeps)
|
|
|
52
55
|
|
|
53
56
|
const items = findAllInstances<ActionSheetItemProperties>({
|
|
54
57
|
node,
|
|
55
|
-
key:
|
|
58
|
+
key: actionSheetItemHandler.key,
|
|
56
59
|
});
|
|
57
60
|
|
|
58
|
-
const contentChildren = items.map(
|
|
61
|
+
const contentChildren = items.map(actionSheetItemHandler.transform);
|
|
59
62
|
|
|
60
63
|
const content = createElement(
|
|
61
64
|
"ActionSheetContent",
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import type { NormalizedInstanceNode, NormalizedTextNode } from "@/normalizer";
|
|
4
4
|
import { findAll, findAllInstances, findOne } from "@/utils/figma-node";
|
|
5
5
|
import { match } from "ts-pattern";
|
|
6
|
-
import type {
|
|
6
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
7
7
|
import type {
|
|
8
8
|
AppBarLeftProperties,
|
|
9
9
|
AppBarMainProperties,
|
|
10
10
|
AppBarProperties,
|
|
11
11
|
AppBarRightProperties,
|
|
12
|
-
} from "
|
|
12
|
+
} from "@/codegen/component-properties";
|
|
13
13
|
|
|
14
14
|
const APP_BAR_MAIN_KEY = "336b49b26c3933485d87cc460b06c390976ea58e";
|
|
15
|
-
const
|
|
16
|
-
|
|
15
|
+
const createAppBarMainHandler = (_ctx: ComponentHandlerDeps) =>
|
|
16
|
+
defineComponentHandler<AppBarMainProperties>(
|
|
17
17
|
APP_BAR_MAIN_KEY,
|
|
18
18
|
({ componentProperties: props }) => {
|
|
19
19
|
const { title, subtitle, layout } = match(props.Type.value)
|
|
@@ -49,8 +49,8 @@ const createAppBarMainTransformer = (_ctx: SeedComponentTransformerDeps) =>
|
|
|
49
49
|
);
|
|
50
50
|
|
|
51
51
|
const APP_BAR_LEFT_KEY = "e5d2e47052a22395db79f195a0991a570dc1b6c9";
|
|
52
|
-
const
|
|
53
|
-
|
|
52
|
+
const createAppBarLeftHandler = (ctx: ComponentHandlerDeps) =>
|
|
53
|
+
defineComponentHandler<AppBarLeftProperties>(APP_BAR_LEFT_KEY, (node) => {
|
|
54
54
|
const props = node.componentProperties;
|
|
55
55
|
|
|
56
56
|
const children = (() => {
|
|
@@ -65,17 +65,15 @@ const createAppBarLeftTransformer = (ctx: SeedComponentTransformerDeps) =>
|
|
|
65
65
|
(child) => child.type === "INSTANCE" && child.name === "Icon",
|
|
66
66
|
) as NormalizedInstanceNode | null;
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
if (!iconNode) {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
69
71
|
|
|
70
72
|
return createElement(
|
|
71
73
|
"AppBarIconButton",
|
|
72
74
|
undefined,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
: undefined,
|
|
76
|
-
iconComponentKey === undefined
|
|
77
|
-
? "아이콘과, aria-label 또는 aria-labelledby를 제공해주세요."
|
|
78
|
-
: "aria-label 또는 aria-labelledby를 제공해주세요.",
|
|
75
|
+
ctx.iconHandler.transform(iconNode),
|
|
76
|
+
"aria-label 또는 aria-labelledby를 제공해주세요.",
|
|
79
77
|
);
|
|
80
78
|
}
|
|
81
79
|
}
|
|
@@ -85,8 +83,8 @@ const createAppBarLeftTransformer = (ctx: SeedComponentTransformerDeps) =>
|
|
|
85
83
|
});
|
|
86
84
|
|
|
87
85
|
const APP_BAR_RIGHT_KEY = "9e157fc2d1f89ffee938a5bc62f4a58064fec44e";
|
|
88
|
-
const
|
|
89
|
-
|
|
86
|
+
const createAppBarRightHandler = (ctx: ComponentHandlerDeps) =>
|
|
87
|
+
defineComponentHandler<AppBarRightProperties>(APP_BAR_RIGHT_KEY, (node) => {
|
|
90
88
|
const props = node.componentProperties;
|
|
91
89
|
|
|
92
90
|
const children = (() => {
|
|
@@ -105,18 +103,12 @@ const createAppBarRightTransformer = (ctx: SeedComponentTransformerDeps) =>
|
|
|
105
103
|
(child) => child.type === "INSTANCE" && child.name === "Icon",
|
|
106
104
|
) as NormalizedInstanceNode[];
|
|
107
105
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return iconComponentKeys.map((iconComponentKey) =>
|
|
106
|
+
return iconNodes.map((iconNode) =>
|
|
111
107
|
createElement(
|
|
112
108
|
"AppBarIconButton",
|
|
113
109
|
undefined,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
: undefined,
|
|
117
|
-
iconComponentKey === undefined
|
|
118
|
-
? "아이콘과, aria-label 또는 aria-labelledby를 제공해주세요."
|
|
119
|
-
: "aria-label 또는 aria-labelledby를 제공해주세요.",
|
|
110
|
+
ctx.iconHandler.transform(iconNode),
|
|
111
|
+
"aria-label 또는 aria-labelledby를 제공해주세요.",
|
|
120
112
|
),
|
|
121
113
|
);
|
|
122
114
|
}
|
|
@@ -126,12 +118,12 @@ const createAppBarRightTransformer = (ctx: SeedComponentTransformerDeps) =>
|
|
|
126
118
|
return createElement("AppBarRight", undefined, children);
|
|
127
119
|
});
|
|
128
120
|
|
|
129
|
-
export const
|
|
130
|
-
const
|
|
131
|
-
const
|
|
132
|
-
const
|
|
121
|
+
export const createAppBarHandler = (ctx: ComponentHandlerDeps) => {
|
|
122
|
+
const appBarMainHandler = createAppBarMainHandler(ctx);
|
|
123
|
+
const appBarLeftHandler = createAppBarLeftHandler(ctx);
|
|
124
|
+
const appBarRightHandler = createAppBarRightHandler(ctx);
|
|
133
125
|
|
|
134
|
-
return
|
|
126
|
+
return defineComponentHandler<AppBarProperties>(metadata.standardNavigation.key, (node) => {
|
|
135
127
|
const props = node.componentProperties;
|
|
136
128
|
|
|
137
129
|
const theme = (() => {
|
|
@@ -153,25 +145,25 @@ export const createAppBarTransformer = (ctx: SeedComponentTransformerDeps) => {
|
|
|
153
145
|
})();
|
|
154
146
|
|
|
155
147
|
const mainNode = findAllInstances<AppBarMainProperties>({
|
|
156
|
-
key:
|
|
148
|
+
key: appBarMainHandler.key,
|
|
157
149
|
node,
|
|
158
150
|
});
|
|
159
151
|
const onlyMainNode = mainNode.length === 1 ? mainNode[0] : undefined;
|
|
160
|
-
const main = onlyMainNode ?
|
|
152
|
+
const main = onlyMainNode ? appBarMainHandler.transform(onlyMainNode) : undefined;
|
|
161
153
|
|
|
162
154
|
const leftNode = findAllInstances<AppBarLeftProperties>({
|
|
163
|
-
key:
|
|
155
|
+
key: appBarLeftHandler.key,
|
|
164
156
|
node,
|
|
165
157
|
});
|
|
166
158
|
const onlyLeftNode = leftNode.length === 1 ? leftNode[0] : undefined;
|
|
167
|
-
const left = onlyLeftNode ?
|
|
159
|
+
const left = onlyLeftNode ? appBarLeftHandler.transform(onlyLeftNode) : undefined;
|
|
168
160
|
|
|
169
161
|
const rightNode = findAllInstances<AppBarRightProperties>({
|
|
170
|
-
key:
|
|
162
|
+
key: appBarRightHandler.key,
|
|
171
163
|
node,
|
|
172
164
|
});
|
|
173
165
|
const onlyRightNode = rightNode.length === 1 ? rightNode[0] : undefined;
|
|
174
|
-
const right = onlyRightNode ?
|
|
166
|
+
const right = onlyRightNode ? appBarRightHandler.transform(onlyRightNode) : undefined;
|
|
175
167
|
|
|
176
168
|
return createElement(
|
|
177
169
|
"AppBar",
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
import type { AvatarProperties, AvatarStackProperties } from "@/codegen/component-properties";
|
|
6
|
+
import { createAvatarHandler } from "./avatar";
|
|
7
|
+
|
|
8
|
+
export const createAvatarStackHandler = (ctx: ComponentHandlerDeps) => {
|
|
9
|
+
const avatarHandler = createAvatarHandler(ctx);
|
|
10
|
+
|
|
11
|
+
return defineComponentHandler<AvatarStackProperties>(metadata.avatarStack.key, (node) => {
|
|
12
|
+
const avatarNodes = findAllInstances<AvatarProperties>({
|
|
13
|
+
node,
|
|
14
|
+
key: avatarHandler.key,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const { componentProperties: props } = node;
|
|
18
|
+
|
|
19
|
+
const commonProps = {
|
|
20
|
+
size: props.Size.value,
|
|
21
|
+
// TODO: 구현될 예정
|
|
22
|
+
// topItem: camelCase(props["Top Item"].value),
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const avatarStackChildren = avatarNodes.map(avatarHandler.transform);
|
|
26
|
+
|
|
27
|
+
return createElement("AvatarStack", commonProps, avatarStackChildren);
|
|
28
|
+
});
|
|
29
|
+
};
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import { findAllInstances } from "@/utils/figma-node";
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
|
|
4
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
|
+
import type {
|
|
6
|
+
AvatarProperties,
|
|
7
|
+
IdentityPlaceholderProperties,
|
|
8
|
+
} from "@/codegen/component-properties";
|
|
9
|
+
import { createIdentityPlaceholderHandler } from "./identity-placeholder";
|
|
7
10
|
|
|
8
|
-
export const
|
|
9
|
-
const
|
|
11
|
+
export const createAvatarHandler = (ctx: ComponentHandlerDeps) => {
|
|
12
|
+
const identityPlaceholderHandler = createIdentityPlaceholderHandler(ctx);
|
|
10
13
|
|
|
11
|
-
return
|
|
14
|
+
return defineComponentHandler<AvatarProperties>(metadata.avatar.key, (node) => {
|
|
12
15
|
const [placeholder] = findAllInstances<IdentityPlaceholderProperties>({
|
|
13
16
|
node,
|
|
14
|
-
key:
|
|
17
|
+
key: identityPlaceholderHandler.key,
|
|
15
18
|
});
|
|
16
19
|
const { componentProperties: props } = node;
|
|
17
20
|
|
|
@@ -23,7 +26,7 @@ export const createAvatarTransformer = (ctx: SeedComponentTransformerDeps) => {
|
|
|
23
26
|
src: `https://placehold.co/${props.Size.value}x${props.Size.value}`,
|
|
24
27
|
}),
|
|
25
28
|
...(placeholder && {
|
|
26
|
-
fallback:
|
|
29
|
+
fallback: identityPlaceholderHandler.transform(placeholder),
|
|
27
30
|
}),
|
|
28
31
|
size: props.Size.value,
|
|
29
32
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
|
+
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
|
+
import { camelCase } from "change-case";
|
|
4
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
|
+
import type { BadgeProperties } from "@/codegen/component-properties";
|
|
6
|
+
import { handleSizeProp } from "../size";
|
|
7
|
+
|
|
8
|
+
export const createBadgeHandler = (_ctx: ComponentHandlerDeps) =>
|
|
9
|
+
defineComponentHandler<BadgeProperties>(metadata.badge.key, ({ componentProperties: props }) => {
|
|
10
|
+
const commonProps = {
|
|
11
|
+
size: handleSizeProp(props.Size.value),
|
|
12
|
+
tone: camelCase(props.Tone.value),
|
|
13
|
+
variant: camelCase(props.Variant.value),
|
|
14
|
+
shape: camelCase(props.Shape.value),
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return createElement("Badge", commonProps, props["Label#1584:0"].value);
|
|
18
|
+
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import type { NormalizedTextNode } from "@/normalizer";
|
|
4
4
|
import { camelCase } from "change-case";
|
|
5
|
-
import type {
|
|
6
|
-
import type { CalloutProperties } from "
|
|
5
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
6
|
+
import type { CalloutProperties } from "@/codegen/component-properties";
|
|
7
7
|
|
|
8
|
-
export const
|
|
9
|
-
|
|
8
|
+
export const createCalloutHandler = (ctx: ComponentHandlerDeps) =>
|
|
9
|
+
defineComponentHandler<CalloutProperties>(
|
|
10
10
|
metadata.callout.key,
|
|
11
11
|
({ componentProperties: props, children }) => {
|
|
12
12
|
const tag = (() => {
|
|
@@ -78,9 +78,7 @@ export const createCalloutTransformer = (ctx: SeedComponentTransformerDeps) =>
|
|
|
78
78
|
children: linkLabel,
|
|
79
79
|
},
|
|
80
80
|
...(props["Icon#12598:210"].value && {
|
|
81
|
-
prefixIcon:
|
|
82
|
-
ctx.iconService.createIconTagName(props["Icon#12598:210"].componentKey),
|
|
83
|
-
),
|
|
81
|
+
prefixIcon: ctx.iconHandler.transform(props["Icon#12598:210"]),
|
|
84
82
|
}),
|
|
85
83
|
};
|
|
86
84
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import { camelCase } from "change-case";
|
|
4
|
-
import type {
|
|
5
|
-
import type { CheckboxProperties } from "
|
|
4
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
5
|
+
import type { CheckboxProperties } from "@/codegen/component-properties";
|
|
6
6
|
import { handleSizeProp } from "../size";
|
|
7
7
|
|
|
8
|
-
export const
|
|
9
|
-
|
|
8
|
+
export const createCheckboxHandler = (_ctx: ComponentHandlerDeps) =>
|
|
9
|
+
defineComponentHandler<CheckboxProperties>(
|
|
10
10
|
metadata.checkbox.key,
|
|
11
11
|
({ componentProperties: props }) => {
|
|
12
12
|
const states = props.State.value.split("-");
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { createElement,
|
|
1
|
+
import { createElement, defineComponentHandler } from "@/codegen/core";
|
|
2
2
|
import * as metadata from "@/entities/data/__generated__/component-sets";
|
|
3
3
|
import { findAllInstances } from "@/utils/figma-node";
|
|
4
4
|
import { camelCase } from "change-case";
|
|
5
|
-
import type {
|
|
6
|
-
import type { ChipTabsItemProperties, ChipTabsProperties } from "
|
|
5
|
+
import type { ComponentHandlerDeps } from "../deps.interface";
|
|
6
|
+
import type { ChipTabsItemProperties, ChipTabsProperties } from "@/codegen/component-properties";
|
|
7
7
|
|
|
8
8
|
const CHIP_TABS_ITEM_KEY = "fa80168b02051fbb0ba032238bd76d840dbe2e15";
|
|
9
|
-
const
|
|
10
|
-
|
|
9
|
+
const createChipTabsItemHandler = (_ctx: ComponentHandlerDeps) =>
|
|
10
|
+
defineComponentHandler<ChipTabsItemProperties>(
|
|
11
11
|
CHIP_TABS_ITEM_KEY,
|
|
12
12
|
({ componentProperties: props }) => {
|
|
13
13
|
const states = props.State.value.split("-");
|
|
@@ -23,13 +23,13 @@ const createChipTabsItemTransformer = (_ctx: SeedComponentTransformerDeps) =>
|
|
|
23
23
|
},
|
|
24
24
|
);
|
|
25
25
|
|
|
26
|
-
export const
|
|
27
|
-
const
|
|
26
|
+
export const createChipTabsHandler = (ctx: ComponentHandlerDeps) => {
|
|
27
|
+
const chipTabsItemHandler = createChipTabsItemHandler(ctx);
|
|
28
28
|
|
|
29
|
-
return
|
|
29
|
+
return defineComponentHandler<ChipTabsProperties>(metadata.chipTablist.key, (node) => {
|
|
30
30
|
const chipTabsItems = findAllInstances<ChipTabsItemProperties>({
|
|
31
31
|
node,
|
|
32
|
-
key:
|
|
32
|
+
key: chipTabsItemHandler.key,
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
const selectedChipTabsItem = chipTabsItems.find((chipTabsItem) =>
|
|
@@ -39,7 +39,7 @@ export const createChipTabsTransformer = (ctx: SeedComponentTransformerDeps) =>
|
|
|
39
39
|
const chipTabsList = createElement(
|
|
40
40
|
"ChipTabsList",
|
|
41
41
|
undefined,
|
|
42
|
-
chipTabsItems.map(
|
|
42
|
+
chipTabsItems.map(chipTabsItemHandler.transform),
|
|
43
43
|
);
|
|
44
44
|
|
|
45
45
|
const commonProps = {
|