@seed-design/figma 1.0.7 → 1.1.0
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.
|
@@ -3073,8 +3073,13 @@ const createActionButtonHandler = (ctx)=>defineComponentHandler(actionButton.key
|
|
|
3073
3073
|
return createLocalSnippetElement$w("ActionButton", commonProps, children);
|
|
3074
3074
|
});
|
|
3075
3075
|
const ACTION_BUTTON_GHOST_BUTTON_KEY = "ea69291fb4d76217419f3d9613ae16aadafb56a5";
|
|
3076
|
-
const createActionButtonGhostHandler = (ctx)=>defineComponentHandler(ACTION_BUTTON_GHOST_BUTTON_KEY, (
|
|
3076
|
+
const createActionButtonGhostHandler = (ctx)=>defineComponentHandler(ACTION_BUTTON_GHOST_BUTTON_KEY, (node)=>{
|
|
3077
|
+
const props = node.componentProperties;
|
|
3077
3078
|
const states = props.State.value.split("-");
|
|
3079
|
+
const buttonWrapperNode = findOne(node, (n)=>n.type === "FRAME" && n.layoutPositioning !== "ABSOLUTE");
|
|
3080
|
+
const labelNode = buttonWrapperNode ? findOne(buttonWrapperNode, (n)=>n.type === "TEXT") : undefined;
|
|
3081
|
+
const color = labelNode ? ctx.valueResolver.getFormattedValue.textFill(labelNode) : null;
|
|
3082
|
+
const fontWeight = labelNode ? ctx.valueResolver.getFormattedValue.fontWeight(labelNode) : null;
|
|
3078
3083
|
const { layout, children } = tsPattern.match(props.Layout.value).with("Icon Only", ()=>({
|
|
3079
3084
|
layout: "iconOnly",
|
|
3080
3085
|
children: [
|
|
@@ -3112,6 +3117,12 @@ const createActionButtonGhostHandler = (ctx)=>defineComponentHandler(ACTION_BUTT
|
|
|
3112
3117
|
size: handleSizeProp(props.Size.value),
|
|
3113
3118
|
variant: "ghost",
|
|
3114
3119
|
layout,
|
|
3120
|
+
...color && {
|
|
3121
|
+
color
|
|
3122
|
+
},
|
|
3123
|
+
...fontWeight && {
|
|
3124
|
+
fontWeight
|
|
3125
|
+
},
|
|
3115
3126
|
...props.Bleed.value === "true" && {
|
|
3116
3127
|
bleedX: "asPadding",
|
|
3117
3128
|
bleedY: "asPadding"
|
|
@@ -3073,8 +3073,13 @@ const createActionButtonHandler = (ctx)=>defineComponentHandler(actionButton.key
|
|
|
3073
3073
|
return createLocalSnippetElement$w("ActionButton", commonProps, children);
|
|
3074
3074
|
});
|
|
3075
3075
|
const ACTION_BUTTON_GHOST_BUTTON_KEY = "ea69291fb4d76217419f3d9613ae16aadafb56a5";
|
|
3076
|
-
const createActionButtonGhostHandler = (ctx)=>defineComponentHandler(ACTION_BUTTON_GHOST_BUTTON_KEY, (
|
|
3076
|
+
const createActionButtonGhostHandler = (ctx)=>defineComponentHandler(ACTION_BUTTON_GHOST_BUTTON_KEY, (node)=>{
|
|
3077
|
+
const props = node.componentProperties;
|
|
3077
3078
|
const states = props.State.value.split("-");
|
|
3079
|
+
const buttonWrapperNode = findOne(node, (n)=>n.type === "FRAME" && n.layoutPositioning !== "ABSOLUTE");
|
|
3080
|
+
const labelNode = buttonWrapperNode ? findOne(buttonWrapperNode, (n)=>n.type === "TEXT") : undefined;
|
|
3081
|
+
const color = labelNode ? ctx.valueResolver.getFormattedValue.textFill(labelNode) : null;
|
|
3082
|
+
const fontWeight = labelNode ? ctx.valueResolver.getFormattedValue.fontWeight(labelNode) : null;
|
|
3078
3083
|
const { layout, children } = match(props.Layout.value).with("Icon Only", ()=>({
|
|
3079
3084
|
layout: "iconOnly",
|
|
3080
3085
|
children: [
|
|
@@ -3112,6 +3117,12 @@ const createActionButtonGhostHandler = (ctx)=>defineComponentHandler(ACTION_BUTT
|
|
|
3112
3117
|
size: handleSizeProp(props.Size.value),
|
|
3113
3118
|
variant: "ghost",
|
|
3114
3119
|
layout,
|
|
3120
|
+
...color && {
|
|
3121
|
+
color
|
|
3122
|
+
},
|
|
3123
|
+
...fontWeight && {
|
|
3124
|
+
fontWeight
|
|
3125
|
+
},
|
|
3115
3126
|
...props.Bleed.value === "true" && {
|
|
3116
3127
|
bleedX: "asPadding",
|
|
3117
3128
|
bleedY: "asPadding"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seed-design/figma",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/daangn/seed-design.git",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"sync-entities": "rm -rf src/entities/data/__generated__ && bun figma-extractor src/entities/data/__generated__"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@seed-design/css": "1.0
|
|
42
|
+
"@seed-design/css": "1.1.0",
|
|
43
43
|
"change-case": "^5.4.4",
|
|
44
44
|
"ts-pattern": "^5.7.0"
|
|
45
45
|
},
|
|
@@ -9,6 +9,8 @@ import type {
|
|
|
9
9
|
} from "@/codegen/component-properties";
|
|
10
10
|
import { handleSizeProp } from "../size";
|
|
11
11
|
import { createLocalSnippetHelper, createSeedReactElement } from "../../element-factories";
|
|
12
|
+
import { findOne } from "@/utils/figma-node";
|
|
13
|
+
import type { NormalizedTextNode } from "@/normalizer";
|
|
12
14
|
|
|
13
15
|
const { createLocalSnippetElement } = createLocalSnippetHelper("action-button");
|
|
14
16
|
|
|
@@ -70,60 +72,73 @@ export const createActionButtonHandler = (ctx: ComponentHandlerDeps) =>
|
|
|
70
72
|
const ACTION_BUTTON_GHOST_BUTTON_KEY = "ea69291fb4d76217419f3d9613ae16aadafb56a5";
|
|
71
73
|
|
|
72
74
|
export const createActionButtonGhostHandler = (ctx: ComponentHandlerDeps) =>
|
|
73
|
-
defineComponentHandler<ActionButtonGhostProperties>(
|
|
74
|
-
|
|
75
|
-
({ componentProperties: props }) => {
|
|
76
|
-
const states = props.State.value.split("-");
|
|
75
|
+
defineComponentHandler<ActionButtonGhostProperties>(ACTION_BUTTON_GHOST_BUTTON_KEY, (node) => {
|
|
76
|
+
const props = node.componentProperties;
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
.with("Icon Only", () => ({
|
|
80
|
-
layout: "iconOnly",
|
|
81
|
-
children: [
|
|
82
|
-
createSeedReactElement("Icon", {
|
|
83
|
-
svg: ctx.iconHandler.transform(props["Icon#30525:15"]),
|
|
84
|
-
}),
|
|
85
|
-
],
|
|
86
|
-
}))
|
|
87
|
-
.with("Icon First", () => ({
|
|
88
|
-
layout: "withText",
|
|
89
|
-
children: [
|
|
90
|
-
createSeedReactElement("PrefixIcon", {
|
|
91
|
-
svg: ctx.iconHandler.transform(props["Prefix Icon#30511:3"]),
|
|
92
|
-
}),
|
|
93
|
-
props["Label#30511:2"].value,
|
|
94
|
-
],
|
|
95
|
-
}))
|
|
96
|
-
.with("Icon Last", () => ({
|
|
97
|
-
layout: "withText",
|
|
98
|
-
children: [
|
|
99
|
-
props["Label#30511:2"].value,
|
|
100
|
-
createSeedReactElement("SuffixIcon", {
|
|
101
|
-
svg: ctx.iconHandler.transform(props["Suffix Icon#30525:0"]),
|
|
102
|
-
}),
|
|
103
|
-
],
|
|
104
|
-
}))
|
|
105
|
-
.with("Text Only", () => ({
|
|
106
|
-
layout: "withText",
|
|
107
|
-
children: props["Label#30511:2"].value,
|
|
108
|
-
}))
|
|
109
|
-
.exhaustive();
|
|
78
|
+
const states = props.State.value.split("-");
|
|
110
79
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
...(states.includes("Loading") && {
|
|
116
|
-
loading: true,
|
|
117
|
-
}),
|
|
118
|
-
size: handleSizeProp(props.Size.value),
|
|
119
|
-
variant: "ghost",
|
|
120
|
-
layout,
|
|
121
|
-
...(props.Bleed.value === "true" && {
|
|
122
|
-
bleedX: "asPadding",
|
|
123
|
-
bleedY: "asPadding",
|
|
124
|
-
}),
|
|
125
|
-
};
|
|
80
|
+
const buttonWrapperNode = findOne(
|
|
81
|
+
node,
|
|
82
|
+
(n) => n.type === "FRAME" && n.layoutPositioning !== "ABSOLUTE",
|
|
83
|
+
);
|
|
126
84
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
85
|
+
const labelNode = buttonWrapperNode
|
|
86
|
+
? (findOne(buttonWrapperNode, (n) => n.type === "TEXT") as NormalizedTextNode | undefined)
|
|
87
|
+
: undefined;
|
|
88
|
+
|
|
89
|
+
const color = labelNode ? ctx.valueResolver.getFormattedValue.textFill(labelNode) : null;
|
|
90
|
+
const fontWeight = labelNode ? ctx.valueResolver.getFormattedValue.fontWeight(labelNode) : null;
|
|
91
|
+
|
|
92
|
+
const { layout, children } = match(props.Layout.value)
|
|
93
|
+
.with("Icon Only", () => ({
|
|
94
|
+
layout: "iconOnly",
|
|
95
|
+
children: [
|
|
96
|
+
createSeedReactElement("Icon", {
|
|
97
|
+
svg: ctx.iconHandler.transform(props["Icon#30525:15"]),
|
|
98
|
+
}),
|
|
99
|
+
],
|
|
100
|
+
}))
|
|
101
|
+
.with("Icon First", () => ({
|
|
102
|
+
layout: "withText",
|
|
103
|
+
children: [
|
|
104
|
+
createSeedReactElement("PrefixIcon", {
|
|
105
|
+
svg: ctx.iconHandler.transform(props["Prefix Icon#30511:3"]),
|
|
106
|
+
}),
|
|
107
|
+
props["Label#30511:2"].value,
|
|
108
|
+
],
|
|
109
|
+
}))
|
|
110
|
+
.with("Icon Last", () => ({
|
|
111
|
+
layout: "withText",
|
|
112
|
+
children: [
|
|
113
|
+
props["Label#30511:2"].value,
|
|
114
|
+
createSeedReactElement("SuffixIcon", {
|
|
115
|
+
svg: ctx.iconHandler.transform(props["Suffix Icon#30525:0"]),
|
|
116
|
+
}),
|
|
117
|
+
],
|
|
118
|
+
}))
|
|
119
|
+
.with("Text Only", () => ({
|
|
120
|
+
layout: "withText",
|
|
121
|
+
children: props["Label#30511:2"].value,
|
|
122
|
+
}))
|
|
123
|
+
.exhaustive();
|
|
124
|
+
|
|
125
|
+
const commonProps = {
|
|
126
|
+
...(states.includes("Disabled") && {
|
|
127
|
+
disabled: true,
|
|
128
|
+
}),
|
|
129
|
+
...(states.includes("Loading") && {
|
|
130
|
+
loading: true,
|
|
131
|
+
}),
|
|
132
|
+
size: handleSizeProp(props.Size.value),
|
|
133
|
+
variant: "ghost",
|
|
134
|
+
layout,
|
|
135
|
+
...(color && { color }),
|
|
136
|
+
...(fontWeight && { fontWeight }),
|
|
137
|
+
...(props.Bleed.value === "true" && {
|
|
138
|
+
bleedX: "asPadding",
|
|
139
|
+
bleedY: "asPadding",
|
|
140
|
+
}),
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
return createLocalSnippetElement("ActionButton", commonProps, children);
|
|
144
|
+
});
|