@dannote/figma-use 0.6.2 → 0.7.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.
- package/CHANGELOG.md +77 -1
- package/README.md +114 -256
- package/SKILL.md +82 -20
- package/dist/cli/index.js +3947 -380
- package/dist/proxy/index.js +8 -6
- package/package.json +8 -1
- package/packages/cli/src/render/component-set.tsx +7 -3
- package/packages/cli/src/render/components.tsx +16 -47
- package/packages/cli/src/render/icon.ts +163 -0
- package/packages/cli/src/render/index.ts +7 -1
- package/packages/cli/src/render/reconciler.ts +96 -34
- package/packages/cli/src/render/shorthands.ts +129 -0
- package/packages/cli/src/render/vars.ts +4 -5
- package/packages/plugin/dist/main.js +127 -33
package/SKILL.md
CHANGED
|
@@ -62,6 +62,8 @@ Output (unified diff format):
|
|
|
62
62
|
+opacity: 1
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
+
⚠️ **Don't forget space prefix on context lines** — `size: 48 40` will fail, ` size: 48 40` works.
|
|
66
|
+
|
|
65
67
|
### Apply patch (validates old values!)
|
|
66
68
|
```bash
|
|
67
69
|
# Dry run — preview changes
|
|
@@ -77,6 +79,14 @@ figma-use diff apply patch.diff --force
|
|
|
77
79
|
cat patch.diff | figma-use diff apply --stdin
|
|
78
80
|
```
|
|
79
81
|
|
|
82
|
+
### Visual diff (PNG)
|
|
83
|
+
```bash
|
|
84
|
+
figma-use diff visual --from <id1> --to <id2> --output diff.png
|
|
85
|
+
figma-use diff visual --from <id1> --to <id2> --output diff.png --threshold 0.05 # Stricter
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Red pixels show differences. Useful for verifying modifications.
|
|
89
|
+
|
|
80
90
|
### Workflow: Iterative design with critique
|
|
81
91
|
|
|
82
92
|
1. **Render initial design:**
|
|
@@ -111,46 +121,72 @@ figma-use node delete <id>
|
|
|
111
121
|
Use `render --stdin` with **pure JSX only**. No variables, no functions, no imports — just JSX tags:
|
|
112
122
|
|
|
113
123
|
```bash
|
|
114
|
-
echo '<Frame style={{
|
|
115
|
-
<Text style={{
|
|
116
|
-
<Text style={{
|
|
124
|
+
echo '<Frame style={{p: 24, gap: 16, flex: "col", bg: "#FFF", rounded: 12}}>
|
|
125
|
+
<Text style={{size: 24, weight: "bold", color: "#000"}}>Card Title</Text>
|
|
126
|
+
<Text style={{size: 14, color: "#666"}}>Description text here</Text>
|
|
117
127
|
</Frame>' | figma-use render --stdin
|
|
118
128
|
```
|
|
119
129
|
|
|
120
130
|
⚠️ **stdin does NOT support:** `const`, `let`, `function`, `defineComponent`, `defineComponentSet`, ternary operators, or any JavaScript logic. Only literal JSX.
|
|
121
131
|
|
|
122
|
-
**
|
|
132
|
+
⚠️ **When rendering multiple elements**, use `--x` and `--y` to position each render at different coordinates. Don't stack everything at (0, 0).
|
|
133
|
+
|
|
134
|
+
**Elements:** `Frame`, `Rectangle`, `Ellipse`, `Text`, `Line`, `Star`, `Polygon`, `Vector`, `Group`, `Icon`
|
|
135
|
+
|
|
136
|
+
**Icons (150k+ from Iconify):**
|
|
137
|
+
```bash
|
|
138
|
+
echo '<Frame style={{flex: "row", gap: 8, p: 16}}>
|
|
139
|
+
<Icon icon="mdi:home" size={24} color="#3B82F6" />
|
|
140
|
+
<Icon icon="lucide:star" size={24} color="#F59E0B" />
|
|
141
|
+
</Frame>' | figma-use render --stdin
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Style props (with shorthands):**
|
|
123
145
|
|
|
124
|
-
|
|
146
|
+
| Shorthand | Full | Values |
|
|
147
|
+
|-----------|------|--------|
|
|
148
|
+
| `w`, `h` | `width`, `height` | number |
|
|
149
|
+
| `bg` | `backgroundColor` | hex color |
|
|
150
|
+
| `rounded` | `borderRadius` | number |
|
|
151
|
+
| `p`, `pt`, `pr`, `pb`, `pl` | `padding*` | number |
|
|
152
|
+
| `px`, `py` | paddingLeft+Right, paddingTop+Bottom | number |
|
|
153
|
+
| `flex` | `flexDirection` | `"row"`, `"col"` |
|
|
154
|
+
| `justify` | `justifyContent` | `"start"`, `"end"`, `"center"`, `"between"`, `"evenly"` |
|
|
155
|
+
| `items` | `alignItems` | `"start"`, `"end"`, `"center"`, `"stretch"` |
|
|
156
|
+
| `size` | `fontSize` | number |
|
|
157
|
+
| `font` | `fontFamily` | string |
|
|
158
|
+
| `weight` | `fontWeight` | `"bold"`, number |
|
|
159
|
+
|
|
160
|
+
Also: `gap`, `opacity`, `color`, `borderColor`, `borderWidth`, `textAlign`, `x`, `y`
|
|
125
161
|
|
|
126
162
|
### Auto-Layout (Hug Contents)
|
|
127
163
|
|
|
128
|
-
Frames with `
|
|
164
|
+
Frames with `flex` automatically calculate size from children:
|
|
129
165
|
|
|
130
166
|
```bash
|
|
131
167
|
# Height calculated as 50 + 10 (gap) + 30 = 90
|
|
132
|
-
echo '<Frame style={{
|
|
133
|
-
<Frame style={{
|
|
134
|
-
<Frame style={{
|
|
168
|
+
echo '<Frame style={{w: 200, flex: "col", gap: 10}}>
|
|
169
|
+
<Frame style={{w: 200, h: 50, bg: "#00FF00"}} />
|
|
170
|
+
<Frame style={{w: 200, h: 30, bg: "#0000FF"}} />
|
|
135
171
|
</Frame>' | figma-use render --stdin
|
|
136
172
|
```
|
|
137
173
|
|
|
138
|
-
**Limitation:** Row layout without explicit width collapses to 1×1 — always set `
|
|
174
|
+
**Limitation:** Row layout without explicit width collapses to 1×1 — always set `w` on row containers
|
|
139
175
|
|
|
140
176
|
### Buttons Example (3 sizes)
|
|
141
177
|
|
|
142
178
|
Since stdin doesn't support variables, write out each variant explicitly:
|
|
143
179
|
|
|
144
180
|
```bash
|
|
145
|
-
echo '<Frame name="Buttons" style={{gap: 16,
|
|
146
|
-
<Frame name="Small" style={{
|
|
147
|
-
<Text style={{
|
|
181
|
+
echo '<Frame name="Buttons" style={{gap: 16, flex: "row", p: 24}}>
|
|
182
|
+
<Frame name="Small" style={{px: 12, py: 6, bg: "#3B82F6", rounded: 6, flex: "row", justify: "center", items: "center"}}>
|
|
183
|
+
<Text style={{size: 12, color: "#FFF"}}>Button</Text>
|
|
148
184
|
</Frame>
|
|
149
|
-
<Frame name="Medium" style={{
|
|
150
|
-
<Text style={{
|
|
185
|
+
<Frame name="Medium" style={{px: 16, py: 8, bg: "#3B82F6", rounded: 6, flex: "row", justify: "center", items: "center"}}>
|
|
186
|
+
<Text style={{size: 14, color: "#FFF"}}>Button</Text>
|
|
151
187
|
</Frame>
|
|
152
|
-
<Frame name="Large" style={{
|
|
153
|
-
<Text style={{
|
|
188
|
+
<Frame name="Large" style={{px: 24, py: 12, bg: "#3B82F6", rounded: 6, flex: "row", justify: "center", items: "center"}}>
|
|
189
|
+
<Text style={{size: 16, color: "#FFF"}}>Button</Text>
|
|
154
190
|
</Frame>
|
|
155
191
|
</Frame>' | figma-use render --stdin
|
|
156
192
|
```
|
|
@@ -178,6 +214,7 @@ For proper Figma ComponentSets with variant properties, create a `.figma.tsx` fi
|
|
|
178
214
|
```bash
|
|
179
215
|
figma-use render --examples # Full API reference
|
|
180
216
|
figma-use render ./MyComponent.figma.tsx
|
|
217
|
+
figma-use render ./MyComponent.figma.tsx --x 100 --y 200 # Position at coordinates
|
|
181
218
|
```
|
|
182
219
|
|
|
183
220
|
---
|
|
@@ -191,10 +228,14 @@ figma-use create page "Page Name"
|
|
|
191
228
|
figma-use create frame --width 400 --height 300 --fill "#FFF" --radius 12 --layout VERTICAL --gap 16
|
|
192
229
|
figma-use create rect --width 100 --height 50 --fill "#FF0000" --radius 8
|
|
193
230
|
figma-use create ellipse --width 80 --height 80 --fill "#00FF00"
|
|
194
|
-
figma-use create text --text "Hello" --
|
|
231
|
+
figma-use create text --text "Hello" --font-size 24 --fill "#000"
|
|
195
232
|
figma-use create line --length 100 --stroke "#000"
|
|
233
|
+
figma-use create icon mdi:home --size 24 --color "#000" # Iconify icon
|
|
234
|
+
figma-use create icon lucide:star --size 48 --component # as Figma component
|
|
196
235
|
```
|
|
197
236
|
|
|
237
|
+
**Icons:** 150k+ from Iconify — `mdi:*`, `lucide:*`, `heroicons:*`, `tabler:*`, `fa-solid:*`, `ph:*`, etc. Browse: https://icon-sets.iconify.design/
|
|
238
|
+
|
|
198
239
|
### Query
|
|
199
240
|
|
|
200
241
|
```bash
|
|
@@ -241,8 +282,9 @@ figma-use export selection --output selection.png
|
|
|
241
282
|
### Navigate
|
|
242
283
|
|
|
243
284
|
```bash
|
|
244
|
-
figma-use page
|
|
245
|
-
figma-use page
|
|
285
|
+
figma-use page current # Show current page
|
|
286
|
+
figma-use page list # List all pages
|
|
287
|
+
figma-use page set "Page Name" # Switch page
|
|
246
288
|
figma-use viewport zoom-to-fit <ids...>
|
|
247
289
|
figma-use viewport get
|
|
248
290
|
figma-use viewport set --x 100 --y 200 --zoom 1.5
|
|
@@ -262,6 +304,14 @@ figma-use style list
|
|
|
262
304
|
figma-use style create-paint "Brand/Primary" --color "#E11D48"
|
|
263
305
|
```
|
|
264
306
|
|
|
307
|
+
**Variable references in CLI:** Use `var:Name` or `$Name` in any color option (`--fill`, `--stroke`, `--color`):
|
|
308
|
+
```bash
|
|
309
|
+
figma-use create rect --x 0 --y 0 --width 100 --height 100 --fill 'var:Primary'
|
|
310
|
+
figma-use create icon mdi:home --color '$Brand/Accent'
|
|
311
|
+
figma-use set fill <id> 'var:Colors/Primary'
|
|
312
|
+
figma-use set stroke <id> '$Brand/Border'
|
|
313
|
+
```
|
|
314
|
+
|
|
265
315
|
### Fonts
|
|
266
316
|
|
|
267
317
|
```bash
|
|
@@ -318,6 +368,18 @@ figma-use export node <id> --scale 0.5 --output /tmp/check.png # Overview
|
|
|
318
368
|
figma-use export node <id> --scale 2 --output /tmp/detail.png # Details
|
|
319
369
|
```
|
|
320
370
|
|
|
371
|
+
For modifications, use visual diff to highlight changes:
|
|
372
|
+
|
|
373
|
+
```bash
|
|
374
|
+
# Before modifying, export original
|
|
375
|
+
figma-use export node <id> --output /tmp/before.png
|
|
376
|
+
|
|
377
|
+
# After changes, compare visually
|
|
378
|
+
figma-use diff visual --from <original-id> --to <modified-id> --output /tmp/diff.png
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
Red pixels = differences. Use `--threshold 0.05` for stricter comparison.
|
|
382
|
+
|
|
321
383
|
### Copying Elements Between Pages
|
|
322
384
|
|
|
323
385
|
`node clone` creates a copy in the same parent. To move to another page:
|