@seed-design/figma 0.0.20 → 0.0.22
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 +8019 -0
- package/lib/codegen/index.d.ts +1827 -0
- package/lib/codegen/index.js +7989 -0
- package/lib/codegen/targets/react/index.cjs +12205 -0
- package/lib/codegen/targets/react/index.d.ts +270 -0
- package/lib/codegen/targets/react/index.js +12187 -0
- package/lib/index.cjs +86 -2741
- package/lib/index.d.ts +18 -1933
- package/lib/index.js +68 -2715
- package/package.json +18 -9
- package/src/codegen/{targets/react/component/properties.type.ts → component-properties.ts} +43 -43
- package/src/codegen/core/codegen.ts +24 -9
- 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/context.ts +20 -0
- package/src/codegen/core/index.ts +16 -14
- package/src/codegen/core/infer-layout.test.ts +17 -16
- package/src/codegen/core/infer-layout.ts +1 -1
- package/src/codegen/core/{props.ts → props-converter.ts} +10 -13
- package/src/codegen/core/{value.ts → value-resolver.ts} +90 -52
- 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 +71 -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 +22 -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 +108 -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 +35 -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/normalizer/from-plugin.ts +3 -0
- package/src/normalizer/from-rest.ts +6 -0
- package/src/normalizer/types.ts +4 -1
- 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
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createPropsTransformer,
|
|
3
|
-
definePropsTransformer,
|
|
4
|
-
type PropsTransformer,
|
|
5
|
-
type ValueTransformer,
|
|
6
|
-
} from "@/codegen/core";
|
|
7
|
-
import type { StyleService } from "@/entities";
|
|
1
|
+
import { createPropsConverter, definePropsConverter, type PropsConverter } from "@/codegen/core";
|
|
8
2
|
import type {
|
|
9
3
|
NormalizedCornerTrait,
|
|
10
4
|
NormalizedHasChildrenTrait,
|
|
@@ -14,16 +8,17 @@ import type {
|
|
|
14
8
|
NormalizedIsLayerTrait,
|
|
15
9
|
NormalizedTypePropertiesTrait,
|
|
16
10
|
} from "@/normalizer";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
11
|
+
import type { FigmaValueResolver } from "./value-resolver";
|
|
12
|
+
|
|
13
|
+
export interface PropsConverters {
|
|
14
|
+
containerLayout: PropsConverter<ContainerLayoutTrait, ContainerLayoutProps>;
|
|
15
|
+
selfLayout: PropsConverter<SelfLayoutTrait, SelfLayoutProps>;
|
|
16
|
+
radius: PropsConverter<RadiusTrait, RadiusProps>;
|
|
17
|
+
frameFill: PropsConverter<FillTrait, FillProps>;
|
|
18
|
+
shapeFill: PropsConverter<FillTrait, FillProps>;
|
|
19
|
+
textFill: PropsConverter<FillTrait, FillProps>;
|
|
20
|
+
stroke: PropsConverter<StrokeTrait, StrokeProps>;
|
|
21
|
+
typeStyle: PropsConverter<TypeStyleTrait, TypeStyleProps>;
|
|
27
22
|
}
|
|
28
23
|
|
|
29
24
|
export type ContainerLayoutTrait = NormalizedHasFramePropertiesTrait &
|
|
@@ -55,12 +50,10 @@ export interface ContainerLayoutProps {
|
|
|
55
50
|
verticalPadding?: number | string; // string when variable
|
|
56
51
|
}
|
|
57
52
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
): PropsTransformer<ContainerLayoutTrait, ContainerLayoutProps> {
|
|
63
|
-
return createPropsTransformer({
|
|
53
|
+
export function createContainerLayoutPropsConverter(
|
|
54
|
+
valueResolver: FigmaValueResolver,
|
|
55
|
+
): PropsConverter<ContainerLayoutTrait, ContainerLayoutProps> {
|
|
56
|
+
return createPropsConverter({
|
|
64
57
|
_types: {
|
|
65
58
|
trait: {} as ContainerLayoutTrait,
|
|
66
59
|
props: {} as ContainerLayoutProps,
|
|
@@ -70,11 +63,11 @@ export function createContainerLayoutPropsTransformer(
|
|
|
70
63
|
primaryAxisAlignItems: ({ primaryAxisAlignItems }) => primaryAxisAlignItems,
|
|
71
64
|
counterAxisAlignItems: ({ counterAxisAlignItems }) => counterAxisAlignItems,
|
|
72
65
|
layoutWrap: ({ layoutWrap }) => layoutWrap,
|
|
73
|
-
itemSpacing: (
|
|
74
|
-
paddingTop: (node) =>
|
|
75
|
-
paddingBottom: (node) =>
|
|
76
|
-
paddingLeft: (node) =>
|
|
77
|
-
paddingRight: (node) =>
|
|
66
|
+
itemSpacing: (node) => valueResolver.getFormattedValue.itemSpacing(node),
|
|
67
|
+
paddingTop: (node) => valueResolver.getFormattedValue.paddingTop(node),
|
|
68
|
+
paddingBottom: (node) => valueResolver.getFormattedValue.paddingBottom(node),
|
|
69
|
+
paddingLeft: (node) => valueResolver.getFormattedValue.paddingLeft(node),
|
|
70
|
+
paddingRight: (node) => valueResolver.getFormattedValue.paddingRight(node),
|
|
78
71
|
},
|
|
79
72
|
shorthands: {
|
|
80
73
|
horizontalPadding: ["paddingLeft", "paddingRight"],
|
|
@@ -97,10 +90,10 @@ export interface SelfLayoutProps {
|
|
|
97
90
|
maxHeight?: string | number; // string when variable
|
|
98
91
|
}
|
|
99
92
|
|
|
100
|
-
export function
|
|
101
|
-
|
|
102
|
-
):
|
|
103
|
-
return
|
|
93
|
+
export function createSelfLayoutPropsConverter(
|
|
94
|
+
valueResolver: FigmaValueResolver,
|
|
95
|
+
): PropsConverter<SelfLayoutTrait, SelfLayoutProps> {
|
|
96
|
+
return createPropsConverter({
|
|
104
97
|
_types: {
|
|
105
98
|
trait: {} as SelfLayoutTrait,
|
|
106
99
|
props: {} as SelfLayoutProps,
|
|
@@ -110,12 +103,12 @@ export function createSelfLayoutPropsTransformer(
|
|
|
110
103
|
layoutAlign: ({ layoutAlign }) => layoutAlign,
|
|
111
104
|
layoutSizingVertical: ({ layoutSizingVertical }) => layoutSizingVertical,
|
|
112
105
|
layoutSizingHorizontal: ({ layoutSizingHorizontal }) => layoutSizingHorizontal,
|
|
113
|
-
width: (node) =>
|
|
114
|
-
height: (node) =>
|
|
115
|
-
minWidth: (node) =>
|
|
116
|
-
minHeight: (node) =>
|
|
117
|
-
maxWidth: (node) =>
|
|
118
|
-
maxHeight: (node) =>
|
|
106
|
+
width: (node) => valueResolver.getFormattedValue.width(node),
|
|
107
|
+
height: (node) => valueResolver.getFormattedValue.height(node),
|
|
108
|
+
minWidth: (node) => valueResolver.getFormattedValue.minWidth(node),
|
|
109
|
+
minHeight: (node) => valueResolver.getFormattedValue.minHeight(node),
|
|
110
|
+
maxWidth: (node) => valueResolver.getFormattedValue.maxWidth(node),
|
|
111
|
+
maxHeight: (node) => valueResolver.getFormattedValue.maxHeight(node),
|
|
119
112
|
},
|
|
120
113
|
defaults: {},
|
|
121
114
|
});
|
|
@@ -129,17 +122,17 @@ export interface RadiusProps {
|
|
|
129
122
|
bottomRightRadius?: number | string; // string when variable
|
|
130
123
|
}
|
|
131
124
|
|
|
132
|
-
export function
|
|
133
|
-
return
|
|
125
|
+
export function createRadiusPropsConverter(valueResolver: FigmaValueResolver) {
|
|
126
|
+
return createPropsConverter({
|
|
134
127
|
_types: {
|
|
135
128
|
trait: {} as RadiusTrait,
|
|
136
129
|
props: {} as RadiusProps,
|
|
137
130
|
},
|
|
138
131
|
handlers: {
|
|
139
|
-
topLeftRadius: (node) =>
|
|
140
|
-
topRightRadius: (node) =>
|
|
141
|
-
bottomLeftRadius: (node) =>
|
|
142
|
-
bottomRightRadius: (node) =>
|
|
132
|
+
topLeftRadius: (node) => valueResolver.getFormattedValue.topLeftRadius(node),
|
|
133
|
+
topRightRadius: (node) => valueResolver.getFormattedValue.topRightRadius(node),
|
|
134
|
+
bottomLeftRadius: (node) => valueResolver.getFormattedValue.bottomLeftRadius(node),
|
|
135
|
+
bottomRightRadius: (node) => valueResolver.getFormattedValue.bottomRightRadius(node),
|
|
143
136
|
},
|
|
144
137
|
shorthands: {
|
|
145
138
|
cornerRadius: ["topLeftRadius", "topRightRadius", "bottomLeftRadius", "bottomRightRadius"],
|
|
@@ -158,9 +151,9 @@ export interface FillProps {
|
|
|
158
151
|
fill?: string;
|
|
159
152
|
}
|
|
160
153
|
|
|
161
|
-
export function
|
|
162
|
-
return
|
|
163
|
-
const fill =
|
|
154
|
+
export function createFrameFillPropsConverter(valueResolver: FigmaValueResolver) {
|
|
155
|
+
return definePropsConverter<FillTrait, FillProps>((node: FillTrait) => {
|
|
156
|
+
const fill = valueResolver.getFormattedValue.frameFill(node);
|
|
164
157
|
|
|
165
158
|
return {
|
|
166
159
|
fill,
|
|
@@ -168,9 +161,9 @@ export function createFrameFillPropsTransformer(valueTransformer: FigmaValueTran
|
|
|
168
161
|
});
|
|
169
162
|
}
|
|
170
163
|
|
|
171
|
-
export function
|
|
172
|
-
return
|
|
173
|
-
const fill =
|
|
164
|
+
export function createShapeFillPropsConverter(valueResolver: FigmaValueResolver) {
|
|
165
|
+
return definePropsConverter<FillTrait, FillProps>((node: FillTrait) => {
|
|
166
|
+
const fill = valueResolver.getFormattedValue.shapeFill(node);
|
|
174
167
|
|
|
175
168
|
return {
|
|
176
169
|
fill,
|
|
@@ -178,9 +171,9 @@ export function createShapeFillPropsTransformer(valueTransformer: FigmaValueTran
|
|
|
178
171
|
});
|
|
179
172
|
}
|
|
180
173
|
|
|
181
|
-
export function
|
|
182
|
-
return
|
|
183
|
-
const fill =
|
|
174
|
+
export function createTextFillPropsConverter(valueResolver: FigmaValueResolver) {
|
|
175
|
+
return definePropsConverter<FillTrait, FillProps>((node: FillTrait) => {
|
|
176
|
+
const fill = valueResolver.getFormattedValue.textFill(node);
|
|
184
177
|
|
|
185
178
|
return {
|
|
186
179
|
fill,
|
|
@@ -193,11 +186,11 @@ export interface StrokeProps {
|
|
|
193
186
|
strokeWeight?: number;
|
|
194
187
|
}
|
|
195
188
|
|
|
196
|
-
export function
|
|
197
|
-
|
|
198
|
-
):
|
|
199
|
-
return
|
|
200
|
-
const stroke =
|
|
189
|
+
export function createStrokePropsConverter(
|
|
190
|
+
valueResolver: FigmaValueResolver,
|
|
191
|
+
): PropsConverter<StrokeTrait, StrokeProps> {
|
|
192
|
+
return definePropsConverter((node: StrokeTrait) => {
|
|
193
|
+
const stroke = valueResolver.getFormattedValue.stroke(node);
|
|
201
194
|
const strokeWeight = node.strokeWeight;
|
|
202
195
|
|
|
203
196
|
return {
|
|
@@ -215,15 +208,11 @@ export interface TypeStyleProps {
|
|
|
215
208
|
maxLines?: number;
|
|
216
209
|
}
|
|
217
210
|
|
|
218
|
-
export function
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
styleService: StyleService;
|
|
224
|
-
}): PropsTransformer<TypeStyleTrait, TypeStyleProps> {
|
|
225
|
-
return definePropsTransformer((node) => {
|
|
226
|
-
const styleName = node.textStyleKey ? styleService.getStyleName(node.textStyleKey) : undefined;
|
|
211
|
+
export function createTypeStylePropsConverter(
|
|
212
|
+
valueResolver: FigmaValueResolver,
|
|
213
|
+
): PropsConverter<TypeStyleTrait, TypeStyleProps> {
|
|
214
|
+
return definePropsConverter((node) => {
|
|
215
|
+
const styleName = valueResolver.getTextStyleValue(node);
|
|
227
216
|
const maxLines =
|
|
228
217
|
node.style.textTruncation === "ENDING" ? (node.style.maxLines ?? undefined) : undefined;
|
|
229
218
|
|
|
@@ -235,9 +224,9 @@ export function createTypeStylePropsTransformer({
|
|
|
235
224
|
}
|
|
236
225
|
|
|
237
226
|
return {
|
|
238
|
-
fontSize:
|
|
239
|
-
fontWeight:
|
|
240
|
-
lineHeight:
|
|
227
|
+
fontSize: valueResolver.getFormattedValue.fontSize(node),
|
|
228
|
+
fontWeight: valueResolver.getFormattedValue.fontWeight(node),
|
|
229
|
+
lineHeight: valueResolver.getFormattedValue.lineHeight(node),
|
|
241
230
|
maxLines,
|
|
242
231
|
};
|
|
243
232
|
});
|
|
@@ -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,22 @@
|
|
|
1
|
+
import { createValueResolver, type ValueResolver } from "@/codegen/core";
|
|
2
|
+
import { styleService, variableService } from "@/codegen/default-services";
|
|
3
|
+
import { toCssRgba } from "@/utils/css";
|
|
4
|
+
|
|
5
|
+
export type FigmaValueResolver = ValueResolver<string, number, number, number>;
|
|
6
|
+
|
|
7
|
+
export const valueResolver = createValueResolver({
|
|
8
|
+
variableService,
|
|
9
|
+
variableNameFormatter: ({ slug }) =>
|
|
10
|
+
slug
|
|
11
|
+
.filter((s) => s !== "dimension")
|
|
12
|
+
.map((s) => s.replaceAll(",", "_"))
|
|
13
|
+
.join("/"),
|
|
14
|
+
styleService,
|
|
15
|
+
styleNameFormatter: ({ slug }) => slug[slug.length - 1]!,
|
|
16
|
+
rawValueFormatters: {
|
|
17
|
+
color: (value: RGBA) => toCssRgba(value),
|
|
18
|
+
dimension: (value: number) => value,
|
|
19
|
+
fontDimension: (value: number) => value,
|
|
20
|
+
fontWeight: (value: number) => value,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
@@ -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",
|