@seed-design/figma 0.0.6 → 0.0.15
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/index.cjs +5548 -4901
- package/lib/index.d.ts +489 -189
- package/lib/index.js +5535 -4888
- package/package.json +3 -2
- package/src/codegen/core/codegen.ts +65 -0
- package/src/codegen/core/component.ts +15 -27
- package/src/codegen/core/component.types.ts +29 -0
- package/src/codegen/core/element.ts +13 -0
- package/src/codegen/core/index.ts +13 -8
- package/src/codegen/core/infer-layout.test.ts +285 -0
- package/src/codegen/core/infer-layout.ts +416 -0
- package/src/codegen/core/jsx.ts +12 -0
- package/src/codegen/core/props.ts +81 -0
- package/src/codegen/core/value.ts +289 -0
- package/src/codegen/index.ts +39 -6
- package/src/codegen/targets/figma/context.ts +139 -0
- package/src/codegen/targets/figma/frame.ts +37 -0
- package/src/codegen/targets/figma/index.ts +6 -0
- package/src/codegen/targets/figma/instance.ts +16 -0
- package/src/codegen/targets/figma/props.ts +244 -0
- package/src/codegen/targets/figma/shape.ts +62 -0
- package/src/codegen/targets/figma/text.ts +33 -0
- package/src/codegen/targets/index.ts +2 -0
- package/src/codegen/{domain/seed-component → targets/react/component}/deps.interface.ts +2 -2
- package/src/codegen/{domain/seed-component → targets/react/component}/index.ts +36 -34
- package/src/codegen/{domain/seed-component → targets/react/component}/properties.type.ts +2 -2
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/action-button.ts +4 -5
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/action-chip.ts +3 -4
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/action-sheet.ts +4 -5
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/app-bar.ts +5 -6
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/avatar-stack.ts +4 -5
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/avatar.ts +4 -5
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/badge.ts +4 -5
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/callout.ts +4 -5
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/checkbox.ts +4 -5
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/chip-tabs.ts +4 -5
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/control-chip.ts +4 -5
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/error-state.ts +4 -5
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/extended-action-sheet.ts +4 -5
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/extended-fab.ts +4 -5
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/fab.ts +2 -2
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/help-bubble.ts +2 -2
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/identity-placeholder.ts +2 -2
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/inline-banner.ts +5 -6
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/manner-temp-badge.ts +3 -4
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/multiline-text-field.ts +4 -5
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/progress-circle.ts +3 -4
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/reaction-button.ts +4 -5
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/segmented-control.ts +4 -5
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/select-box.ts +4 -5
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/skeleton.ts +3 -4
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/snackbar.ts +3 -4
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/switch.ts +4 -5
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/tabs.ts +5 -6
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/text-button.ts +6 -7
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/text-field.ts +4 -5
- package/src/codegen/{domain/seed-component → targets/react/component}/transformers/toggle-button.ts +4 -5
- package/src/codegen/targets/react/context.ts +170 -0
- package/src/codegen/targets/react/frame.ts +75 -0
- package/src/codegen/targets/react/index.ts +7 -0
- package/src/codegen/{domain/instance.service.ts → targets/react/instance.ts} +20 -33
- package/src/codegen/targets/react/props.ts +361 -0
- package/src/codegen/targets/react/shape.ts +36 -0
- package/src/codegen/targets/react/text.ts +33 -0
- package/src/{codegen → entities}/data/icons.ts +1 -1
- package/src/{codegen → entities}/data/styles.ts +1 -1
- package/src/{codegen → entities}/data/variable-collections.ts +1 -1
- package/src/{codegen → entities}/data/variables.ts +1 -1
- package/src/entities/index.ts +41 -0
- package/src/{codegen/domain → entities}/style.repository.ts +6 -2
- package/src/{codegen/domain → entities}/style.service.ts +1 -1
- package/src/{codegen/domain → entities}/variable.repository.ts +17 -4
- package/src/{codegen/domain → entities}/variable.service.ts +47 -9
- package/src/index.ts +1 -0
- package/src/normalizer/from-plugin.ts +3 -0
- package/src/normalizer/types.ts +28 -24
- package/src/utils/common.ts +4 -0
- package/src/utils/css.ts +10 -4
- package/src/utils/figma-node.ts +42 -2
- package/src/codegen/context.ts +0 -148
- package/src/codegen/core/transformer.ts +0 -40
- package/src/codegen/domain/codegen.service.ts +0 -69
- package/src/codegen/domain/figma-component.service.ts +0 -21
- package/src/codegen/domain/frame.service.ts +0 -108
- package/src/codegen/domain/index.ts +0 -22
- package/src/codegen/domain/props/container-layout-props.service.ts +0 -248
- package/src/codegen/domain/props/fill-props.service.ts +0 -75
- package/src/codegen/domain/props/radius-props.service.ts +0 -105
- package/src/codegen/domain/props/self-layout-props.service.ts +0 -127
- package/src/codegen/domain/props/stroke-props.service.ts +0 -45
- package/src/codegen/domain/props/type-style-props.service.ts +0 -31
- package/src/codegen/domain/rectangle.service.ts +0 -31
- package/src/codegen/domain/text.service.ts +0 -62
- /package/src/codegen/{domain/seed-component → targets/react/component}/size.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/action-button.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/action-button.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/action-chip.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/action-chip.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/action-sheet.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/action-sheet.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/avatar-stack.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/avatar-stack.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/avatar.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/avatar.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/badge.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/badge.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/bottom-navigation-global.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/bottom-navigation-global.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/bottom-navigation-kr.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/bottom-navigation-kr.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/bottom-sheet.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/bottom-sheet.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/callout.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/callout.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/checkbox.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/checkbox.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/chip-tablist.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/chip-tablist.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/control-chip.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/control-chip.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/divider.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/divider.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/error-state.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/error-state.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/extended-action-sheet.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/extended-action-sheet.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/extended-floating-action-button.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/extended-floating-action-button.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/floating-action-button.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/floating-action-button.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/help-bubble.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/help-bubble.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/identity-placeholder.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/identity-placeholder.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/index.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/index.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/inline-banner.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/inline-banner.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/main-tab-navigation-global.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/main-tab-navigation-global.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/main-tab-navigation-kr.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/main-tab-navigation-kr.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/manner-temp-badge.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/manner-temp-badge.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/manner-temp-bar.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/manner-temp-bar.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/manner-temp.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/manner-temp.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/multiline-text-field.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/multiline-text-field.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/progress-circle.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/progress-circle.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/radio.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/radio.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/range-slider.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/range-slider.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/reaction-button.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/reaction-button.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/segmented-control.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/segmented-control.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/select-box.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/select-box.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/skeleton.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/skeleton.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/slider.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/slider.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/snackbar.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/snackbar.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/standard-navigation.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/standard-navigation.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/switch.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/switch.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/tablist.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/tablist.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/template-bottom-fixed-bar.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/template-bottom-fixed-bar.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/template-button-group.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/template-button-group.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/template-chip-group.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/template-chip-group.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/template-select-box-group.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/template-select-box-group.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/template-top-navigation.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/template-top-navigation.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/text-button.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/text-button.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/text-field.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/text-field.mjs +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/toggle-button.d.ts +0 -0
- /package/src/{codegen → entities}/data/__generated__/component-sets/toggle-button.mjs +0 -0
- /package/src/{codegen/domain → entities}/icon.interface.ts +0 -0
- /package/src/{codegen/domain → entities}/icon.repository.ts +0 -0
- /package/src/{codegen/domain → entities}/icon.service.ts +0 -0
- /package/src/{codegen/domain → entities}/style.interface.ts +0 -0
- /package/src/{codegen/domain → entities}/variable.interface.ts +0 -0
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import { definePropsTransformer, type PropsTransformer } from "@/codegen/core";
|
|
2
|
-
import type {
|
|
3
|
-
NormalizedHasChildrenTrait,
|
|
4
|
-
NormalizedHasFramePropertiesTrait,
|
|
5
|
-
NormalizedIsLayerTrait,
|
|
6
|
-
} from "@/normalizer";
|
|
7
|
-
import { objectEntries } from "@/utils/common";
|
|
8
|
-
import { toCssPixel } from "@/utils/css";
|
|
9
|
-
import type { VariableService } from "../variable.service";
|
|
10
|
-
|
|
11
|
-
type ContainerLayoutTrait = NormalizedHasFramePropertiesTrait &
|
|
12
|
-
NormalizedHasChildrenTrait &
|
|
13
|
-
NormalizedIsLayerTrait;
|
|
14
|
-
|
|
15
|
-
export interface ContainerLayoutPropsService<T extends Record<string, any>> {
|
|
16
|
-
transform: PropsTransformer<ContainerLayoutTrait, T>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Seed Implementation
|
|
20
|
-
type LayoutPropsKey =
|
|
21
|
-
| "flexDirection"
|
|
22
|
-
| "justifyContent"
|
|
23
|
-
| "alignItems"
|
|
24
|
-
| "flexWrap"
|
|
25
|
-
| "gap"
|
|
26
|
-
| "paddingBottom"
|
|
27
|
-
| "paddingLeft"
|
|
28
|
-
| "paddingRight"
|
|
29
|
-
| "paddingTop";
|
|
30
|
-
|
|
31
|
-
type LayoutShorthandPropsKey = "padding" | "paddingX" | "paddingY";
|
|
32
|
-
|
|
33
|
-
type LayoutPropHandler = (props: ContainerLayoutTrait) => string | number | boolean | undefined;
|
|
34
|
-
|
|
35
|
-
type LayoutShorthandHandler = (
|
|
36
|
-
props: Partial<Record<LayoutPropsKey, string | number | boolean | undefined>>,
|
|
37
|
-
) =>
|
|
38
|
-
| {
|
|
39
|
-
value: string | number | boolean | undefined;
|
|
40
|
-
exclude: LayoutPropsKey[];
|
|
41
|
-
}
|
|
42
|
-
| undefined;
|
|
43
|
-
|
|
44
|
-
export type SeedContainerLayoutProps = Partial<
|
|
45
|
-
Record<LayoutPropsKey | LayoutShorthandPropsKey, string | number | boolean>
|
|
46
|
-
>;
|
|
47
|
-
|
|
48
|
-
export function createContainerLayoutPropsService({
|
|
49
|
-
variableService,
|
|
50
|
-
shouldInferVariableName,
|
|
51
|
-
}: {
|
|
52
|
-
variableService: VariableService;
|
|
53
|
-
shouldInferVariableName: boolean;
|
|
54
|
-
}): ContainerLayoutPropsService<SeedContainerLayoutProps> {
|
|
55
|
-
const getLayoutVariableName = (id: string) => variableService.getVariableName(id);
|
|
56
|
-
const inferSpacingVariableName = (value?: number) => {
|
|
57
|
-
if (value === undefined) {
|
|
58
|
-
return undefined;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (shouldInferVariableName) {
|
|
62
|
-
const inferred = variableService.inferVariableName("GAP", value);
|
|
63
|
-
if (inferred) {
|
|
64
|
-
return inferred;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return value === 0 ? 0 : toCssPixel(value);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const layoutPropHandlers: Record<LayoutPropsKey, LayoutPropHandler> = {
|
|
72
|
-
flexDirection: ({ layoutMode }) => (layoutMode === "HORIZONTAL" ? "row" : "column"),
|
|
73
|
-
justifyContent: ({ primaryAxisAlignItems }) => {
|
|
74
|
-
switch (primaryAxisAlignItems) {
|
|
75
|
-
case "MIN":
|
|
76
|
-
return "flexStart";
|
|
77
|
-
case "CENTER":
|
|
78
|
-
return "center";
|
|
79
|
-
case "MAX":
|
|
80
|
-
return "flexEnd";
|
|
81
|
-
case "SPACE_BETWEEN":
|
|
82
|
-
return "spaceBetween";
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
alignItems: ({ counterAxisAlignItems, children }) => {
|
|
86
|
-
const isStretch = children.every((child) => {
|
|
87
|
-
if (!("layoutAlign" in child)) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return child.layoutAlign === "STRETCH";
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
if (isStretch) {
|
|
95
|
-
return "stretch";
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
switch (counterAxisAlignItems) {
|
|
99
|
-
case "MIN":
|
|
100
|
-
return "flexStart";
|
|
101
|
-
case "CENTER":
|
|
102
|
-
return "center";
|
|
103
|
-
case "MAX":
|
|
104
|
-
return "flexEnd";
|
|
105
|
-
case "BASELINE":
|
|
106
|
-
return "baseline";
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
flexWrap: ({ layoutWrap }) => (layoutWrap === "WRAP" ? "wrap" : "nowrap"),
|
|
110
|
-
gap: ({ itemSpacing, boundVariables, primaryAxisAlignItems, children }) =>
|
|
111
|
-
children.length <= 1
|
|
112
|
-
? 0
|
|
113
|
-
: primaryAxisAlignItems === "SPACE_BETWEEN"
|
|
114
|
-
? 0
|
|
115
|
-
: boundVariables?.itemSpacing
|
|
116
|
-
? getLayoutVariableName(boundVariables.itemSpacing.id)
|
|
117
|
-
: inferSpacingVariableName(itemSpacing),
|
|
118
|
-
paddingTop: ({ paddingTop, boundVariables }) =>
|
|
119
|
-
boundVariables?.paddingTop
|
|
120
|
-
? getLayoutVariableName(boundVariables.paddingTop.id)
|
|
121
|
-
: inferSpacingVariableName(paddingTop),
|
|
122
|
-
paddingBottom: ({ paddingBottom, boundVariables }) =>
|
|
123
|
-
boundVariables?.paddingBottom
|
|
124
|
-
? getLayoutVariableName(boundVariables.paddingBottom.id)
|
|
125
|
-
: inferSpacingVariableName(paddingBottom),
|
|
126
|
-
paddingLeft: ({ paddingLeft, boundVariables }) =>
|
|
127
|
-
boundVariables?.paddingLeft
|
|
128
|
-
? getLayoutVariableName(boundVariables.paddingLeft.id)
|
|
129
|
-
: inferSpacingVariableName(paddingLeft),
|
|
130
|
-
paddingRight: ({ paddingRight, boundVariables }) =>
|
|
131
|
-
boundVariables?.paddingRight
|
|
132
|
-
? getLayoutVariableName(boundVariables.paddingRight.id)
|
|
133
|
-
: inferSpacingVariableName(paddingRight),
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
const layoutShorthandHandlers: Record<LayoutShorthandPropsKey, LayoutShorthandHandler> = {
|
|
137
|
-
paddingX: ({ paddingLeft, paddingRight, paddingTop, paddingBottom }) => {
|
|
138
|
-
if (paddingLeft === undefined || paddingRight === undefined) {
|
|
139
|
-
return undefined;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (
|
|
143
|
-
paddingLeft === paddingRight &&
|
|
144
|
-
paddingTop === paddingBottom &&
|
|
145
|
-
paddingLeft === paddingTop
|
|
146
|
-
) {
|
|
147
|
-
return undefined;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (paddingLeft === paddingRight) {
|
|
151
|
-
const value = paddingLeft;
|
|
152
|
-
return {
|
|
153
|
-
value,
|
|
154
|
-
exclude: ["paddingLeft", "paddingRight"],
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
return undefined;
|
|
158
|
-
},
|
|
159
|
-
paddingY: ({ paddingLeft, paddingRight, paddingTop, paddingBottom }) => {
|
|
160
|
-
if (paddingTop === undefined || paddingBottom === undefined) {
|
|
161
|
-
return undefined;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (
|
|
165
|
-
paddingLeft === paddingRight &&
|
|
166
|
-
paddingTop === paddingBottom &&
|
|
167
|
-
paddingLeft === paddingTop
|
|
168
|
-
) {
|
|
169
|
-
return undefined;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (paddingTop === paddingBottom) {
|
|
173
|
-
return {
|
|
174
|
-
value: paddingTop,
|
|
175
|
-
exclude: ["paddingTop", "paddingBottom"],
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
return undefined;
|
|
179
|
-
},
|
|
180
|
-
padding: ({ paddingLeft, paddingRight, paddingTop, paddingBottom }) => {
|
|
181
|
-
if (
|
|
182
|
-
paddingLeft === undefined ||
|
|
183
|
-
paddingRight === undefined ||
|
|
184
|
-
paddingTop === undefined ||
|
|
185
|
-
paddingBottom === undefined
|
|
186
|
-
) {
|
|
187
|
-
return undefined;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (
|
|
191
|
-
paddingLeft === paddingRight &&
|
|
192
|
-
paddingTop === paddingBottom &&
|
|
193
|
-
paddingLeft === paddingTop
|
|
194
|
-
) {
|
|
195
|
-
return {
|
|
196
|
-
value: paddingLeft,
|
|
197
|
-
exclude: ["paddingLeft", "paddingRight", "paddingTop", "paddingBottom"],
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
return undefined;
|
|
201
|
-
},
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
// Default values
|
|
205
|
-
const layoutPropDefaults: SeedContainerLayoutProps = {
|
|
206
|
-
flexDirection: "row",
|
|
207
|
-
justifyContent: "flexStart",
|
|
208
|
-
alignItems: "stretch",
|
|
209
|
-
flexWrap: "nowrap",
|
|
210
|
-
gap: 0,
|
|
211
|
-
padding: 0,
|
|
212
|
-
paddingX: 0,
|
|
213
|
-
paddingY: 0,
|
|
214
|
-
paddingBottom: 0,
|
|
215
|
-
paddingLeft: 0,
|
|
216
|
-
paddingRight: 0,
|
|
217
|
-
paddingTop: 0,
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
const transform = definePropsTransformer((node: ContainerLayoutTrait) => {
|
|
221
|
-
const result: SeedContainerLayoutProps = {};
|
|
222
|
-
|
|
223
|
-
for (const [prop, handler] of objectEntries(layoutPropHandlers)) {
|
|
224
|
-
const value = handler(node);
|
|
225
|
-
if (value !== undefined && value !== layoutPropDefaults[prop]) {
|
|
226
|
-
result[prop] = value;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
for (const [prop, handler] of objectEntries(layoutShorthandHandlers)) {
|
|
231
|
-
const shorthandResult = handler(result);
|
|
232
|
-
if (shorthandResult === undefined) {
|
|
233
|
-
continue;
|
|
234
|
-
}
|
|
235
|
-
const { value, exclude } = shorthandResult;
|
|
236
|
-
if (value !== undefined && value !== layoutPropDefaults[prop]) {
|
|
237
|
-
result[prop] = value;
|
|
238
|
-
for (const excludedProp of exclude) {
|
|
239
|
-
delete result[excludedProp];
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
return result;
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
return { transform };
|
|
248
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { definePropsTransformer, type PropsTransformer } from "@/codegen/core";
|
|
2
|
-
import type { NormalizedHasGeometryTrait, NormalizedIsLayerTrait } from "@/normalizer";
|
|
3
|
-
import { toCssRgba } from "@/utils/css";
|
|
4
|
-
import type { VariableService } from "../variable.service";
|
|
5
|
-
|
|
6
|
-
type FillTrait = NormalizedIsLayerTrait & NormalizedHasGeometryTrait;
|
|
7
|
-
|
|
8
|
-
export interface FillPropsService<T extends Record<string, any>> {
|
|
9
|
-
transform: PropsTransformer<FillTrait, T>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface FrameFillProps {
|
|
13
|
-
background?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function createFrameFillPropsService({
|
|
17
|
-
variableService,
|
|
18
|
-
}: { variableService: VariableService }): FillPropsService<FrameFillProps> {
|
|
19
|
-
const transform = definePropsTransformer((node: FillTrait) => {
|
|
20
|
-
const fills = node.fills;
|
|
21
|
-
if (fills.length === 0) {
|
|
22
|
-
return {};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const fill = fills[0];
|
|
26
|
-
if (!fill || ("visible" in fill && !fill.visible) || fill.type !== "SOLID") {
|
|
27
|
-
return {};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (node.boundVariables?.fills?.length === 1) {
|
|
31
|
-
return {
|
|
32
|
-
background: variableService.getVariableName(node.boundVariables.fills[0]!.id),
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const color = fill.color;
|
|
37
|
-
return {
|
|
38
|
-
background: toCssRgba(color),
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
return { transform };
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface ShapeFillProps {
|
|
46
|
-
color?: string;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function createShapeFillPropsService({
|
|
50
|
-
variableService,
|
|
51
|
-
}: { variableService: VariableService }): FillPropsService<ShapeFillProps> {
|
|
52
|
-
const transform = definePropsTransformer((node: FillTrait) => {
|
|
53
|
-
const fills = node.fills;
|
|
54
|
-
if (fills.length === 0) {
|
|
55
|
-
return {};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const fill = fills[0];
|
|
59
|
-
if (!fill || ("visible" in fill && !fill.visible) || fill.type !== "SOLID") {
|
|
60
|
-
return {};
|
|
61
|
-
}
|
|
62
|
-
if (node.boundVariables?.fills?.length === 1) {
|
|
63
|
-
return {
|
|
64
|
-
color: variableService.getVariableName(node.boundVariables.fills[0]!.id),
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const color = fill.color;
|
|
69
|
-
return {
|
|
70
|
-
color: toCssRgba(color),
|
|
71
|
-
};
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
return { transform };
|
|
75
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { definePropsTransformer, type PropsTransformer } from "@/codegen/core";
|
|
2
|
-
import type { NormalizedCornerTrait, NormalizedIsLayerTrait } from "@/normalizer";
|
|
3
|
-
import { objectEntries } from "@/utils/common";
|
|
4
|
-
import { toCssPixel } from "@/utils/css";
|
|
5
|
-
import type { VariableService } from "../variable.service";
|
|
6
|
-
|
|
7
|
-
type RadiusTrait = NormalizedCornerTrait & NormalizedIsLayerTrait;
|
|
8
|
-
|
|
9
|
-
export interface RadiusPropsService<T extends Record<string, any>> {
|
|
10
|
-
transform: PropsTransformer<RadiusTrait, T>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
type RadiusPropsKey =
|
|
14
|
-
| "borderRadius"
|
|
15
|
-
| "borderTopLeftRadius"
|
|
16
|
-
| "borderTopRightRadius"
|
|
17
|
-
| "borderBottomLeftRadius"
|
|
18
|
-
| "borderBottomRightRadius";
|
|
19
|
-
|
|
20
|
-
type ApperancePropHandler = (props: RadiusTrait) => string | number | boolean | undefined;
|
|
21
|
-
|
|
22
|
-
export type SeedRadiusProps = Partial<Record<RadiusPropsKey, string | number | boolean>>;
|
|
23
|
-
|
|
24
|
-
export function createRadiusPropsService({
|
|
25
|
-
variableService,
|
|
26
|
-
shouldInferVariableName,
|
|
27
|
-
}: {
|
|
28
|
-
variableService: VariableService;
|
|
29
|
-
shouldInferVariableName: boolean;
|
|
30
|
-
}): RadiusPropsService<SeedRadiusProps> {
|
|
31
|
-
const getLayoutVariableName = (id: string) => variableService.getVariableName(id);
|
|
32
|
-
const inferRadiusVariableName = (value?: number) => {
|
|
33
|
-
if (value === undefined) {
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (shouldInferVariableName) {
|
|
38
|
-
const inferred = variableService.inferVariableName("CORNER_RADIUS", value);
|
|
39
|
-
if (inferred) {
|
|
40
|
-
return inferred;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return value === 0 ? 0 : toCssPixel(value);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const radiusPropHandlers: Record<RadiusPropsKey, ApperancePropHandler> = {
|
|
48
|
-
borderRadius: ({ cornerRadius, boundVariables }) => {
|
|
49
|
-
// If all corner radii are the same, use the first one
|
|
50
|
-
if (
|
|
51
|
-
cornerRadius &&
|
|
52
|
-
boundVariables?.bottomLeftRadius === boundVariables?.bottomRightRadius &&
|
|
53
|
-
boundVariables?.bottomLeftRadius === boundVariables?.topLeftRadius &&
|
|
54
|
-
boundVariables?.bottomLeftRadius === boundVariables?.topRightRadius
|
|
55
|
-
) {
|
|
56
|
-
return boundVariables?.bottomLeftRadius
|
|
57
|
-
? getLayoutVariableName(boundVariables.bottomLeftRadius.id)
|
|
58
|
-
: inferRadiusVariableName(cornerRadius);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// TODO: handle individual corner radii
|
|
62
|
-
return undefined;
|
|
63
|
-
},
|
|
64
|
-
borderTopLeftRadius: ({ rectangleCornerRadii, boundVariables }) =>
|
|
65
|
-
boundVariables?.topLeftRadius
|
|
66
|
-
? getLayoutVariableName(boundVariables.topLeftRadius.id)
|
|
67
|
-
: inferRadiusVariableName(rectangleCornerRadii?.[0]),
|
|
68
|
-
borderTopRightRadius: ({ rectangleCornerRadii, boundVariables }) =>
|
|
69
|
-
boundVariables?.topRightRadius
|
|
70
|
-
? getLayoutVariableName(boundVariables.topRightRadius.id)
|
|
71
|
-
: inferRadiusVariableName(rectangleCornerRadii?.[1]),
|
|
72
|
-
borderBottomLeftRadius: ({ rectangleCornerRadii, boundVariables }) =>
|
|
73
|
-
boundVariables?.bottomLeftRadius
|
|
74
|
-
? getLayoutVariableName(boundVariables.bottomLeftRadius.id)
|
|
75
|
-
: inferRadiusVariableName(rectangleCornerRadii?.[2]),
|
|
76
|
-
borderBottomRightRadius: ({ rectangleCornerRadii, boundVariables }) =>
|
|
77
|
-
boundVariables?.bottomRightRadius
|
|
78
|
-
? getLayoutVariableName(boundVariables.bottomRightRadius.id)
|
|
79
|
-
: inferRadiusVariableName(rectangleCornerRadii?.[3]),
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
// Default values
|
|
83
|
-
const radiusPropDefaults: SeedRadiusProps = {
|
|
84
|
-
borderRadius: 0,
|
|
85
|
-
borderTopLeftRadius: 0,
|
|
86
|
-
borderTopRightRadius: 0,
|
|
87
|
-
borderBottomLeftRadius: 0,
|
|
88
|
-
borderBottomRightRadius: 0,
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const transform = definePropsTransformer((node: RadiusTrait) => {
|
|
92
|
-
const result: SeedRadiusProps = {};
|
|
93
|
-
|
|
94
|
-
for (const [prop, handler] of objectEntries(radiusPropHandlers)) {
|
|
95
|
-
const value = handler(node);
|
|
96
|
-
if (value !== undefined && value !== radiusPropDefaults[prop]) {
|
|
97
|
-
result[prop] = value;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return result;
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
return { transform };
|
|
105
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { definePropsTransformer, type PropsTransformer } from "@/codegen/core";
|
|
2
|
-
import type {
|
|
3
|
-
NormalizedHasFramePropertiesTrait,
|
|
4
|
-
NormalizedHasLayoutTrait,
|
|
5
|
-
NormalizedIsLayerTrait,
|
|
6
|
-
} from "@/normalizer";
|
|
7
|
-
import { objectEntries } from "@/utils/common";
|
|
8
|
-
import { toCssPixel } from "@/utils/css";
|
|
9
|
-
import type { VariableService } from "../variable.service";
|
|
10
|
-
|
|
11
|
-
type SelfLayoutTrait = NormalizedIsLayerTrait &
|
|
12
|
-
NormalizedHasLayoutTrait &
|
|
13
|
-
NormalizedHasFramePropertiesTrait;
|
|
14
|
-
|
|
15
|
-
export interface SelfLayoutPropsService<T extends Record<string, any>> {
|
|
16
|
-
transform: PropsTransformer<SelfLayoutTrait, T>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
type LayoutPropsKey =
|
|
20
|
-
| "flexGrow"
|
|
21
|
-
| "alignSelf"
|
|
22
|
-
| "width"
|
|
23
|
-
| "height"
|
|
24
|
-
| "minWidth"
|
|
25
|
-
| "minHeight"
|
|
26
|
-
| "maxWidth"
|
|
27
|
-
| "maxHeight";
|
|
28
|
-
|
|
29
|
-
type LayoutPropHandler = (props: SelfLayoutTrait) => string | number | boolean | undefined;
|
|
30
|
-
|
|
31
|
-
export type SeedSelfLayoutProps = Partial<Record<LayoutPropsKey, string | number | boolean>>;
|
|
32
|
-
|
|
33
|
-
export function createSelfLayoutPropsService({
|
|
34
|
-
variableService,
|
|
35
|
-
shouldInferVariableName,
|
|
36
|
-
}: {
|
|
37
|
-
variableService: VariableService;
|
|
38
|
-
shouldInferVariableName: boolean;
|
|
39
|
-
}): SelfLayoutPropsService<SeedSelfLayoutProps> {
|
|
40
|
-
const getLayoutVariableName = (id: string) => variableService.getVariableName(id);
|
|
41
|
-
const inferSizeVariableName = (value?: number) => {
|
|
42
|
-
if (value === undefined) {
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (shouldInferVariableName) {
|
|
47
|
-
const inferred = variableService.inferVariableName("WIDTH_HEIGHT", value);
|
|
48
|
-
if (inferred) {
|
|
49
|
-
return inferred;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return value === 0 ? 0 : toCssPixel(value);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const layoutPropHandlers: Record<LayoutPropsKey, LayoutPropHandler> = {
|
|
57
|
-
flexGrow: ({ layoutGrow }) => layoutGrow,
|
|
58
|
-
alignSelf: ({ layoutAlign }) => {
|
|
59
|
-
switch (layoutAlign) {
|
|
60
|
-
case "STRETCH":
|
|
61
|
-
return "stretch";
|
|
62
|
-
case "MIN":
|
|
63
|
-
return "flexStart";
|
|
64
|
-
case "CENTER":
|
|
65
|
-
return "center";
|
|
66
|
-
case "MAX":
|
|
67
|
-
return "flexEnd";
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
height: ({ boundVariables, layoutSizingVertical, absoluteBoundingBox }) =>
|
|
71
|
-
layoutSizingVertical === "FIXED" || layoutSizingVertical === undefined
|
|
72
|
-
? boundVariables?.size?.y
|
|
73
|
-
? getLayoutVariableName(boundVariables.size.y.id)
|
|
74
|
-
: inferSizeVariableName(absoluteBoundingBox?.height)
|
|
75
|
-
: undefined,
|
|
76
|
-
width: ({ boundVariables, layoutSizingHorizontal, absoluteBoundingBox }) =>
|
|
77
|
-
layoutSizingHorizontal === "FIXED" || layoutSizingHorizontal === undefined
|
|
78
|
-
? boundVariables?.size?.x
|
|
79
|
-
? getLayoutVariableName(boundVariables.size.x.id)
|
|
80
|
-
: inferSizeVariableName(absoluteBoundingBox?.width)
|
|
81
|
-
: undefined,
|
|
82
|
-
minHeight: ({ boundVariables, layoutSizingVertical, minHeight }) =>
|
|
83
|
-
layoutSizingVertical === "HUG"
|
|
84
|
-
? boundVariables?.minHeight
|
|
85
|
-
? getLayoutVariableName(boundVariables.minHeight.id)
|
|
86
|
-
: inferSizeVariableName(minHeight)
|
|
87
|
-
: undefined,
|
|
88
|
-
maxHeight: ({ boundVariables, layoutSizingVertical, maxHeight }) =>
|
|
89
|
-
layoutSizingVertical === "HUG"
|
|
90
|
-
? boundVariables?.maxHeight
|
|
91
|
-
? getLayoutVariableName(boundVariables.maxHeight.id)
|
|
92
|
-
: inferSizeVariableName(maxHeight)
|
|
93
|
-
: undefined,
|
|
94
|
-
minWidth: ({ boundVariables, layoutSizingHorizontal, minWidth }) =>
|
|
95
|
-
layoutSizingHorizontal === "HUG"
|
|
96
|
-
? boundVariables?.minWidth
|
|
97
|
-
? getLayoutVariableName(boundVariables.minWidth.id)
|
|
98
|
-
: inferSizeVariableName(minWidth)
|
|
99
|
-
: undefined,
|
|
100
|
-
maxWidth: ({ boundVariables, layoutSizingHorizontal, maxWidth }) =>
|
|
101
|
-
layoutSizingHorizontal === "HUG"
|
|
102
|
-
? boundVariables?.maxWidth
|
|
103
|
-
? getLayoutVariableName(boundVariables.maxWidth.id)
|
|
104
|
-
: inferSizeVariableName(maxWidth)
|
|
105
|
-
: undefined,
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
// Default values
|
|
109
|
-
const layoutPropDefaults: SeedSelfLayoutProps = {
|
|
110
|
-
flexGrow: 0,
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const transform = definePropsTransformer((node: SelfLayoutTrait) => {
|
|
114
|
-
const result: SeedSelfLayoutProps = {};
|
|
115
|
-
|
|
116
|
-
for (const [prop, handler] of objectEntries(layoutPropHandlers)) {
|
|
117
|
-
const value = handler(node);
|
|
118
|
-
if (value !== undefined && value !== layoutPropDefaults[prop]) {
|
|
119
|
-
result[prop] = value;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return result;
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
return { transform };
|
|
127
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { definePropsTransformer, type PropsTransformer } from "@/codegen/core";
|
|
2
|
-
import type { NormalizedHasGeometryTrait, NormalizedIsLayerTrait } from "@/normalizer";
|
|
3
|
-
import type { VariableService } from "../variable.service";
|
|
4
|
-
|
|
5
|
-
type StrokeTrait = NormalizedIsLayerTrait & NormalizedHasGeometryTrait;
|
|
6
|
-
|
|
7
|
-
export interface StrokePropsService<T extends Record<string, any>> {
|
|
8
|
-
transform: PropsTransformer<StrokeTrait, T>;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface SeedFrameStrokeProps {
|
|
12
|
-
borderWidth?: number;
|
|
13
|
-
borderColor?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function createFrameStrokePropsService({
|
|
17
|
-
variableService,
|
|
18
|
-
}: { variableService: VariableService }): StrokePropsService<SeedFrameStrokeProps> {
|
|
19
|
-
const transform = definePropsTransformer((node: StrokeTrait) => {
|
|
20
|
-
const strokes = node.strokes;
|
|
21
|
-
if (strokes === undefined || strokes.length === 0) {
|
|
22
|
-
return {};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const stroke = strokes[0];
|
|
26
|
-
if (!stroke || ("visible" in stroke && !stroke.visible) || stroke.type !== "SOLID") {
|
|
27
|
-
return {};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (node.boundVariables?.strokes?.length === 1) {
|
|
31
|
-
return {
|
|
32
|
-
borderWidth: node.strokeWeight as number,
|
|
33
|
-
borderColor: variableService.getVariableName(node.boundVariables.strokes[0]!.id),
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const color = stroke.color;
|
|
38
|
-
return {
|
|
39
|
-
borderWidth: node.strokeWeight as number,
|
|
40
|
-
borderColor: `rgba(${color.r * 255}, ${color.g * 255}, ${color.b * 255}, ${stroke.opacity})`,
|
|
41
|
-
};
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
return { transform };
|
|
45
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { definePropsTransformer, type PropsTransformer } from "@/codegen/core";
|
|
2
|
-
import type { NormalizedTextNode } from "@/normalizer";
|
|
3
|
-
import type { VariableService } from "../variable.service";
|
|
4
|
-
|
|
5
|
-
export interface TypeStylePropsService {
|
|
6
|
-
transform: PropsTransformer<NormalizedTextNode>;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function createFrameTypeStylePropsService({
|
|
10
|
-
variableService,
|
|
11
|
-
}: { variableService: VariableService }) {
|
|
12
|
-
const transform = definePropsTransformer((node: NormalizedTextNode) => {
|
|
13
|
-
const fontSizeBoundVariables = node.boundVariables?.fontSize?.[0];
|
|
14
|
-
const fontStyleBoundVariables = node.boundVariables?.fontStyle?.[0];
|
|
15
|
-
const lineHeightBoundVariables = node.boundVariables?.lineHeight?.[0];
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
fontSize: fontSizeBoundVariables
|
|
19
|
-
? variableService.getVariableName(fontSizeBoundVariables.id)
|
|
20
|
-
: undefined,
|
|
21
|
-
fontWeight: fontStyleBoundVariables
|
|
22
|
-
? variableService.getVariableName(fontStyleBoundVariables.id)
|
|
23
|
-
: undefined,
|
|
24
|
-
lineHeight: lineHeightBoundVariables
|
|
25
|
-
? variableService.getVariableName(lineHeightBoundVariables.id)
|
|
26
|
-
: undefined,
|
|
27
|
-
};
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
return { transform } satisfies TypeStylePropsService;
|
|
31
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { NormalizedRectangleNode } from "@/normalizer";
|
|
2
|
-
import { createElement, defineElementTransformer, type ElementTransformer } from "../core";
|
|
3
|
-
import type {
|
|
4
|
-
SeedSelfLayoutProps,
|
|
5
|
-
SelfLayoutPropsService,
|
|
6
|
-
} from "./props/self-layout-props.service";
|
|
7
|
-
|
|
8
|
-
export interface RectangleService {
|
|
9
|
-
transform: ElementTransformer<NormalizedRectangleNode>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface SeedRectangleServiceDeps {
|
|
13
|
-
selfLayoutPropsService: SelfLayoutPropsService<SeedSelfLayoutProps>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function createSeedRectangleService({
|
|
17
|
-
selfLayoutPropsService,
|
|
18
|
-
}: SeedRectangleServiceDeps): RectangleService {
|
|
19
|
-
const transform = defineElementTransformer((node: NormalizedRectangleNode, traverse) => {
|
|
20
|
-
return createElement(
|
|
21
|
-
"Box",
|
|
22
|
-
{ ...selfLayoutPropsService.transform(node, traverse), background: "palette.gray200" },
|
|
23
|
-
undefined,
|
|
24
|
-
"Rectangle Node Placeholder",
|
|
25
|
-
);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
transform,
|
|
30
|
-
};
|
|
31
|
-
}
|