@promptui-lib/codegen 0.1.13 → 0.1.14
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/README.md +465 -347
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<h1 align="center"
|
|
1
|
+
<h1 align="center">PromptUI</h1>
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
4
|
<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>
|
|
@@ -7,119 +7,364 @@
|
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
|
-
<strong>
|
|
10
|
+
<strong>Transforme designs do Figma em código pronto para produção em segundos.</strong>
|
|
11
11
|
</p>
|
|
12
12
|
|
|
13
13
|
<p align="center">
|
|
14
|
-
100%
|
|
14
|
+
100% determinístico. Sem IA. Mesmo input = mesmo output, sempre.
|
|
15
15
|
</p>
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## Índice
|
|
20
|
+
|
|
21
|
+
- [O que é o PromptUI?](#o-que-é-o-promptui)
|
|
22
|
+
- [Início Rápido](#início-rápido)
|
|
23
|
+
- [Instalação](#instalação)
|
|
24
|
+
- [Frameworks Suportados](#frameworks-suportados)
|
|
25
|
+
- [Comandos CLI](#comandos-cli)
|
|
26
|
+
- [Configuração](#configuração)
|
|
27
|
+
- [Guia para Designers](#guia-para-designers)
|
|
28
|
+
- [Classificação de Componentes](#classificação-de-componentes)
|
|
29
|
+
- [HTML5 Semântico](#html5-semântico)
|
|
30
|
+
- [Como Funciona](#como-funciona)
|
|
31
|
+
- [Integração com Claude Code](#integração-com-claude-code)
|
|
32
|
+
- [Estrutura de Pacotes](#estrutura-de-pacotes)
|
|
20
33
|
|
|
21
|
-
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## O que é o PromptUI?
|
|
37
|
+
|
|
38
|
+
**PromptUI** é uma biblioteca que converte automaticamente designs do Figma em código limpo e pronto para produção. Ela lê a API do Figma, parseia a estrutura do design e gera código específico para cada framework.
|
|
22
39
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
- **
|
|
26
|
-
- **Tailwind
|
|
27
|
-
- **
|
|
28
|
-
- **
|
|
29
|
-
- **
|
|
40
|
+
### Principais Funcionalidades
|
|
41
|
+
|
|
42
|
+
- **Output Determinístico**: Mesmo design = mesmo código, sempre
|
|
43
|
+
- **Múltiplos Frameworks**: React, Material UI, Tailwind, Bootstrap, Flutter, SwiftUI
|
|
44
|
+
- **Design Tokens**: Extrai automaticamente cores, espaçamentos, tipografia
|
|
45
|
+
- **HTML5 Semântico**: Gera tags apropriadas (`<button>`, `<nav>`, `<header>`, `<form>`)
|
|
46
|
+
- **Auto Layout → Flexbox**: Converte Auto Layout do Figma para CSS Flexbox
|
|
47
|
+
- **Posicionamento Absoluto**: Suporta elementos sem Auto Layout
|
|
48
|
+
- **Google Fonts**: Importa automaticamente as fontes detectadas
|
|
49
|
+
- **Composição de Componentes**: Componentes `#` aninhados são importados automaticamente
|
|
30
50
|
|
|
31
51
|
---
|
|
32
52
|
|
|
33
|
-
##
|
|
53
|
+
## Início Rápido
|
|
34
54
|
|
|
35
55
|
```bash
|
|
56
|
+
# 1. Instale globalmente
|
|
36
57
|
npm install -g @promptui-lib/cli
|
|
58
|
+
|
|
59
|
+
# 2. Configure seu projeto
|
|
60
|
+
npx @promptui-lib/cli init
|
|
61
|
+
|
|
62
|
+
# 3. Configure as credenciais do Figma
|
|
63
|
+
export FIGMA_TOKEN=seu_token_aqui
|
|
64
|
+
export FIGMA_FILE_ID=id_do_arquivo
|
|
65
|
+
|
|
66
|
+
# 4. Gere todos os componentes
|
|
67
|
+
npx @promptui-lib/cli generate
|
|
37
68
|
```
|
|
38
69
|
|
|
39
70
|
---
|
|
40
71
|
|
|
41
|
-
##
|
|
72
|
+
## Instalação
|
|
42
73
|
|
|
43
|
-
|
|
74
|
+
```bash
|
|
75
|
+
npm install -g @promptui-lib/cli
|
|
76
|
+
```
|
|
44
77
|
|
|
45
|
-
|
|
78
|
+
Ou use com npx:
|
|
46
79
|
|
|
80
|
+
```bash
|
|
81
|
+
npx @promptui-lib/cli generate
|
|
47
82
|
```
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Frameworks Suportados
|
|
87
|
+
|
|
88
|
+
| Framework | Comando | Output |
|
|
89
|
+
| ---------------- | -------------------- | ---------------------------- |
|
|
90
|
+
| **React + SCSS** | `generate` | TSX + BEM SCSS |
|
|
91
|
+
| **Material UI** | `generate mui` | TSX + componentes MUI |
|
|
92
|
+
| **Tailwind CSS** | `generate tailwind` | TSX + classes Tailwind |
|
|
93
|
+
| **Bootstrap** | `generate bootstrap` | TSX + classes Bootstrap |
|
|
94
|
+
| **Ant Design** | `generate antd` | TSX + componentes Ant Design |
|
|
95
|
+
| **Flutter** | `generate flutter` | Dart StatelessWidget |
|
|
96
|
+
| **SwiftUI** | `generate swiftui` | Swift View |
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Comandos CLI
|
|
101
|
+
|
|
102
|
+
### Gerar Componentes
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Exporta frames marcados com #
|
|
106
|
+
npx @promptui-lib/cli generate
|
|
107
|
+
|
|
108
|
+
# Exporta TODOS os frames de nível superior
|
|
109
|
+
npx @promptui-lib/cli generate --all
|
|
110
|
+
|
|
111
|
+
# Exporta node específico por ID
|
|
112
|
+
npx @promptui-lib/cli generate 3:100
|
|
113
|
+
|
|
114
|
+
# Preview sem salvar arquivos
|
|
115
|
+
npx @promptui-lib/cli generate --preview
|
|
116
|
+
|
|
117
|
+
# Com framework específico
|
|
118
|
+
npx @promptui-lib/cli generate tailwind
|
|
119
|
+
npx @promptui-lib/cli generate mui
|
|
120
|
+
npx @promptui-lib/cli generate bootstrap
|
|
52
121
|
```
|
|
53
122
|
|
|
54
|
-
###
|
|
123
|
+
### Opções
|
|
124
|
+
|
|
125
|
+
| Opção | Descrição |
|
|
126
|
+
| --------------- | ----------------------------------------- |
|
|
127
|
+
| `--all, -a` | Exporta todos os frames de nível superior |
|
|
128
|
+
| `--force, -f` | Sobrescreve arquivos existentes |
|
|
129
|
+
| `--output, -o` | Diretório de saída customizado |
|
|
130
|
+
| `--preview, -p` | Preview sem salvar |
|
|
131
|
+
| `--layer, -l` | Força camada (atoms/molecules/organisms) |
|
|
132
|
+
| `--no-meta` | Não gera meta.json |
|
|
133
|
+
|
|
134
|
+
### Outros Comandos
|
|
55
135
|
|
|
56
136
|
```bash
|
|
137
|
+
# Inicializa configuração
|
|
57
138
|
npx @promptui-lib/cli init
|
|
139
|
+
|
|
140
|
+
# Sincroniza design tokens
|
|
141
|
+
npx @promptui-lib/cli sync tokens
|
|
142
|
+
|
|
143
|
+
# Inicia agente MCP
|
|
144
|
+
npx @promptui-lib/cli agent
|
|
58
145
|
```
|
|
59
146
|
|
|
60
|
-
|
|
147
|
+
---
|
|
61
148
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
149
|
+
## Configuração
|
|
150
|
+
|
|
151
|
+
Crie `promptui.config.json`:
|
|
152
|
+
|
|
153
|
+
```json
|
|
154
|
+
{
|
|
155
|
+
"figma": {
|
|
156
|
+
"token": "figd_...",
|
|
157
|
+
"fileId": "ABC123xyz"
|
|
158
|
+
},
|
|
159
|
+
"output": {
|
|
160
|
+
"basePath": "src/components",
|
|
161
|
+
"styleFormat": "scss"
|
|
162
|
+
}
|
|
163
|
+
}
|
|
65
164
|
```
|
|
66
165
|
|
|
67
|
-
|
|
166
|
+
Ou use variáveis de ambiente:
|
|
68
167
|
|
|
69
168
|
```bash
|
|
70
|
-
|
|
71
|
-
|
|
169
|
+
export FIGMA_TOKEN=figd_...
|
|
170
|
+
export FIGMA_FILE_ID=ABC123xyz
|
|
171
|
+
```
|
|
72
172
|
|
|
73
|
-
|
|
74
|
-
npx @promptui-lib/cli generate bootstrap
|
|
173
|
+
### Obtendo Credenciais do Figma
|
|
75
174
|
|
|
76
|
-
|
|
77
|
-
npx @promptui-lib/cli generate mui
|
|
175
|
+
**Token:**
|
|
78
176
|
|
|
79
|
-
|
|
80
|
-
|
|
177
|
+
1. Acesse [Configurações do Figma](https://www.figma.com/settings)
|
|
178
|
+
2. "Personal Access Tokens" → Criar novo
|
|
81
179
|
|
|
82
|
-
|
|
83
|
-
|
|
180
|
+
**File ID:**
|
|
181
|
+
Da URL do Figma: `https://www.figma.com/file/ABC123xyz/MeuProjeto` → `ABC123xyz`
|
|
84
182
|
|
|
85
|
-
|
|
86
|
-
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Guia para Designers
|
|
186
|
+
|
|
187
|
+
### Regra Principal: Prefixo `#`
|
|
188
|
+
|
|
189
|
+
Para que um componente seja exportado, o nome do frame **deve começar com `#`**:
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
✅ #Button → Será exportado
|
|
193
|
+
✅ #Card → Será exportado
|
|
194
|
+
✅ #LoginScreen → Será exportado
|
|
195
|
+
❌ Button → Ignorado
|
|
196
|
+
❌ card-design → Ignorado
|
|
87
197
|
```
|
|
88
198
|
|
|
199
|
+
### Composição de Componentes
|
|
200
|
+
|
|
201
|
+
Componentes `#` aninhados são automaticamente importados:
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
#LoginScreen (organismo)
|
|
205
|
+
├── #Header (organismo) → import { Header } from '../organisms/Header'
|
|
206
|
+
├── #Form (molécula) → import { Form } from '../molecules/Form'
|
|
207
|
+
│ ├── field-email → <input type="email" placeholder="Email">
|
|
208
|
+
│ ├── field-password → <input type="password" placeholder="Password">
|
|
209
|
+
│ └── #Button → import { Button } from '../atoms/Button'
|
|
210
|
+
└── #Footer (organismo) → import { Footer } from '../organisms/Footer'
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Auto Layout é Essencial
|
|
214
|
+
|
|
215
|
+
**Sempre use Auto Layout** nos seus frames. O PromptUI converte:
|
|
216
|
+
|
|
217
|
+
| Figma Auto Layout | CSS Gerado |
|
|
218
|
+
| ----------------- | -------------------------------- |
|
|
219
|
+
| Horizontal | `flex-direction: row` |
|
|
220
|
+
| Vertical | `flex-direction: column` |
|
|
221
|
+
| Space between | `justify-content: space-between` |
|
|
222
|
+
| Packed (center) | `justify-content: center` |
|
|
223
|
+
| Gap: 16 | `gap: 16px` ou `$spacing-md` |
|
|
224
|
+
| Padding | `padding: Xpx Ypx` |
|
|
225
|
+
|
|
226
|
+
**Sem Auto Layout**: Elementos recebem `position: absolute` baseado nas constraints.
|
|
227
|
+
|
|
228
|
+
### Nomenclatura de Elementos Internos
|
|
229
|
+
|
|
230
|
+
Use nomes descritivos para que o PromptUI gere HTML5 semântico:
|
|
231
|
+
|
|
232
|
+
| Nome no Figma | HTML Gerado |
|
|
233
|
+
| -------------------- | ------------------------------------------------ |
|
|
234
|
+
| `field-email` | `<input type="email" placeholder="Email">` |
|
|
235
|
+
| `field-password` | `<input type="password" placeholder="Password">` |
|
|
236
|
+
| `field-cpf` | `<input type="text" placeholder="Cpf">` |
|
|
237
|
+
| `field-telefone` | `<input type="tel" placeholder="Telefone">` |
|
|
238
|
+
| `btn-enviar` | `<button>` |
|
|
239
|
+
| `link-esqueci-senha` | `<a href="/esqueci-senha">` |
|
|
240
|
+
| `nav-menu` | `<nav>` |
|
|
241
|
+
| `img-avatar` | `<img alt="Avatar">` |
|
|
242
|
+
|
|
89
243
|
---
|
|
90
244
|
|
|
91
|
-
##
|
|
245
|
+
## Classificação de Componentes
|
|
246
|
+
|
|
247
|
+
O PromptUI usa **HTML5 Semântico + Atomic Design + SOLID** para classificar componentes automaticamente.
|
|
92
248
|
|
|
93
|
-
###
|
|
249
|
+
### Átomos (Elementos Indivisíveis)
|
|
94
250
|
|
|
95
|
-
|
|
251
|
+
Elementos simples, sem filhos complexos:
|
|
96
252
|
|
|
97
253
|
```
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
└── label (Text: "Click me")
|
|
254
|
+
button, btn, link, input, field, textfield, textarea, select,
|
|
255
|
+
checkbox, radio, toggle, switch, icon, image, img, avatar,
|
|
256
|
+
badge, tag, chip, label, text, spinner, loader, loading,
|
|
257
|
+
skeleton, progress, divider, separator, spacer, line
|
|
103
258
|
```
|
|
104
259
|
|
|
105
|
-
**
|
|
106
|
-
|
|
107
|
-
|
|
260
|
+
**Exemplos:** `#Button`, `#Input`, `#Icon`, `#Badge`, `#Avatar`
|
|
261
|
+
|
|
262
|
+
### Moléculas (Combinação de Átomos)
|
|
263
|
+
|
|
264
|
+
Formam unidade funcional:
|
|
265
|
+
|
|
266
|
+
```
|
|
267
|
+
card, tile, item, row, cell, form, fieldset, form-group,
|
|
268
|
+
input-group, search-bar, nav, menu, navbar, nav-bar, nav-item,
|
|
269
|
+
breadcrumb, tabs, tab, modal, dialog, popup, popover, tooltip,
|
|
270
|
+
dropdown, alert, toast, notification, snackbar, banner,
|
|
271
|
+
list-item, menu-item, accordion-item, figure, thumbnail
|
|
108
272
|
```
|
|
109
273
|
|
|
110
|
-
**
|
|
274
|
+
**Exemplos:** `#Card`, `#Form`, `#SearchBar`, `#Modal`, `#Alert`
|
|
111
275
|
|
|
112
|
-
|
|
113
|
-
// src/components/atoms/Button/button.tsx
|
|
114
|
-
import type { ReactNode } from 'react';
|
|
115
|
-
import './button.scss';
|
|
276
|
+
### Organismos (Seções Estruturais HTML5)
|
|
116
277
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
278
|
+
Contêm moléculas, são seções completas:
|
|
279
|
+
|
|
280
|
+
```
|
|
281
|
+
header, footer, main, section, article, aside, sidebar, panel,
|
|
282
|
+
container, wrapper, list, grid, table, gallery, carousel,
|
|
283
|
+
hero, features, testimonials, pricing, contact, wizard, stepper,
|
|
284
|
+
flow, timeline, dashboard, overview, stats, screen, page, view,
|
|
285
|
+
layout, template
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
**Exemplos:** `#Header`, `#Footer`, `#Sidebar`, `#LoginScreen`, `#Dashboard`
|
|
289
|
+
|
|
290
|
+
### Regra de Composição
|
|
291
|
+
|
|
292
|
+
**Se um componente tem filhos marcados com `#`, ele é automaticamente um ORGANISMO.**
|
|
293
|
+
|
|
294
|
+
```
|
|
295
|
+
#LoginScreen → organismo (tem #Header, #Form, #Footer como filhos)
|
|
296
|
+
├── #Header → organismo (pelo nome)
|
|
297
|
+
├── #Form → molécula (pelo nome)
|
|
298
|
+
│ └── #Button → átomo (pelo nome)
|
|
299
|
+
└── #Footer → organismo (pelo nome)
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## HTML5 Semântico
|
|
305
|
+
|
|
306
|
+
### Tags Geradas Automaticamente
|
|
307
|
+
|
|
308
|
+
| Padrão no Nome | Tag HTML |
|
|
309
|
+
| --------------------------- | ---------------- |
|
|
310
|
+
| `button`, `btn` | `<button>` |
|
|
311
|
+
| `input`, `field`, `campo` | `<input>` |
|
|
312
|
+
| `link`, `anchor` | `<a href="...">` |
|
|
313
|
+
| `nav`, `menu`, `navegacao` | `<nav>` |
|
|
314
|
+
| `header`, `cabecalho` | `<header>` |
|
|
315
|
+
| `footer`, `rodape` | `<footer>` |
|
|
316
|
+
| `section`, `secao` | `<section>` |
|
|
317
|
+
| `article`, `artigo` | `<article>` |
|
|
318
|
+
| `image`, `imagem`, `avatar` | `<img>` |
|
|
319
|
+
| `form`, `formulario` | `<form>` |
|
|
320
|
+
| (padrão) | `<div>` |
|
|
321
|
+
|
|
322
|
+
### Tipos de Input Detectados
|
|
323
|
+
|
|
324
|
+
| Nome do Campo | Tipo Gerado |
|
|
325
|
+
| ------------------------------- | ----------------- |
|
|
326
|
+
| `field-email`, `campo-email` | `type="email"` |
|
|
327
|
+
| `field-password`, `campo-senha` | `type="password"` |
|
|
328
|
+
| `field-telefone`, `field-phone` | `type="tel"` |
|
|
329
|
+
| `field-busca`, `field-search` | `type="search"` |
|
|
330
|
+
| `field-numero`, `field-number` | `type="number"` |
|
|
331
|
+
| `field-data`, `field-date` | `type="date"` |
|
|
332
|
+
| `field-url`, `field-website` | `type="url"` |
|
|
333
|
+
| `field-arquivo`, `field-upload` | `type="file"` |
|
|
334
|
+
| (outros) | `type="text"` |
|
|
335
|
+
|
|
336
|
+
### Placeholders Genéricos
|
|
337
|
+
|
|
338
|
+
O placeholder é gerado automaticamente a partir do nome do campo:
|
|
339
|
+
|
|
340
|
+
```
|
|
341
|
+
field-cpf → placeholder="Cpf"
|
|
342
|
+
field-cnpj → placeholder="Cnpj"
|
|
343
|
+
campo-nome → placeholder="Nome"
|
|
344
|
+
input-endereco → placeholder="Endereco"
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## Como Funciona
|
|
350
|
+
|
|
351
|
+
O PromptUI segue um pipeline de 4 etapas:
|
|
352
|
+
|
|
353
|
+
```
|
|
354
|
+
┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
|
|
355
|
+
│ 1. FETCH │ ──► │ 2. PARSE │ ──► │ 3. CODEGEN │ ──► │ 4. WRITE │
|
|
356
|
+
│ API Figma │ │ Estrutura │ │ Framework │ │ Arquivos │
|
|
357
|
+
└──────────────┘ └──────────────┘ └──────────────┘ └──────────────┘
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### Etapa 3: Geração de Código
|
|
361
|
+
|
|
362
|
+
Gera código específico para cada framework:
|
|
363
|
+
|
|
364
|
+
**React + SCSS (BEM):**
|
|
121
365
|
|
|
122
|
-
|
|
366
|
+
```tsx
|
|
367
|
+
export const Button = ({ children, className = "" }: IButtonProps) => {
|
|
123
368
|
return (
|
|
124
369
|
<button className={`button ${className}`.trim()}>
|
|
125
370
|
<span className="button__label">{children}</span>
|
|
@@ -129,370 +374,243 @@ export const Button = ({ children, className = '' }: IButtonProps) => {
|
|
|
129
374
|
```
|
|
130
375
|
|
|
131
376
|
```scss
|
|
132
|
-
// src/components/atoms/Button/button.scss
|
|
133
377
|
.button {
|
|
134
378
|
display: flex;
|
|
135
379
|
align-items: center;
|
|
136
|
-
|
|
380
|
+
gap: $spacing-xs;
|
|
137
381
|
padding: $spacing-sm $spacing-lg;
|
|
138
382
|
background-color: $color-primary;
|
|
139
383
|
border-radius: $radius-medium;
|
|
140
|
-
|
|
141
|
-
&__label {
|
|
142
|
-
color: $color-text-inverse;
|
|
143
|
-
font-weight: $font-weight-medium;
|
|
144
|
-
}
|
|
145
384
|
}
|
|
146
385
|
```
|
|
147
386
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
### Example 2: Card with Bootstrap
|
|
151
|
-
|
|
152
|
-
**In Figma:** Frame named `#CardProduct`
|
|
387
|
+
**Design Tokens SCSS (`_variables.scss`):**
|
|
153
388
|
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
389
|
+
```scss
|
|
390
|
+
// Cores extraídas do Figma
|
|
391
|
+
$color-primary: #3b82f6;
|
|
392
|
+
$color-primary-hover: #2563eb;
|
|
393
|
+
$color-secondary: #64748b;
|
|
394
|
+
$color-success: #22c55e;
|
|
395
|
+
$color-warning: #f59e0b;
|
|
396
|
+
$color-error: #ef4444;
|
|
397
|
+
$color-background: #ffffff;
|
|
398
|
+
$color-surface: #f8fafc;
|
|
399
|
+
$color-text-primary: #1e293b;
|
|
400
|
+
$color-text-secondary: #64748b;
|
|
401
|
+
$color-border: #e2e8f0;
|
|
402
|
+
|
|
403
|
+
// Espaçamentos (baseado no gap/padding do Figma)
|
|
404
|
+
$spacing-xs: 4px;
|
|
405
|
+
$spacing-sm: 8px;
|
|
406
|
+
$spacing-md: 16px;
|
|
407
|
+
$spacing-lg: 24px;
|
|
408
|
+
$spacing-xl: 32px;
|
|
409
|
+
$spacing-2xl: 48px;
|
|
410
|
+
|
|
411
|
+
// Border Radius
|
|
412
|
+
$radius-none: 0;
|
|
413
|
+
$radius-small: 4px;
|
|
414
|
+
$radius-medium: 8px;
|
|
415
|
+
$radius-large: 12px;
|
|
416
|
+
$radius-xl: 16px;
|
|
417
|
+
$radius-full: 9999px;
|
|
418
|
+
|
|
419
|
+
// Tipografia
|
|
420
|
+
$font-family-sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
|
|
421
|
+
$font-family-mono: "Fira Code", monospace;
|
|
422
|
+
|
|
423
|
+
$font-size-xs: 12px;
|
|
424
|
+
$font-size-sm: 14px;
|
|
425
|
+
$font-size-base: 16px;
|
|
426
|
+
$font-size-lg: 18px;
|
|
427
|
+
$font-size-xl: 20px;
|
|
428
|
+
$font-size-2xl: 24px;
|
|
429
|
+
$font-size-3xl: 30px;
|
|
430
|
+
|
|
431
|
+
$font-weight-normal: 400;
|
|
432
|
+
$font-weight-medium: 500;
|
|
433
|
+
$font-weight-semibold: 600;
|
|
434
|
+
$font-weight-bold: 700;
|
|
435
|
+
|
|
436
|
+
// Sombras
|
|
437
|
+
$shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
|
|
438
|
+
$shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
439
|
+
$shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
|
|
440
|
+
$shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);
|
|
441
|
+
|
|
442
|
+
// Transições
|
|
443
|
+
$transition-fast: 150ms ease;
|
|
444
|
+
$transition-normal: 200ms ease;
|
|
445
|
+
$transition-slow: 300ms ease;
|
|
167
446
|
```
|
|
168
447
|
|
|
169
|
-
**
|
|
448
|
+
**Tailwind CSS:**
|
|
170
449
|
|
|
171
450
|
```tsx
|
|
172
|
-
|
|
173
|
-
import type { ReactNode } from 'react';
|
|
174
|
-
|
|
175
|
-
export interface ICardProductProps {
|
|
176
|
-
children?: ReactNode;
|
|
177
|
-
className?: string;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
export const CardProduct = ({ children, className = '' }: ICardProductProps) => {
|
|
451
|
+
export const Button = ({ children, className = "" }: IButtonProps) => {
|
|
181
452
|
return (
|
|
182
|
-
<
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
<p className="h4 text-primary fw-bold">$99.00</p>
|
|
188
|
-
<button className="btn btn-primary w-100">Buy Now</button>
|
|
189
|
-
</div>
|
|
190
|
-
</div>
|
|
453
|
+
<button
|
|
454
|
+
className={`flex items-center gap-2 px-6 py-3 bg-blue-500 hover:bg-blue-600 text-white rounded-lg transition-colors ${className}`.trim()}
|
|
455
|
+
>
|
|
456
|
+
<span>{children}</span>
|
|
457
|
+
</button>
|
|
191
458
|
);
|
|
192
459
|
};
|
|
193
460
|
```
|
|
194
461
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
### Example 3: Header with Tailwind CSS
|
|
462
|
+
**Material UI:**
|
|
198
463
|
|
|
199
|
-
|
|
464
|
+
```tsx
|
|
465
|
+
import { Button as MuiButton, Box, Typography } from "@mui/material";
|
|
200
466
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
467
|
+
export const Button = ({ children, className = "" }: IButtonProps) => {
|
|
468
|
+
return (
|
|
469
|
+
<MuiButton
|
|
470
|
+
variant="contained"
|
|
471
|
+
className={className}
|
|
472
|
+
sx={{
|
|
473
|
+
display: "flex",
|
|
474
|
+
alignItems: "center",
|
|
475
|
+
gap: 1,
|
|
476
|
+
px: 3,
|
|
477
|
+
py: 1.5,
|
|
478
|
+
borderRadius: 2,
|
|
479
|
+
}}
|
|
480
|
+
>
|
|
481
|
+
<Typography>{children}</Typography>
|
|
482
|
+
</MuiButton>
|
|
483
|
+
);
|
|
484
|
+
};
|
|
204
485
|
```
|
|
205
486
|
|
|
206
|
-
**
|
|
487
|
+
**Bootstrap:**
|
|
207
488
|
|
|
208
489
|
```tsx
|
|
209
|
-
|
|
210
|
-
export const HeaderNav = ({ className = '' }: IHeaderNavProps) => {
|
|
490
|
+
export const Button = ({ children, className = "" }: IButtonProps) => {
|
|
211
491
|
return (
|
|
212
|
-
<
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
<nav className="flex items-center gap-8">
|
|
218
|
-
<a className="text-gray-600 hover:text-gray-900">Home</a>
|
|
219
|
-
<a className="text-gray-600 hover:text-gray-900">Products</a>
|
|
220
|
-
<a className="text-gray-600 hover:text-gray-900">About</a>
|
|
221
|
-
</nav>
|
|
222
|
-
<button className="px-4 py-2 bg-blue-500 text-white rounded-lg">
|
|
223
|
-
Sign In
|
|
224
|
-
</button>
|
|
225
|
-
</header>
|
|
492
|
+
<button
|
|
493
|
+
className={`btn btn-primary d-flex align-items-center gap-2 ${className}`.trim()}
|
|
494
|
+
>
|
|
495
|
+
<span>{children}</span>
|
|
496
|
+
</button>
|
|
226
497
|
);
|
|
227
498
|
};
|
|
228
499
|
```
|
|
229
500
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
### Example 4: Button with Flutter
|
|
501
|
+
**Ant Design:**
|
|
233
502
|
|
|
234
|
-
|
|
503
|
+
```tsx
|
|
504
|
+
import { Button as AntButton } from "antd";
|
|
235
505
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
506
|
+
export const Button = ({ children, className = "" }: IButtonProps) => {
|
|
507
|
+
return (
|
|
508
|
+
<AntButton
|
|
509
|
+
type="primary"
|
|
510
|
+
className={className}
|
|
511
|
+
style={{
|
|
512
|
+
display: "flex",
|
|
513
|
+
alignItems: "center",
|
|
514
|
+
gap: 8,
|
|
515
|
+
height: "auto",
|
|
516
|
+
padding: "12px 24px",
|
|
517
|
+
borderRadius: 8,
|
|
518
|
+
}}
|
|
519
|
+
>
|
|
520
|
+
{children}
|
|
521
|
+
</AntButton>
|
|
522
|
+
);
|
|
523
|
+
};
|
|
239
524
|
```
|
|
240
525
|
|
|
241
|
-
**
|
|
526
|
+
**Flutter:**
|
|
242
527
|
|
|
243
528
|
```dart
|
|
244
|
-
/// Button
|
|
245
|
-
/// Generated by PromptUI (Flutter)
|
|
246
|
-
|
|
247
|
-
import 'package:flutter/material.dart';
|
|
248
|
-
|
|
249
529
|
class Button extends StatelessWidget {
|
|
250
|
-
|
|
530
|
+
final Widget child;
|
|
531
|
+
final VoidCallback? onPressed;
|
|
532
|
+
|
|
533
|
+
const Button({Key? key, required this.child, this.onPressed}) : super(key: key);
|
|
251
534
|
|
|
252
535
|
@override
|
|
253
536
|
Widget build(BuildContext context) {
|
|
254
|
-
return
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
537
|
+
return ElevatedButton(
|
|
538
|
+
onPressed: onPressed,
|
|
539
|
+
style: ElevatedButton.styleFrom(
|
|
540
|
+
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
|
541
|
+
shape: RoundedRectangleBorder(
|
|
542
|
+
borderRadius: BorderRadius.circular(8),
|
|
543
|
+
),
|
|
259
544
|
),
|
|
260
|
-
child:
|
|
545
|
+
child: child,
|
|
261
546
|
);
|
|
262
547
|
}
|
|
263
548
|
}
|
|
264
549
|
```
|
|
265
550
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
### Example 5: Button with SwiftUI
|
|
269
|
-
|
|
270
|
-
**In Figma:** Frame named `#Button`
|
|
271
|
-
|
|
272
|
-
**Command:**
|
|
273
|
-
```bash
|
|
274
|
-
npx @promptui-lib/cli generate swiftui
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
**Result:**
|
|
551
|
+
**SwiftUI:**
|
|
278
552
|
|
|
279
553
|
```swift
|
|
280
|
-
/// Button
|
|
281
|
-
/// Generated by PromptUI (SwiftUI)
|
|
282
|
-
|
|
283
|
-
import SwiftUI
|
|
284
|
-
|
|
285
554
|
struct Button: View {
|
|
555
|
+
let label: String
|
|
556
|
+
let action: () -> Void
|
|
557
|
+
|
|
286
558
|
var body: some View {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
559
|
+
SwiftUI.Button(action: action) {
|
|
560
|
+
Text(label)
|
|
561
|
+
.padding(.horizontal, 24)
|
|
562
|
+
.padding(.vertical, 12)
|
|
563
|
+
.background(Color.blue)
|
|
564
|
+
.foregroundColor(.white)
|
|
565
|
+
.cornerRadius(8)
|
|
566
|
+
}
|
|
293
567
|
}
|
|
294
568
|
}
|
|
295
|
-
|
|
296
|
-
#Preview {
|
|
297
|
-
Button()
|
|
298
|
-
}
|
|
299
569
|
```
|
|
300
570
|
|
|
301
571
|
---
|
|
302
572
|
|
|
303
|
-
##
|
|
304
|
-
|
|
305
|
-
| Command | Description |
|
|
306
|
-
|---------|-------------|
|
|
307
|
-
| `npx @promptui-lib/cli init` | Configure the project |
|
|
308
|
-
| `npx @promptui-lib/cli generate` | Generate components (React + SCSS) |
|
|
309
|
-
| `npx @promptui-lib/cli generate bootstrap` | Generate with Bootstrap |
|
|
310
|
-
| `npx @promptui-lib/cli generate mui` | Generate with Material UI |
|
|
311
|
-
| `npx @promptui-lib/cli generate tailwind` | Generate with Tailwind CSS |
|
|
312
|
-
| `npx @promptui-lib/cli generate flutter` | Generate with Flutter/Dart |
|
|
313
|
-
| `npx @promptui-lib/cli generate swiftui` | Generate with SwiftUI |
|
|
314
|
-
| `npx @promptui-lib/cli sync tokens` | Sync design tokens |
|
|
315
|
-
|
|
316
|
-
## Options
|
|
317
|
-
|
|
318
|
-
| Option | Description |
|
|
319
|
-
|--------|-------------|
|
|
320
|
-
| `-p, --preview` | Preview without saving |
|
|
321
|
-
| `-o, --output <dir>` | Output directory |
|
|
322
|
-
| `-f, --force` | Overwrite existing files |
|
|
323
|
-
|
|
324
|
-
---
|
|
573
|
+
## Integração com Claude Code
|
|
325
574
|
|
|
326
|
-
|
|
575
|
+
O PromptUI inclui um Agente MCP (Model Context Protocol) para integração com IA.
|
|
327
576
|
|
|
328
|
-
|
|
577
|
+
### Configuração
|
|
329
578
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
| **organisms** | Complex compositions | Header, Footer, Sidebar |
|
|
335
|
-
|
|
336
|
-
---
|
|
337
|
-
|
|
338
|
-
## Configuration
|
|
579
|
+
```bash
|
|
580
|
+
# Inicie o agente
|
|
581
|
+
npx @promptui-lib/cli agent
|
|
582
|
+
```
|
|
339
583
|
|
|
340
|
-
|
|
584
|
+
Configure no Claude Code:
|
|
341
585
|
|
|
342
586
|
```json
|
|
343
587
|
{
|
|
344
|
-
"
|
|
345
|
-
"
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
588
|
+
"mcpServers": {
|
|
589
|
+
"promptui": {
|
|
590
|
+
"command": "npx",
|
|
591
|
+
"args": ["@promptui-lib/cli", "agent"]
|
|
592
|
+
}
|
|
349
593
|
}
|
|
350
594
|
}
|
|
351
595
|
```
|
|
352
596
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
## Figma Support
|
|
356
|
-
|
|
357
|
-
### What We Extract from Figma
|
|
358
|
-
|
|
359
|
-
| Element | Supported | Notes |
|
|
360
|
-
|---------|-----------|-------|
|
|
361
|
-
| **Colors** | ✅ Yes | RGB, Hex, tokens |
|
|
362
|
-
| **Spacing** | ✅ Yes | Padding, margin, gap |
|
|
363
|
-
| **Typography** | ✅ Yes | Font size, weight, family |
|
|
364
|
-
| **Border Radius** | ✅ Yes | All corners |
|
|
365
|
-
| **Shadows** | ✅ Yes | Drop shadow, inner shadow |
|
|
366
|
-
| **Layout** | ✅ Yes | Auto Layout → Flexbox |
|
|
367
|
-
| **SVG/Icons** | ✅ Yes | Exported as inline SVG |
|
|
368
|
-
| **Images** | ⚠️ Partial | Placeholder generated |
|
|
369
|
-
| **Gradients** | ⚠️ Partial | Linear gradients |
|
|
370
|
-
| **Animations** | ❌ No | Not available via Figma API |
|
|
371
|
-
| **Prototype Links** | ❌ No | Prototype data only |
|
|
372
|
-
|
|
373
|
-
### Bootstrap Components Mapping
|
|
374
|
-
|
|
375
|
-
Name your Figma frames to auto-map to Bootstrap components:
|
|
376
|
-
|
|
377
|
-
| Figma Frame Name | Bootstrap Output |
|
|
378
|
-
|------------------|------------------|
|
|
379
|
-
| `#Alert` | `<div class="alert">` |
|
|
380
|
-
| `#Badge` | `<span class="badge">` |
|
|
381
|
-
| `#Breadcrumb` | `<nav class="breadcrumb">` |
|
|
382
|
-
| `#Button` | `<button class="btn">` |
|
|
383
|
-
| `#ButtonGroup` | `<div class="btn-group">` |
|
|
384
|
-
| `#Card` | `<div class="card">` |
|
|
385
|
-
| `#Carousel` | `<div class="carousel">` |
|
|
386
|
-
| `#Collapse` | `<div class="collapse">` |
|
|
387
|
-
| `#Dropdown` | `<div class="dropdown">` |
|
|
388
|
-
| `#ListGroup` | `<ul class="list-group">` |
|
|
389
|
-
| `#Modal` | `<div class="modal">` |
|
|
390
|
-
| `#Navbar` | `<nav class="navbar">` |
|
|
391
|
-
| `#Nav` or `#Tabs` | `<ul class="nav">` |
|
|
392
|
-
| `#Offcanvas` | `<div class="offcanvas">` |
|
|
393
|
-
| `#Pagination` | `<nav class="pagination">` |
|
|
394
|
-
| `#Progress` | `<div class="progress">` |
|
|
395
|
-
| `#Spinner` | `<div class="spinner">` |
|
|
396
|
-
| `#Toast` | `<div class="toast">` |
|
|
397
|
-
| `#Tooltip` | `data-bs-toggle="tooltip"` |
|
|
398
|
-
|
|
399
|
-
### Material UI Components Mapping
|
|
400
|
-
|
|
401
|
-
| Figma Frame Name | MUI Output |
|
|
402
|
-
|------------------|------------|
|
|
403
|
-
| `#Alert` | `<Alert>` |
|
|
404
|
-
| `#Avatar` | `<Avatar>` |
|
|
405
|
-
| `#Badge` | `<Badge>` |
|
|
406
|
-
| `#Breadcrumb` | `<Breadcrumbs>` |
|
|
407
|
-
| `#Button` | `<Button>` |
|
|
408
|
-
| `#Card` | `<Card>` |
|
|
409
|
-
| `#Checkbox` | `<Checkbox>` |
|
|
410
|
-
| `#Chip` | `<Chip>` |
|
|
411
|
-
| `#Dialog` or `#Modal` | `<Dialog>` |
|
|
412
|
-
| `#Drawer` | `<Drawer>` |
|
|
413
|
-
| `#Input` or `#TextField` | `<TextField>` |
|
|
414
|
-
| `#List` | `<List>` |
|
|
415
|
-
| `#Menu` | `<Menu>` |
|
|
416
|
-
| `#Pagination` | `<Pagination>` |
|
|
417
|
-
| `#Progress` | `<LinearProgress>` |
|
|
418
|
-
| `#Radio` | `<Radio>` |
|
|
419
|
-
| `#Select` | `<Select>` |
|
|
420
|
-
| `#Slider` | `<Slider>` |
|
|
421
|
-
| `#Snackbar` | `<Snackbar>` |
|
|
422
|
-
| `#Switch` | `<Switch>` |
|
|
423
|
-
| `#Table` | `<Table>` |
|
|
424
|
-
| `#Tabs` | `<Tabs>` |
|
|
425
|
-
| `#Tooltip` | `<Tooltip>` |
|
|
426
|
-
|
|
427
|
-
### Form Components
|
|
428
|
-
|
|
429
|
-
| Figma Frame Name | React + SCSS | Bootstrap | MUI |
|
|
430
|
-
|------------------|--------------|-----------|-----|
|
|
431
|
-
| `#Input` | `<input>` | `<input class="form-control">` | `<TextField>` |
|
|
432
|
-
| `#Select` | `<select>` | `<select class="form-select">` | `<Select>` |
|
|
433
|
-
| `#Checkbox` | `<input type="checkbox">` | `<input class="form-check-input">` | `<Checkbox>` |
|
|
434
|
-
| `#Radio` | `<input type="radio">` | `<input class="form-check-input">` | `<Radio>` |
|
|
435
|
-
| `#Switch` | `<input type="checkbox">` | `<div class="form-switch">` | `<Switch>` |
|
|
436
|
-
| `#Textarea` | `<textarea>` | `<textarea class="form-control">` | `<TextField multiline>` |
|
|
437
|
-
| `#FormGroup` | `<div class="form-group">` | `<div class="mb-3">` | `<FormControl>` |
|
|
438
|
-
|
|
439
|
-
---
|
|
440
|
-
|
|
441
|
-
## For Designers
|
|
442
|
-
|
|
443
|
-
### Figma Rules
|
|
444
|
-
|
|
445
|
-
1. **`#` prefix** - Add to frame name to export
|
|
446
|
-
2. **Auto Layout** - Always use to maintain structure
|
|
447
|
-
3. **Descriptive names** - `title`, `content`, not "Frame 1"
|
|
448
|
-
4. **PascalCase** - `#ButtonPrimary`, not `#button-primary`
|
|
449
|
-
|
|
450
|
-
### Correct structure example
|
|
451
|
-
|
|
452
|
-
```
|
|
453
|
-
#CardProduct (Frame, Auto Layout Vertical)
|
|
454
|
-
├── image (Rectangle, Aspect Ratio 16:9)
|
|
455
|
-
├── content (Frame, Auto Layout Vertical, Padding 16px)
|
|
456
|
-
│ ├── title (Text, Heading/H3)
|
|
457
|
-
│ ├── description (Text, Body/Small)
|
|
458
|
-
│ └── price (Text, Heading/H2)
|
|
459
|
-
└── actions (Frame, Auto Layout Horizontal)
|
|
460
|
-
└── button (Instance of #Button)
|
|
461
|
-
```
|
|
462
|
-
|
|
463
|
-
---
|
|
464
|
-
|
|
465
|
-
## Environment Variables
|
|
466
|
-
|
|
467
|
-
| Variable | Description |
|
|
468
|
-
|----------|-------------|
|
|
469
|
-
| `FIGMA_TOKEN` | Figma access token |
|
|
470
|
-
| `FIGMA_FILE_ID` | Figma file ID |
|
|
471
|
-
|
|
472
|
-
### How to get Figma Token
|
|
473
|
-
|
|
474
|
-
1. Go to [Figma Account Settings](https://www.figma.com/settings)
|
|
475
|
-
2. Navigate to "Personal Access Tokens"
|
|
476
|
-
3. Create a new token
|
|
477
|
-
|
|
478
|
-
### How to get File ID
|
|
479
|
-
|
|
480
|
-
The File ID is in your Figma file URL:
|
|
597
|
+
### Exemplos de Prompts
|
|
481
598
|
|
|
482
599
|
```
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
600
|
+
"Gere o componente #Button do Figma usando Tailwind"
|
|
601
|
+
"Gere todos os componentes marcados com Material UI"
|
|
602
|
+
"Sincronize os design tokens para variáveis SCSS"
|
|
603
|
+
"Preview do #LoginForm sem salvar"
|
|
486
604
|
```
|
|
487
605
|
|
|
488
606
|
---
|
|
489
607
|
|
|
490
|
-
##
|
|
608
|
+
## Autor
|
|
491
609
|
|
|
492
610
|
**Desiree Menezes** - [@desireemenezes](https://github.com/desireemenezes)
|
|
493
611
|
|
|
494
612
|
---
|
|
495
613
|
|
|
496
|
-
##
|
|
614
|
+
## Licença
|
|
497
615
|
|
|
498
|
-
|
|
616
|
+
Proprietário - Todos os direitos reservados.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptui-lib/codegen",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Code generator for PromptUI - generates React TSX and SCSS",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@promptui-lib/core": "0.1.
|
|
33
|
+
"@promptui-lib/core": "0.1.14"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^20.0.0",
|