@seed-design/figma 0.0.4 → 0.0.6
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 +10589 -12261
- package/lib/index.d.ts +1732 -41
- package/lib/index.js +10565 -12262
- package/package.json +2 -2
- package/src/codegen/context.ts +148 -0
- package/src/{component/type-helper.ts → codegen/core/component.ts} +1 -12
- package/src/codegen/core/index.ts +14 -0
- package/src/{jsx.ts → codegen/core/jsx.ts} +13 -3
- package/src/codegen/core/transformer.ts +40 -0
- package/src/{data → codegen/data}/icons.ts +2 -6
- package/src/{data → codegen/data}/styles.ts +87 -29
- package/src/codegen/data/variable-collections.ts +310 -0
- package/src/{data → codegen/data}/variables.ts +2821 -5887
- package/src/codegen/domain/codegen.service.ts +69 -0
- package/src/codegen/domain/figma-component.service.ts +21 -0
- package/src/codegen/domain/frame.service.ts +108 -0
- package/src/codegen/domain/icon.interface.ts +5 -0
- package/src/codegen/domain/icon.repository.ts +11 -0
- package/src/codegen/domain/icon.service.ts +35 -0
- package/src/codegen/domain/index.ts +22 -0
- package/src/codegen/domain/instance.service.ts +91 -0
- package/src/codegen/domain/props/container-layout-props.service.ts +248 -0
- package/src/codegen/domain/props/fill-props.service.ts +75 -0
- package/src/codegen/domain/props/radius-props.service.ts +105 -0
- package/src/codegen/domain/props/self-layout-props.service.ts +127 -0
- package/src/codegen/domain/props/stroke-props.service.ts +45 -0
- package/src/codegen/domain/props/type-style-props.service.ts +31 -0
- package/src/codegen/domain/rectangle.service.ts +31 -0
- package/src/codegen/domain/seed-component/deps.interface.ts +6 -0
- package/src/codegen/domain/seed-component/index.ts +75 -0
- package/src/{component/type.ts → codegen/domain/seed-component/properties.type.ts} +2 -2
- package/src/{component/properties.ts → codegen/domain/seed-component/size.ts} +4 -2
- package/src/codegen/domain/seed-component/transformers/action-button.ts +69 -0
- package/src/codegen/domain/seed-component/transformers/action-chip.ts +82 -0
- package/src/codegen/domain/seed-component/transformers/action-sheet.ts +78 -0
- package/src/{component/handlers → codegen/domain/seed-component/transformers}/app-bar.ts +114 -111
- package/src/codegen/domain/seed-component/transformers/avatar-stack.ts +30 -0
- package/src/codegen/domain/seed-component/transformers/avatar.ts +39 -0
- package/src/codegen/domain/seed-component/transformers/badge.ts +22 -0
- package/src/codegen/domain/seed-component/transformers/callout.ts +90 -0
- package/src/codegen/domain/seed-component/transformers/checkbox.ts +34 -0
- package/src/codegen/domain/seed-component/transformers/chip-tabs.ts +55 -0
- package/src/codegen/domain/seed-component/transformers/control-chip.ts +86 -0
- package/src/codegen/domain/seed-component/transformers/error-state.ts +39 -0
- package/src/codegen/domain/seed-component/transformers/extended-action-sheet.ts +99 -0
- package/src/codegen/domain/seed-component/transformers/extended-fab.ts +25 -0
- package/src/codegen/domain/seed-component/transformers/fab.ts +18 -0
- package/src/codegen/domain/seed-component/transformers/help-bubble.ts +68 -0
- package/src/codegen/domain/seed-component/transformers/identity-placeholder.ts +18 -0
- package/src/{component/handlers → codegen/domain/seed-component/transformers}/inline-banner.ts +11 -13
- package/src/codegen/domain/seed-component/transformers/manner-temp-badge.ts +19 -0
- package/src/codegen/domain/seed-component/transformers/multiline-text-field.ts +82 -0
- package/src/codegen/domain/seed-component/transformers/progress-circle.ts +51 -0
- package/src/codegen/domain/seed-component/transformers/reaction-button.ts +37 -0
- package/src/codegen/domain/seed-component/transformers/segmented-control.ts +59 -0
- package/src/codegen/domain/seed-component/transformers/select-box.ts +82 -0
- package/src/codegen/domain/seed-component/transformers/skeleton.ts +52 -0
- package/src/codegen/domain/seed-component/transformers/snackbar.ts +23 -0
- package/src/codegen/domain/seed-component/transformers/switch.ts +31 -0
- package/src/codegen/domain/seed-component/transformers/tabs.ts +129 -0
- package/src/{component/handlers → codegen/domain/seed-component/transformers}/text-button.ts +16 -18
- package/src/codegen/domain/seed-component/transformers/text-field.ts +109 -0
- package/src/codegen/domain/seed-component/transformers/toggle-button.ts +47 -0
- package/src/codegen/domain/style.interface.ts +5 -0
- package/src/codegen/domain/style.repository.ts +23 -0
- package/src/codegen/domain/style.service.ts +38 -0
- package/src/codegen/domain/text.service.ts +62 -0
- package/src/codegen/domain/variable.interface.ts +18 -0
- package/src/codegen/domain/variable.repository.ts +44 -0
- package/src/codegen/domain/variable.service.ts +95 -0
- package/src/codegen/index.ts +13 -0
- package/src/index.ts +2 -2
- package/src/normalizer/from-plugin.ts +29 -28
- package/src/normalizer/from-rest.ts +5 -1
- package/src/normalizer/types.ts +80 -32
- package/src/utils/common.ts +19 -0
- package/src/utils/css.ts +13 -0
- package/src/utils/figma-variable.ts +13 -0
- package/src/component/handlers/action-button.ts +0 -66
- package/src/component/handlers/action-chip.ts +0 -71
- package/src/component/handlers/action-sheet.ts +0 -74
- package/src/component/handlers/avatar-stack.ts +0 -35
- package/src/component/handlers/avatar.ts +0 -37
- package/src/component/handlers/badge.ts +0 -20
- package/src/component/handlers/callout.ts +0 -87
- package/src/component/handlers/checkbox.ts +0 -32
- package/src/component/handlers/chip-tabs.ts +0 -51
- package/src/component/handlers/control-chip.ts +0 -75
- package/src/component/handlers/error-state.ts +0 -37
- package/src/component/handlers/extended-action-sheet.ts +0 -86
- package/src/component/handlers/extended-fab.ts +0 -24
- package/src/component/handlers/fab.ts +0 -17
- package/src/component/handlers/help-bubble.ts +0 -66
- package/src/component/handlers/identity-placeholder.ts +0 -16
- package/src/component/handlers/manner-temp-badge.ts +0 -17
- package/src/component/handlers/multiline-text-field.ts +0 -80
- package/src/component/handlers/progress-circle.ts +0 -49
- package/src/component/handlers/reaction-button.ts +0 -36
- package/src/component/handlers/segmented-control.ts +0 -51
- package/src/component/handlers/select-box.ts +0 -76
- package/src/component/handlers/skeleton.ts +0 -51
- package/src/component/handlers/snackbar.ts +0 -21
- package/src/component/handlers/switch.ts +0 -29
- package/src/component/handlers/tabs.ts +0 -107
- package/src/component/handlers/text-field.ts +0 -108
- package/src/component/handlers/toggle-button.ts +0 -44
- package/src/component/index.ts +0 -76
- package/src/generate-code.ts +0 -251
- package/src/icon.ts +0 -46
- package/src/layout.ts +0 -31
- package/src/props/color.ts +0 -78
- package/src/props/layout.ts +0 -292
- package/src/props/sizing.ts +0 -58
- package/src/props/text.ts +0 -21
- package/src/props/variable.ts +0 -66
- /package/src/{data → codegen/data}/__generated__/component-sets/action-button.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/action-button.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/action-chip.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/action-chip.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/action-sheet.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/action-sheet.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/avatar-stack.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/avatar-stack.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/avatar.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/avatar.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/badge.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/badge.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/bottom-navigation-global.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/bottom-navigation-global.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/bottom-navigation-kr.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/bottom-navigation-kr.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/bottom-sheet.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/bottom-sheet.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/callout.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/callout.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/checkbox.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/checkbox.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/chip-tablist.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/chip-tablist.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/control-chip.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/control-chip.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/divider.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/divider.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/error-state.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/error-state.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/extended-action-sheet.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/extended-action-sheet.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/extended-floating-action-button.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/extended-floating-action-button.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/floating-action-button.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/floating-action-button.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/help-bubble.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/help-bubble.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/identity-placeholder.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/identity-placeholder.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/index.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/index.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/inline-banner.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/inline-banner.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/main-tab-navigation-global.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/main-tab-navigation-global.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/main-tab-navigation-kr.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/main-tab-navigation-kr.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/manner-temp-badge.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/manner-temp-badge.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/manner-temp-bar.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/manner-temp-bar.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/manner-temp.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/manner-temp.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/multiline-text-field.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/multiline-text-field.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/progress-circle.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/progress-circle.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/radio.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/radio.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/range-slider.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/range-slider.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/reaction-button.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/reaction-button.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/segmented-control.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/segmented-control.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/select-box.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/select-box.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/skeleton.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/skeleton.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/slider.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/slider.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/snackbar.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/snackbar.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/standard-navigation.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/standard-navigation.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/switch.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/switch.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/tablist.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/tablist.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/template-bottom-fixed-bar.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/template-bottom-fixed-bar.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/template-button-group.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/template-button-group.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/template-chip-group.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/template-chip-group.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/template-select-box-group.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/template-select-box-group.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/template-top-navigation.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/template-top-navigation.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/text-button.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/text-button.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/text-field.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/text-field.mjs +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/toggle-button.d.ts +0 -0
- /package/src/{data → codegen/data}/__generated__/component-sets/toggle-button.mjs +0 -0
package/src/props/layout.ts
DELETED
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
NormalizedComponentNode,
|
|
3
|
-
NormalizedFrameNode,
|
|
4
|
-
NormalizedInstanceNode,
|
|
5
|
-
} from "../normalizer";
|
|
6
|
-
import { getLayoutVariableName, inferDimension, inferRadius } from "./variable";
|
|
7
|
-
|
|
8
|
-
// Basic handlers
|
|
9
|
-
type LayoutPropHandler = (
|
|
10
|
-
props: Pick<
|
|
11
|
-
NormalizedFrameNode,
|
|
12
|
-
| "layoutMode"
|
|
13
|
-
| "layoutWrap"
|
|
14
|
-
| "paddingLeft"
|
|
15
|
-
| "paddingRight"
|
|
16
|
-
| "paddingTop"
|
|
17
|
-
| "paddingBottom"
|
|
18
|
-
| "primaryAxisAlignItems"
|
|
19
|
-
| "counterAxisAlignItems"
|
|
20
|
-
| "primaryAxisSizingMode"
|
|
21
|
-
| "counterAxisSizingMode"
|
|
22
|
-
| "layoutGrow"
|
|
23
|
-
| "layoutAlign"
|
|
24
|
-
| "itemSpacing"
|
|
25
|
-
| "counterAxisSpacing"
|
|
26
|
-
| "boundVariables"
|
|
27
|
-
| "cornerRadius"
|
|
28
|
-
| "rectangleCornerRadii"
|
|
29
|
-
| "children"
|
|
30
|
-
>,
|
|
31
|
-
) => string | number | boolean | undefined;
|
|
32
|
-
|
|
33
|
-
const layoutPropHandlers = {
|
|
34
|
-
flexDirection: ({ layoutMode }) => (layoutMode === "HORIZONTAL" ? "row" : "column"),
|
|
35
|
-
justifyContent: ({ primaryAxisAlignItems }) => {
|
|
36
|
-
switch (primaryAxisAlignItems) {
|
|
37
|
-
case "MIN":
|
|
38
|
-
return "flexStart";
|
|
39
|
-
case "CENTER":
|
|
40
|
-
return "center";
|
|
41
|
-
case "MAX":
|
|
42
|
-
return "flexEnd";
|
|
43
|
-
case "SPACE_BETWEEN":
|
|
44
|
-
return "spaceBetween";
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
alignItems: ({ counterAxisAlignItems, children }) => {
|
|
48
|
-
const isStretch = children.every((child) => {
|
|
49
|
-
if (!("layoutAlign" in child)) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return child.layoutAlign === "STRETCH";
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
if (isStretch) {
|
|
57
|
-
return "stretch";
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
switch (counterAxisAlignItems) {
|
|
61
|
-
case "MIN":
|
|
62
|
-
return "flexStart";
|
|
63
|
-
case "CENTER":
|
|
64
|
-
return "center";
|
|
65
|
-
case "MAX":
|
|
66
|
-
return "flexEnd";
|
|
67
|
-
case "BASELINE":
|
|
68
|
-
return "baseline";
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
flexWrap: ({ layoutWrap }) => (layoutWrap === "WRAP" ? "wrap" : "nowrap"),
|
|
72
|
-
flexGrow: ({ layoutGrow }) => layoutGrow,
|
|
73
|
-
alignSelf: ({ layoutAlign }) => {
|
|
74
|
-
switch (layoutAlign) {
|
|
75
|
-
case "STRETCH":
|
|
76
|
-
return "stretch";
|
|
77
|
-
case "MIN":
|
|
78
|
-
return "flexStart";
|
|
79
|
-
case "CENTER":
|
|
80
|
-
return "center";
|
|
81
|
-
case "MAX":
|
|
82
|
-
return "flexEnd";
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
gap: ({ itemSpacing, boundVariables, primaryAxisAlignItems, children }) =>
|
|
86
|
-
children.length <= 1
|
|
87
|
-
? 0
|
|
88
|
-
: primaryAxisAlignItems === "SPACE_BETWEEN"
|
|
89
|
-
? 0
|
|
90
|
-
: boundVariables?.itemSpacing
|
|
91
|
-
? getLayoutVariableName(boundVariables.itemSpacing.id)
|
|
92
|
-
: inferDimension(itemSpacing ?? 0),
|
|
93
|
-
paddingTop: ({ paddingTop, boundVariables }) =>
|
|
94
|
-
boundVariables?.paddingTop
|
|
95
|
-
? getLayoutVariableName(boundVariables.paddingTop.id)
|
|
96
|
-
: inferDimension(paddingTop ?? 0),
|
|
97
|
-
paddingBottom: ({ paddingBottom, boundVariables }) =>
|
|
98
|
-
boundVariables?.paddingBottom
|
|
99
|
-
? getLayoutVariableName(boundVariables.paddingBottom.id)
|
|
100
|
-
: inferDimension(paddingBottom ?? 0),
|
|
101
|
-
paddingLeft: ({ paddingLeft, boundVariables }) =>
|
|
102
|
-
boundVariables?.paddingLeft
|
|
103
|
-
? getLayoutVariableName(boundVariables.paddingLeft.id)
|
|
104
|
-
: inferDimension(paddingLeft ?? 0),
|
|
105
|
-
paddingRight: ({ paddingRight, boundVariables }) =>
|
|
106
|
-
boundVariables?.paddingRight
|
|
107
|
-
? getLayoutVariableName(boundVariables.paddingRight.id)
|
|
108
|
-
: inferDimension(paddingRight ?? 0),
|
|
109
|
-
borderRadius: ({ cornerRadius, boundVariables }) => {
|
|
110
|
-
// If all corner radii are the same, use the first one
|
|
111
|
-
if (
|
|
112
|
-
cornerRadius &&
|
|
113
|
-
boundVariables?.bottomLeftRadius === boundVariables?.bottomRightRadius &&
|
|
114
|
-
boundVariables?.bottomLeftRadius === boundVariables?.topLeftRadius &&
|
|
115
|
-
boundVariables?.bottomLeftRadius === boundVariables?.topRightRadius
|
|
116
|
-
) {
|
|
117
|
-
return boundVariables?.bottomLeftRadius
|
|
118
|
-
? getLayoutVariableName(boundVariables.bottomLeftRadius.id)
|
|
119
|
-
: inferRadius(cornerRadius ?? 0);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// TODO: handle individual corner radii
|
|
123
|
-
return undefined;
|
|
124
|
-
},
|
|
125
|
-
borderTopLeftRadius: ({ rectangleCornerRadii, boundVariables }) =>
|
|
126
|
-
boundVariables?.topLeftRadius
|
|
127
|
-
? getLayoutVariableName(boundVariables.topLeftRadius.id)
|
|
128
|
-
: inferRadius(rectangleCornerRadii?.[0] ?? 0),
|
|
129
|
-
borderTopRightRadius: ({ rectangleCornerRadii, boundVariables }) =>
|
|
130
|
-
boundVariables?.topRightRadius
|
|
131
|
-
? getLayoutVariableName(boundVariables.topRightRadius.id)
|
|
132
|
-
: inferRadius(rectangleCornerRadii?.[1] ?? 0),
|
|
133
|
-
borderBottomLeftRadius: ({ rectangleCornerRadii, boundVariables }) =>
|
|
134
|
-
boundVariables?.bottomLeftRadius
|
|
135
|
-
? getLayoutVariableName(boundVariables.bottomLeftRadius.id)
|
|
136
|
-
: inferRadius(rectangleCornerRadii?.[2] ?? 0),
|
|
137
|
-
borderBottomRightRadius: ({ rectangleCornerRadii, boundVariables }) =>
|
|
138
|
-
boundVariables?.bottomRightRadius
|
|
139
|
-
? getLayoutVariableName(boundVariables.bottomRightRadius.id)
|
|
140
|
-
: inferRadius(rectangleCornerRadii?.[3] ?? 0),
|
|
141
|
-
} satisfies Record<string, LayoutPropHandler>;
|
|
142
|
-
|
|
143
|
-
type LayoutProps = keyof typeof layoutPropHandlers;
|
|
144
|
-
|
|
145
|
-
// Shorthand handlers
|
|
146
|
-
type LayoutShorthandHandler = (props: Record<LayoutProps, string | number | boolean | undefined>) =>
|
|
147
|
-
| {
|
|
148
|
-
value: string | number | boolean | undefined;
|
|
149
|
-
exclude: LayoutProps[];
|
|
150
|
-
}
|
|
151
|
-
| undefined;
|
|
152
|
-
|
|
153
|
-
const layoutShorthandHandlers = {
|
|
154
|
-
paddingX: ({ paddingLeft, paddingRight, paddingTop, paddingBottom }) => {
|
|
155
|
-
if (
|
|
156
|
-
paddingLeft === paddingRight &&
|
|
157
|
-
paddingTop === paddingBottom &&
|
|
158
|
-
paddingLeft === paddingTop
|
|
159
|
-
) {
|
|
160
|
-
return undefined;
|
|
161
|
-
}
|
|
162
|
-
if (paddingLeft === paddingRight) {
|
|
163
|
-
const value =
|
|
164
|
-
paddingLeft === "globalGutter" || paddingLeft === "betweenChips"
|
|
165
|
-
? `spacingX.${paddingLeft}`
|
|
166
|
-
: paddingLeft;
|
|
167
|
-
return {
|
|
168
|
-
value,
|
|
169
|
-
exclude: ["paddingLeft", "paddingRight"],
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
return undefined;
|
|
173
|
-
},
|
|
174
|
-
paddingY: ({ paddingLeft, paddingRight, paddingTop, paddingBottom }) => {
|
|
175
|
-
if (
|
|
176
|
-
paddingLeft === paddingRight &&
|
|
177
|
-
paddingTop === paddingBottom &&
|
|
178
|
-
paddingLeft === paddingTop
|
|
179
|
-
) {
|
|
180
|
-
return undefined;
|
|
181
|
-
}
|
|
182
|
-
if (paddingTop === paddingBottom) {
|
|
183
|
-
return {
|
|
184
|
-
value: paddingTop,
|
|
185
|
-
exclude: ["paddingTop", "paddingBottom"],
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
return undefined;
|
|
189
|
-
},
|
|
190
|
-
padding: ({ paddingLeft, paddingRight, paddingTop, paddingBottom }) => {
|
|
191
|
-
if (
|
|
192
|
-
paddingLeft === paddingRight &&
|
|
193
|
-
paddingTop === paddingBottom &&
|
|
194
|
-
paddingLeft === paddingTop
|
|
195
|
-
) {
|
|
196
|
-
return {
|
|
197
|
-
value: paddingLeft,
|
|
198
|
-
exclude: ["paddingLeft", "paddingRight", "paddingTop", "paddingBottom"],
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
return undefined;
|
|
202
|
-
},
|
|
203
|
-
} satisfies Record<string, LayoutShorthandHandler>;
|
|
204
|
-
|
|
205
|
-
type LayoutShorthandProps = keyof typeof layoutShorthandHandlers;
|
|
206
|
-
|
|
207
|
-
// Default values
|
|
208
|
-
const layoutPropDefaults: Record<string, string | number | boolean> = {
|
|
209
|
-
flexDirection: "row",
|
|
210
|
-
justifyContent: "flexStart",
|
|
211
|
-
alignItems: "stretch",
|
|
212
|
-
flexWrap: "nowrap",
|
|
213
|
-
flexGrow: 0,
|
|
214
|
-
alignSelf: "auto",
|
|
215
|
-
gap: 0,
|
|
216
|
-
padding: 0,
|
|
217
|
-
paddingX: 0,
|
|
218
|
-
paddingY: 0,
|
|
219
|
-
paddingBottom: 0,
|
|
220
|
-
paddingLeft: 0,
|
|
221
|
-
paddingRight: 0,
|
|
222
|
-
paddingTop: 0,
|
|
223
|
-
borderRadius: 0,
|
|
224
|
-
borderTopLeftRadius: 0,
|
|
225
|
-
borderTopRightRadius: 0,
|
|
226
|
-
borderBottomLeftRadius: 0,
|
|
227
|
-
borderBottomRightRadius: 0,
|
|
228
|
-
} satisfies Record<LayoutProps | LayoutShorthandProps, string | number | boolean>;
|
|
229
|
-
|
|
230
|
-
type FrameLikeNode = NormalizedFrameNode | NormalizedComponentNode | NormalizedInstanceNode;
|
|
231
|
-
|
|
232
|
-
export function createLayoutProps(
|
|
233
|
-
node: FrameLikeNode,
|
|
234
|
-
): Record<LayoutProps | LayoutShorthandProps, string | number | boolean> {
|
|
235
|
-
const boundVariables = node.boundVariables;
|
|
236
|
-
const children = node.children;
|
|
237
|
-
|
|
238
|
-
const autoLayoutProperties = {
|
|
239
|
-
layoutMode: node.layoutMode,
|
|
240
|
-
layoutWrap: node.layoutWrap,
|
|
241
|
-
paddingLeft: node.paddingLeft,
|
|
242
|
-
paddingRight: node.paddingRight,
|
|
243
|
-
paddingTop: node.paddingTop,
|
|
244
|
-
paddingBottom: node.paddingBottom,
|
|
245
|
-
primaryAxisAlignItems: node.primaryAxisAlignItems,
|
|
246
|
-
counterAxisAlignItems: node.counterAxisAlignItems,
|
|
247
|
-
primaryAxisSizingMode: node.primaryAxisSizingMode,
|
|
248
|
-
counterAxisSizingMode: node.counterAxisSizingMode,
|
|
249
|
-
layoutGrow: node.layoutGrow,
|
|
250
|
-
layoutAlign: node.layoutAlign,
|
|
251
|
-
itemSpacing: node.itemSpacing,
|
|
252
|
-
counterAxisSpacing: node.counterAxisSpacing,
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
const radiusProperties = {
|
|
256
|
-
cornerRadius: node.cornerRadius,
|
|
257
|
-
topLeftRadius: node.rectangleCornerRadii?.[0],
|
|
258
|
-
topRightRadius: node.rectangleCornerRadii?.[1],
|
|
259
|
-
bottomRightRadius: node.rectangleCornerRadii?.[2],
|
|
260
|
-
bottomLeftRadius: node.rectangleCornerRadii?.[3],
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
const result: Record<string, string | number | boolean> = {};
|
|
264
|
-
|
|
265
|
-
for (const [prop, handler] of Object.entries(layoutPropHandlers)) {
|
|
266
|
-
const value = handler({
|
|
267
|
-
...autoLayoutProperties,
|
|
268
|
-
...radiusProperties,
|
|
269
|
-
boundVariables,
|
|
270
|
-
children,
|
|
271
|
-
});
|
|
272
|
-
if (value !== undefined && value !== layoutPropDefaults[prop]) {
|
|
273
|
-
result[prop] = value;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
for (const [prop, handler] of Object.entries(layoutShorthandHandlers)) {
|
|
278
|
-
const shorthandResult = handler(result);
|
|
279
|
-
if (shorthandResult === undefined) {
|
|
280
|
-
continue;
|
|
281
|
-
}
|
|
282
|
-
const { value, exclude } = shorthandResult;
|
|
283
|
-
if (value !== undefined && value !== layoutPropDefaults[prop]) {
|
|
284
|
-
result[prop] = value;
|
|
285
|
-
for (const excludedProp of exclude) {
|
|
286
|
-
delete result[excludedProp];
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
return result;
|
|
292
|
-
}
|
package/src/props/sizing.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { NormalizedFrameNode } from "../normalizer";
|
|
2
|
-
import { getLayoutVariableName, inferDimension } from "./variable";
|
|
3
|
-
|
|
4
|
-
type SizingPropHandler = (
|
|
5
|
-
props: Pick<
|
|
6
|
-
NormalizedFrameNode,
|
|
7
|
-
"boundVariables" | "layoutSizingHorizontal" | "layoutSizingVertical" | "absoluteBoundingBox"
|
|
8
|
-
>,
|
|
9
|
-
) => string | number | boolean | undefined;
|
|
10
|
-
|
|
11
|
-
const sizingPropHandlers = {
|
|
12
|
-
height: ({ boundVariables, layoutSizingVertical, absoluteBoundingBox }) =>
|
|
13
|
-
layoutSizingVertical === "FIXED"
|
|
14
|
-
? boundVariables?.size?.y
|
|
15
|
-
? getLayoutVariableName(boundVariables.size.y.id)
|
|
16
|
-
: inferDimension(absoluteBoundingBox?.height ?? 0)
|
|
17
|
-
: undefined,
|
|
18
|
-
width: ({ boundVariables, layoutSizingHorizontal, absoluteBoundingBox }) =>
|
|
19
|
-
layoutSizingHorizontal === "FIXED"
|
|
20
|
-
? boundVariables?.size?.x
|
|
21
|
-
? getLayoutVariableName(boundVariables.size.x.id)
|
|
22
|
-
: inferDimension(absoluteBoundingBox?.width ?? 0)
|
|
23
|
-
: undefined,
|
|
24
|
-
} satisfies Record<string, SizingPropHandler>;
|
|
25
|
-
|
|
26
|
-
export type SizingProps = keyof typeof sizingPropHandlers;
|
|
27
|
-
|
|
28
|
-
export function createSizingProps(
|
|
29
|
-
node: Pick<
|
|
30
|
-
NormalizedFrameNode,
|
|
31
|
-
"boundVariables" | "layoutSizingHorizontal" | "layoutSizingVertical" | "absoluteBoundingBox"
|
|
32
|
-
>,
|
|
33
|
-
): Record<string, string | number | boolean> {
|
|
34
|
-
const boundVariables = node.boundVariables;
|
|
35
|
-
const layoutSizingHorizontal = node.layoutSizingHorizontal ?? "FIXED";
|
|
36
|
-
const layoutSizingVertical = node.layoutSizingVertical ?? "FIXED";
|
|
37
|
-
const absoluteBoundingBox = node.absoluteBoundingBox;
|
|
38
|
-
|
|
39
|
-
if (!boundVariables) {
|
|
40
|
-
return {};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const result: Record<string, string | number | boolean> = {};
|
|
44
|
-
|
|
45
|
-
for (const [prop, handler] of Object.entries(sizingPropHandlers)) {
|
|
46
|
-
const value = handler({
|
|
47
|
-
boundVariables,
|
|
48
|
-
layoutSizingHorizontal,
|
|
49
|
-
layoutSizingVertical,
|
|
50
|
-
absoluteBoundingBox,
|
|
51
|
-
});
|
|
52
|
-
if (value !== undefined) {
|
|
53
|
-
result[prop] = value;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return result;
|
|
58
|
-
}
|
package/src/props/text.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { NormalizedTextNode } from "../normalizer";
|
|
2
|
-
import { getTypographyVariableName } from "./variable";
|
|
3
|
-
|
|
4
|
-
// TODO: handle raw values
|
|
5
|
-
export function createTextProps(boundVariables: NormalizedTextNode["boundVariables"]) {
|
|
6
|
-
const fontSizeBoundVariables = boundVariables?.fontSize?.[0];
|
|
7
|
-
const fontStyleBoundVariables = boundVariables?.fontStyle?.[0];
|
|
8
|
-
const lineHeightBoundVariables = boundVariables?.lineHeight?.[0];
|
|
9
|
-
|
|
10
|
-
return {
|
|
11
|
-
fontSize: fontSizeBoundVariables
|
|
12
|
-
? getTypographyVariableName(fontSizeBoundVariables.id)
|
|
13
|
-
: undefined,
|
|
14
|
-
fontWeight: fontStyleBoundVariables
|
|
15
|
-
? getTypographyVariableName(fontStyleBoundVariables.id)
|
|
16
|
-
: undefined,
|
|
17
|
-
lineHeight: lineHeightBoundVariables
|
|
18
|
-
? getTypographyVariableName(lineHeightBoundVariables.id)
|
|
19
|
-
: undefined,
|
|
20
|
-
};
|
|
21
|
-
}
|
package/src/props/variable.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { vars } from "@seed-design/css/vars";
|
|
2
|
-
import { camelCase } from "change-case";
|
|
3
|
-
import { FIGMA_VARIABLES } from "../data/variables";
|
|
4
|
-
|
|
5
|
-
function sanitizeVariableId(id: string) {
|
|
6
|
-
return id.replace("VariableID:", "").split("/")[0]!;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function getNameFromSlashSeparatedVariableName(id: string | undefined) {
|
|
10
|
-
if (!id) return undefined;
|
|
11
|
-
|
|
12
|
-
const sanitizedId = sanitizeVariableId(id);
|
|
13
|
-
const variable = FIGMA_VARIABLES.find((v) => v.id === sanitizedId || v.key === sanitizedId);
|
|
14
|
-
|
|
15
|
-
if (!variable) return undefined;
|
|
16
|
-
|
|
17
|
-
const splits = variable.name.split("/");
|
|
18
|
-
|
|
19
|
-
const name = splits.pop() ?? "";
|
|
20
|
-
const group = splits.pop() ?? "";
|
|
21
|
-
|
|
22
|
-
switch (group) {
|
|
23
|
-
case "spacing-x":
|
|
24
|
-
case "spacing-y":
|
|
25
|
-
return `${camelCase(group)}.${camelCase(name)}`;
|
|
26
|
-
default:
|
|
27
|
-
return camelCase(name);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const getLayoutVariableName = getNameFromSlashSeparatedVariableName;
|
|
32
|
-
|
|
33
|
-
export const getTypographyVariableName = getNameFromSlashSeparatedVariableName;
|
|
34
|
-
|
|
35
|
-
export function getColorVariableName(id: string) {
|
|
36
|
-
const sanitizedId = sanitizeVariableId(id);
|
|
37
|
-
const variable = FIGMA_VARIABLES.find((v) => v.id === sanitizedId || v.key === sanitizedId);
|
|
38
|
-
|
|
39
|
-
if (!variable) return undefined;
|
|
40
|
-
|
|
41
|
-
const [group, name] = variable.name.split("/") as [string, string];
|
|
42
|
-
|
|
43
|
-
return `${camelCase(group, { mergeAmbiguousCharacters: true })}.${camelCase(name, { mergeAmbiguousCharacters: true })}`;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function inferDimension(value: number) {
|
|
47
|
-
if (value === 0) return 0;
|
|
48
|
-
|
|
49
|
-
const expectedDimensionVar = `x${Number.parseFloat((value / 4).toFixed(1))}`.replace(".", "_");
|
|
50
|
-
if (expectedDimensionVar in vars.$dimension) {
|
|
51
|
-
return expectedDimensionVar;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return `${value}px`;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function inferRadius(value: number) {
|
|
58
|
-
if (value === 0) return 0;
|
|
59
|
-
|
|
60
|
-
const expectedRadiusVar = `r${Number.parseFloat((value / 4).toFixed(1))}`.replace(".", "_");
|
|
61
|
-
if (expectedRadiusVar in vars.$radius) {
|
|
62
|
-
return expectedRadiusVar;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return `${value}px`;
|
|
66
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/{data → codegen/data}/__generated__/component-sets/bottom-navigation-global.d.ts
RENAMED
|
File without changes
|
/package/src/{data → codegen/data}/__generated__/component-sets/bottom-navigation-global.mjs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/{data → codegen/data}/__generated__/component-sets/extended-floating-action-button.d.ts
RENAMED
|
File without changes
|
/package/src/{data → codegen/data}/__generated__/component-sets/extended-floating-action-button.mjs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/{data → codegen/data}/__generated__/component-sets/main-tab-navigation-global.d.ts
RENAMED
|
File without changes
|
/package/src/{data → codegen/data}/__generated__/component-sets/main-tab-navigation-global.mjs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/{data → codegen/data}/__generated__/component-sets/template-bottom-fixed-bar.d.ts
RENAMED
|
File without changes
|
/package/src/{data → codegen/data}/__generated__/component-sets/template-bottom-fixed-bar.mjs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|