@promptui-lib/figma-parser 0.1.0 → 0.1.2

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.
Files changed (2) hide show
  1. package/README.md +416 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,416 @@
1
+ <p align="center">
2
+ <img src="./logo.png" alt="PromptUI Logo" width="200" />
3
+ </p>
4
+
5
+ <h1 align="center">PromptUI</h1>
6
+
7
+ <p align="center">
8
+ <a href="https://www.npmjs.com/package/@promptui-lib/cli"><img src="https://img.shields.io/npm/v/@promptui-lib/cli.svg" alt="npm version" /></a>
9
+ <a href="https://www.npmjs.com/package/@promptui-lib/cli"><img src="https://img.shields.io/npm/dm/@promptui-lib/cli.svg" alt="npm downloads" /></a>
10
+ <img src="https://img.shields.io/badge/license-proprietary-red.svg" alt="license" />
11
+ </p>
12
+
13
+ <p align="center">
14
+ <strong>Transform Figma designs into production-ready code in seconds.</strong>
15
+ </p>
16
+
17
+ <p align="center">
18
+ 100% deterministic. No AI. Same input = same output, always.
19
+ </p>
20
+
21
+ ---
22
+
23
+ ## What is it?
24
+
25
+ **PromptUI** is a library that automatically converts your Figma designs into clean, production-ready code.
26
+
27
+ Supports multiple frameworks:
28
+ - **React + SCSS** (BEM methodology)
29
+ - **Material UI** (MUI)
30
+ - **Tailwind CSS**
31
+ - **Bootstrap**
32
+ - **Flutter** (Dart StatelessWidgets)
33
+ - **SwiftUI** (iOS/macOS Views)
34
+
35
+ ---
36
+
37
+ ## Installation
38
+
39
+ ```bash
40
+ npm install -g @promptui-lib/cli
41
+ ```
42
+
43
+ ---
44
+
45
+ ## How It Works
46
+
47
+ ### 1. Mark your components in Figma
48
+
49
+ In Figma, add `#` at the beginning of frame names you want to export:
50
+
51
+ ```
52
+ #Button → Will be exported as component
53
+ #CardProduct → Will be exported as component
54
+ #HeaderNav → Will be exported as component
55
+ Button → Ignored (no #)
56
+ ```
57
+
58
+ ### 2. Configure the project
59
+
60
+ ```bash
61
+ npx @promptui-lib/cli init
62
+ ```
63
+
64
+ Set your credentials:
65
+
66
+ ```bash
67
+ export FIGMA_TOKEN=your_token_here
68
+ export FIGMA_FILE_ID=file_id_here
69
+ ```
70
+
71
+ ### 3. Generate components
72
+
73
+ ```bash
74
+ # React + SCSS
75
+ npx @promptui-lib/cli generate
76
+
77
+ # Bootstrap
78
+ npx @promptui-lib/cli generate bootstrap
79
+
80
+ # Material UI
81
+ npx @promptui-lib/cli generate mui
82
+
83
+ # Tailwind CSS
84
+ npx @promptui-lib/cli generate tailwind
85
+
86
+ # Flutter
87
+ npx @promptui-lib/cli generate flutter
88
+
89
+ # SwiftUI
90
+ npx @promptui-lib/cli generate swiftui
91
+ ```
92
+
93
+ ---
94
+
95
+ ## Examples
96
+
97
+ ### Example 1: Button with React + SCSS
98
+
99
+ **In Figma:** Frame named `#Button`
100
+
101
+ ```
102
+ #Button (Frame)
103
+ ├── Padding: 12px 24px
104
+ ├── Background: #3B82F6
105
+ ├── Border Radius: 8px
106
+ └── label (Text: "Click me")
107
+ ```
108
+
109
+ **Command:**
110
+ ```bash
111
+ npx @promptui-lib/cli generate
112
+ ```
113
+
114
+ **Result:**
115
+
116
+ ```tsx
117
+ // src/components/atoms/Button/button.tsx
118
+ import type { ReactNode } from 'react';
119
+ import './button.scss';
120
+
121
+ export interface IButtonProps {
122
+ children?: ReactNode;
123
+ className?: string;
124
+ }
125
+
126
+ export const Button = ({ children, className = '' }: IButtonProps) => {
127
+ return (
128
+ <button className={`button ${className}`.trim()}>
129
+ <span className="button__label">{children}</span>
130
+ </button>
131
+ );
132
+ };
133
+ ```
134
+
135
+ ```scss
136
+ // src/components/atoms/Button/button.scss
137
+ .button {
138
+ display: flex;
139
+ align-items: center;
140
+ justify-content: center;
141
+ padding: $spacing-sm $spacing-lg;
142
+ background-color: $color-primary;
143
+ border-radius: $radius-medium;
144
+
145
+ &__label {
146
+ color: $color-text-inverse;
147
+ font-weight: $font-weight-medium;
148
+ }
149
+ }
150
+ ```
151
+
152
+ ---
153
+
154
+ ### Example 2: Card with Bootstrap
155
+
156
+ **In Figma:** Frame named `#CardProduct`
157
+
158
+ ```
159
+ #CardProduct (Frame)
160
+ ├── image (Rectangle)
161
+ ├── content (Frame)
162
+ │ ├── title (Text: "Product Name")
163
+ │ ├── description (Text: "Lorem ipsum...")
164
+ │ └── price (Text: "$99.00")
165
+ └── button (Instance of #Button)
166
+ ```
167
+
168
+ **Command:**
169
+ ```bash
170
+ npx @promptui-lib/cli generate bootstrap
171
+ ```
172
+
173
+ **Result:**
174
+
175
+ ```tsx
176
+ // src/components/molecules/CardProduct/card-product.tsx
177
+ import type { ReactNode } from 'react';
178
+
179
+ export interface ICardProductProps {
180
+ children?: ReactNode;
181
+ className?: string;
182
+ }
183
+
184
+ export const CardProduct = ({ children, className = '' }: ICardProductProps) => {
185
+ return (
186
+ <div className={`card ${className}`.trim()}>
187
+ <img className="card-img-top" alt="Product" />
188
+ <div className="card-body">
189
+ <h5 className="card-title fw-bold">Product Name</h5>
190
+ <p className="card-text text-muted">Lorem ipsum...</p>
191
+ <p className="h4 text-primary fw-bold">$99.00</p>
192
+ <button className="btn btn-primary w-100">Buy Now</button>
193
+ </div>
194
+ </div>
195
+ );
196
+ };
197
+ ```
198
+
199
+ ---
200
+
201
+ ### Example 3: Header with Tailwind CSS
202
+
203
+ **In Figma:** Frame named `#HeaderNav`
204
+
205
+ **Command:**
206
+ ```bash
207
+ npx @promptui-lib/cli generate tailwind
208
+ ```
209
+
210
+ **Result:**
211
+
212
+ ```tsx
213
+ // src/components/organisms/HeaderNav/header-nav.tsx
214
+ export const HeaderNav = ({ className = '' }: IHeaderNavProps) => {
215
+ return (
216
+ <header className={`flex items-center justify-between px-6 py-4 bg-white shadow-sm ${className}`.trim()}>
217
+ <div className="flex items-center gap-2">
218
+ <img src="/logo.svg" className="h-8 w-8" alt="Logo" />
219
+ <span className="text-xl font-bold text-gray-900">Brand</span>
220
+ </div>
221
+ <nav className="flex items-center gap-8">
222
+ <a className="text-gray-600 hover:text-gray-900">Home</a>
223
+ <a className="text-gray-600 hover:text-gray-900">Products</a>
224
+ <a className="text-gray-600 hover:text-gray-900">About</a>
225
+ </nav>
226
+ <button className="px-4 py-2 bg-blue-500 text-white rounded-lg">
227
+ Sign In
228
+ </button>
229
+ </header>
230
+ );
231
+ };
232
+ ```
233
+
234
+ ---
235
+
236
+ ### Example 4: Button with Flutter
237
+
238
+ **In Figma:** Frame named `#Button`
239
+
240
+ **Command:**
241
+ ```bash
242
+ npx @promptui-lib/cli generate flutter
243
+ ```
244
+
245
+ **Result:**
246
+
247
+ ```dart
248
+ /// Button
249
+ /// Generated by PromptUI (Flutter)
250
+
251
+ import 'package:flutter/material.dart';
252
+
253
+ class Button extends StatelessWidget {
254
+ const Button({super.key});
255
+
256
+ @override
257
+ Widget build(BuildContext context) {
258
+ return Container(
259
+ padding: EdgeInsets.symmetric(vertical: 8, horizontal: 24),
260
+ decoration: BoxDecoration(
261
+ color: Theme.of(context).primaryColor,
262
+ borderRadius: BorderRadius.circular(8),
263
+ ),
264
+ child: Text('Click me'),
265
+ );
266
+ }
267
+ }
268
+ ```
269
+
270
+ ---
271
+
272
+ ### Example 5: Button with SwiftUI
273
+
274
+ **In Figma:** Frame named `#Button`
275
+
276
+ **Command:**
277
+ ```bash
278
+ npx @promptui-lib/cli generate swiftui
279
+ ```
280
+
281
+ **Result:**
282
+
283
+ ```swift
284
+ /// Button
285
+ /// Generated by PromptUI (SwiftUI)
286
+
287
+ import SwiftUI
288
+
289
+ struct Button: View {
290
+ var body: some View {
291
+ Text("Click me")
292
+ .padding(.horizontal, 24)
293
+ .padding(.vertical, 8)
294
+ .background(.blue)
295
+ .foregroundColor(.white)
296
+ .cornerRadius(8)
297
+ }
298
+ }
299
+
300
+ #Preview {
301
+ Button()
302
+ }
303
+ ```
304
+
305
+ ---
306
+
307
+ ## Commands
308
+
309
+ | Command | Description |
310
+ |---------|-------------|
311
+ | `npx @promptui-lib/cli init` | Configure the project |
312
+ | `npx @promptui-lib/cli generate` | Generate components (React + SCSS) |
313
+ | `npx @promptui-lib/cli generate bootstrap` | Generate with Bootstrap |
314
+ | `npx @promptui-lib/cli generate mui` | Generate with Material UI |
315
+ | `npx @promptui-lib/cli generate tailwind` | Generate with Tailwind CSS |
316
+ | `npx @promptui-lib/cli generate flutter` | Generate with Flutter/Dart |
317
+ | `npx @promptui-lib/cli generate swiftui` | Generate with SwiftUI |
318
+ | `npx @promptui-lib/cli sync tokens` | Sync design tokens |
319
+
320
+ ## Options
321
+
322
+ | Option | Description |
323
+ |--------|-------------|
324
+ | `-p, --preview` | Preview without saving |
325
+ | `-o, --output <dir>` | Output directory |
326
+ | `-f, --force` | Overwrite existing files |
327
+
328
+ ---
329
+
330
+ ## Atomic Design
331
+
332
+ Components are automatically organized:
333
+
334
+ | Layer | Description | Examples |
335
+ |-------|-------------|----------|
336
+ | **atoms** | Simple components | Button, Input, Label, Icon |
337
+ | **molecules** | Medium compositions | Card, SearchBar, FormField |
338
+ | **organisms** | Complex compositions | Header, Footer, Sidebar |
339
+
340
+ ---
341
+
342
+ ## Configuration
343
+
344
+ Create `promptui.config.json`:
345
+
346
+ ```json
347
+ {
348
+ "figma": {
349
+ "fileId": "your-file-id"
350
+ },
351
+ "output": {
352
+ "basePath": "src/components"
353
+ }
354
+ }
355
+ ```
356
+
357
+ ---
358
+
359
+ ## For Designers
360
+
361
+ ### Figma Rules
362
+
363
+ 1. **`#` prefix** - Add to frame name to export
364
+ 2. **Auto Layout** - Always use to maintain structure
365
+ 3. **Descriptive names** - `title`, `content`, not "Frame 1"
366
+ 4. **PascalCase** - `#ButtonPrimary`, not `#button-primary`
367
+
368
+ ### Correct structure example
369
+
370
+ ```
371
+ #CardProduct (Frame, Auto Layout Vertical)
372
+ ├── image (Rectangle, Aspect Ratio 16:9)
373
+ ├── content (Frame, Auto Layout Vertical, Padding 16px)
374
+ │ ├── title (Text, Heading/H3)
375
+ │ ├── description (Text, Body/Small)
376
+ │ └── price (Text, Heading/H2)
377
+ └── actions (Frame, Auto Layout Horizontal)
378
+ └── button (Instance of #Button)
379
+ ```
380
+
381
+ ---
382
+
383
+ ## Environment Variables
384
+
385
+ | Variable | Description |
386
+ |----------|-------------|
387
+ | `FIGMA_TOKEN` | Figma access token |
388
+ | `FIGMA_FILE_ID` | Figma file ID |
389
+
390
+ ### How to get Figma Token
391
+
392
+ 1. Go to [Figma Account Settings](https://www.figma.com/settings)
393
+ 2. Navigate to "Personal Access Tokens"
394
+ 3. Create a new token
395
+
396
+ ### How to get File ID
397
+
398
+ The File ID is in your Figma file URL:
399
+
400
+ ```
401
+ https://www.figma.com/file/ABC123xyz/MyProject
402
+ ^^^^^^^^^^^
403
+ This is the File ID
404
+ ```
405
+
406
+ ---
407
+
408
+ ## Author
409
+
410
+ **Desiree Menezes** - [@desireemenezes](https://github.com/desireemenezes)
411
+
412
+ ---
413
+
414
+ ## License
415
+
416
+ Proprietary - All rights reserved.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptui-lib/figma-parser",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "private": false,
5
5
  "description": "Figma API client and parser for PromptUI",
6
6
  "license": "UNLICENSED",
@@ -30,7 +30,7 @@
30
30
  "dist"
31
31
  ],
32
32
  "dependencies": {
33
- "@promptui-lib/core": "0.1.0"
33
+ "@promptui-lib/core": "0.1.2"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/node": "^20.0.0",