@adlas/create-app 1.0.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.
Files changed (79) hide show
  1. package/README.md +476 -0
  2. package/dist/cli.d.ts +3 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +39 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/commands/figma.d.ts +16 -0
  7. package/dist/commands/figma.d.ts.map +1 -0
  8. package/dist/commands/figma.js +172 -0
  9. package/dist/commands/figma.js.map +1 -0
  10. package/dist/commands/index.d.ts +5 -0
  11. package/dist/commands/index.d.ts.map +1 -0
  12. package/dist/commands/index.js +5 -0
  13. package/dist/commands/index.js.map +1 -0
  14. package/dist/commands/init.d.ts +8 -0
  15. package/dist/commands/init.d.ts.map +1 -0
  16. package/dist/commands/init.js +1471 -0
  17. package/dist/commands/init.js.map +1 -0
  18. package/dist/commands/swagger.d.ts +16 -0
  19. package/dist/commands/swagger.d.ts.map +1 -0
  20. package/dist/commands/swagger.js +404 -0
  21. package/dist/commands/swagger.js.map +1 -0
  22. package/dist/commands/update.d.ts +15 -0
  23. package/dist/commands/update.d.ts.map +1 -0
  24. package/dist/commands/update.js +93 -0
  25. package/dist/commands/update.js.map +1 -0
  26. package/package.json +63 -0
  27. package/templates/.vscode/extensions.json +9 -0
  28. package/templates/.vscode/launch.json +26 -0
  29. package/templates/.vscode/settings.json +67 -0
  30. package/templates/.vscode/tasks.json +21 -0
  31. package/templates/boilerplate/config/fonts.ts +10 -0
  32. package/templates/boilerplate/config/navigationUrls.ts +47 -0
  33. package/templates/boilerplate/config/site.ts +96 -0
  34. package/templates/boilerplate/libs/I18n.ts +15 -0
  35. package/templates/boilerplate/libs/I18nNavigation.ts +5 -0
  36. package/templates/boilerplate/libs/I18nRouting.ts +9 -0
  37. package/templates/boilerplate/libs/env.ts +21 -0
  38. package/templates/boilerplate/libs/react-query/ReactQueryProvider.tsx +21 -0
  39. package/templates/boilerplate/libs/react-query/index.ts +2 -0
  40. package/templates/boilerplate/libs/react-query/queryClient.ts +62 -0
  41. package/templates/boilerplate/libs/react-query/queryKeys.ts +5 -0
  42. package/templates/boilerplate/public/images/index.ts +1 -0
  43. package/templates/boilerplate/reset.d.ts +2 -0
  44. package/templates/boilerplate/styles/globals.css +308 -0
  45. package/templates/boilerplate/types/i18n.ts +10 -0
  46. package/templates/boilerplate/types/locale.ts +8 -0
  47. package/templates/boilerplate/utils/file/fileConfig.ts +123 -0
  48. package/templates/boilerplate/utils/file/fileValidation.ts +78 -0
  49. package/templates/boilerplate/utils/file/imageCompression.ts +182 -0
  50. package/templates/boilerplate/utils/file/index.ts +3 -0
  51. package/templates/boilerplate/utils/helpers.ts +55 -0
  52. package/templates/boilerplate/validations/auth.validation.ts +92 -0
  53. package/templates/boilerplate/validations/commonValidations.ts +258 -0
  54. package/templates/boilerplate/validations/zodErrorMap.ts +101 -0
  55. package/templates/configs/.env.example +8 -0
  56. package/templates/configs/.prettierignore +23 -0
  57. package/templates/configs/.prettierrc.cjs +26 -0
  58. package/templates/configs/.prettierrc.icons.cjs +11 -0
  59. package/templates/configs/Dockerfile +6 -0
  60. package/templates/configs/commitlint.config.ts +8 -0
  61. package/templates/configs/eslint.config.mjs +119 -0
  62. package/templates/configs/knip.config.ts +32 -0
  63. package/templates/configs/lefthook.yml +42 -0
  64. package/templates/configs/lint-staged.config.js +8 -0
  65. package/templates/configs/next.config.template.ts +77 -0
  66. package/templates/configs/next.config.ts +43 -0
  67. package/templates/configs/package.json +75 -0
  68. package/templates/configs/postcss.config.mjs +15 -0
  69. package/templates/configs/svgr.config.mjs +129 -0
  70. package/templates/configs/tsconfig.json +75 -0
  71. package/templates/docs/AI_QUICK_REFERENCE.md +379 -0
  72. package/templates/docs/ARCHITECTURE_PATTERNS.md +927 -0
  73. package/templates/docs/DOCUMENTATION_INDEX.md +411 -0
  74. package/templates/docs/FIGMA_TO_CODE_GUIDE.md +768 -0
  75. package/templates/docs/IMPLEMENTATION_GUIDE.md +892 -0
  76. package/templates/docs/PROJECT_OVERVIEW.md +302 -0
  77. package/templates/docs/REFACTOR_PROGRESS.md +1113 -0
  78. package/templates/docs/SHADCN_TO_HEROUI_MIGRATION.md +1375 -0
  79. package/templates/docs/UI_COMPONENTS_GUIDE.md +893 -0
@@ -0,0 +1,768 @@
1
+ # Figma to Code Guide
2
+
3
+ Complete guide for converting Figma designs to code in the Berndorf e-commerce project. This guide helps AI and developers translate designs accurately using existing components.
4
+
5
+ ## Table of Contents
6
+
7
+ 1. [Figma MCP Server Usage](#figma-mcp-server-usage)
8
+ 2. [Design Analysis Workflow](#design-analysis-workflow)
9
+ 3. [Design Token Mapping](#design-token-mapping)
10
+ 4. [Component Mapping Rules](#component-mapping-rules)
11
+ 5. [AI Decision Tree](#ai-decision-tree)
12
+ 6. [Examples](#examples)
13
+ 7. [Quality Checklist](#quality-checklist)
14
+
15
+ ---
16
+
17
+ ## Figma MCP Server Usage
18
+
19
+ The Figma MCP Server allows AI to directly access and analyze Figma designs.
20
+
21
+ ### Prerequisites
22
+
23
+ 1. Figma file URL or file key
24
+ 2. MCP Server configured in Claude Code
25
+ 3. Access permissions to Figma file
26
+
27
+ ### Available Commands
28
+
29
+ ```typescript
30
+ // Get file information
31
+ mcp__figma_get_file({
32
+ file_key: "abc123xyz",
33
+ depth: 2 // Level of detail (1-4)
34
+ })
35
+
36
+ // Get specific node
37
+ mcp__figma_get_node({
38
+ file_key: "abc123xyz",
39
+ node_id: "123:456"
40
+ })
41
+
42
+ // Get comments
43
+ mcp__figma_get_comments({
44
+ file_key: "abc123xyz"
45
+ })
46
+ ```
47
+
48
+ ### Usage Pattern
49
+
50
+ ```
51
+ 1. User provides Figma URL: https://www.figma.com/file/ABC123/Design
52
+ 2. Extract file key: ABC123
53
+ 3. Call mcp__figma_get_file to analyze design
54
+ 4. Identify components, colors, spacing, typography
55
+ 5. Map to existing components
56
+ 6. Generate code
57
+ ```
58
+
59
+ ---
60
+
61
+ ## Design Analysis Workflow
62
+
63
+ Follow this workflow when converting Figma to code.
64
+
65
+ ### Step 1: Initial Design Analysis
66
+
67
+ **Questions to ask:**
68
+
69
+ 1. What is the overall layout structure?
70
+ - Single column? Multi-column grid?
71
+ - Sidebar? Full-width?
72
+ - Responsive breakpoints needed?
73
+
74
+ 2. What components are used?
75
+ - Buttons? Forms? Cards?
76
+ - Navigation? Modals?
77
+ - Custom or standard components?
78
+
79
+ 3. What are the design tokens?
80
+ - Colors (check against design system)
81
+ - Spacing (check against Tailwind scale)
82
+ - Typography (font sizes, weights)
83
+ - Border radius
84
+
85
+ 4. What interactions are needed?
86
+ - Hover states?
87
+ - Click actions?
88
+ - Form submissions?
89
+ - Animations?
90
+
91
+ ### Step 2: Component Inventory
92
+
93
+ Create an inventory of all UI elements:
94
+
95
+ ```markdown
96
+ ## Component Inventory
97
+
98
+ ### Existing Components Needed:
99
+ - [ ] Button (variant: solid, color: primary)
100
+ - [ ] Input (3 fields: email, name, message)
101
+ - [ ] Textarea (1 field: description)
102
+ - [ ] Card (for product display)
103
+
104
+ ### Element Components Needed:
105
+ - [ ] ProductCard
106
+ - [ ] HeaderBanner
107
+
108
+ ### Custom Components Needed:
109
+ - [ ] None (use existing only!)
110
+ ```
111
+
112
+ ### Step 3: Design Token Extraction
113
+
114
+ Extract all design tokens from Figma:
115
+
116
+ ```markdown
117
+ ## Design Tokens
118
+
119
+ ### Colors:
120
+ - Primary: #0066CC → use text-primary or bg-primary
121
+ - Text: #1A1A1A → use text-default-900
122
+ - Border: #E0E0E0 → use border-default-200
123
+
124
+ ### Spacing:
125
+ - Section padding: 64px → use py-16
126
+ - Card gap: 24px → use gap-6
127
+ - Button padding: 12px 24px → default button styling
128
+
129
+ ### Typography:
130
+ - Heading: 32px, Bold → use text-3xl font-bold
131
+ - Body: 16px, Regular → use text-base
132
+ - Caption: 14px, Medium → use text-sm font-medium
133
+
134
+ ### Border Radius:
135
+ - Buttons: 0px → radius="none" (default)
136
+ - Cards: 0px → rounded-none
137
+ ```
138
+
139
+ ### Step 4: Layout Planning
140
+
141
+ Plan the layout structure:
142
+
143
+ ```tsx
144
+ // Layout structure
145
+ <div className="container mx-auto px-4 py-16">
146
+ {/* Header Section */}
147
+ <div className="mb-8">
148
+ <h1 className="text-3xl font-bold mb-4">Title</h1>
149
+ <p className="text-base text-default-600">Description</p>
150
+ </div>
151
+
152
+ {/* Content Grid */}
153
+ <div className="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3">
154
+ {/* Items */}
155
+ </div>
156
+ </div>
157
+ ```
158
+
159
+ ---
160
+
161
+ ## Design Token Mapping
162
+
163
+ Map Figma design tokens to project tokens.
164
+
165
+ ### Color Mapping
166
+
167
+ | Figma Color | Hex Code | Project Token | Usage |
168
+ |-------------|----------|---------------|-------|
169
+ | Primary | #0066CC | `primary` | Buttons, links |
170
+ | Secondary | #6B7280 | `secondary` | Secondary actions |
171
+ | Success | #10B981 | `success` | Success states |
172
+ | Warning | #F59E0B | `warning` | Warning states |
173
+ | Danger | #EF4444 | `danger` | Error states, delete |
174
+ | Text Dark | #1A1A1A | `default-900` | Primary text |
175
+ | Text Medium | #6B7280 | `default-600` | Secondary text |
176
+ | Text Light | #9CA3AF | `default-400` | Placeholder text |
177
+ | Border | #E5E7EB | `default-200` | Borders |
178
+ | Background | #F9FAFB | `default-50` | Backgrounds |
179
+ | White | #FFFFFF | `background` | Cards, modals |
180
+
181
+ **Usage in Code:**
182
+
183
+ ```tsx
184
+ // Text colors
185
+ className="text-default-900" // Primary text
186
+ className="text-default-600" // Secondary text
187
+ className="text-primary" // Primary brand color
188
+
189
+ // Background colors
190
+ className="bg-primary" // Primary background
191
+ className="bg-default-50" // Light background
192
+ className="bg-background" // White background
193
+
194
+ // Border colors
195
+ className="border-default-200" // Default border
196
+ className="border-primary" // Primary border
197
+ ```
198
+
199
+ ### Spacing Mapping
200
+
201
+ Tailwind uses a consistent spacing scale (4px base unit).
202
+
203
+ | Figma Value | Tailwind Class | Pixels |
204
+ |-------------|----------------|--------|
205
+ | 4px | `gap-1`, `p-1`, `m-1` | 4px |
206
+ | 8px | `gap-2`, `p-2`, `m-2` | 8px |
207
+ | 12px | `gap-3`, `p-3`, `m-3` | 12px |
208
+ | 16px | `gap-4`, `p-4`, `m-4` | 16px |
209
+ | 24px | `gap-6`, `p-6`, `m-6` | 24px |
210
+ | 32px | `gap-8`, `p-8`, `m-8` | 32px |
211
+ | 48px | `gap-12`, `p-12`, `m-12` | 48px |
212
+ | 64px | `gap-16`, `p-16`, `m-16` | 64px |
213
+
214
+ **Usage in Code:**
215
+
216
+ ```tsx
217
+ // Padding
218
+ className="p-4" // 16px all sides
219
+ className="px-6" // 24px horizontal
220
+ className="py-8" // 32px vertical
221
+
222
+ // Margin
223
+ className="mb-6" // 24px bottom
224
+ className="mt-8" // 32px top
225
+
226
+ // Gap (for flex/grid)
227
+ className="gap-4" // 16px gap
228
+ className="gap-6" // 24px gap
229
+ ```
230
+
231
+ ### Typography Mapping
232
+
233
+ | Figma Size/Weight | Tailwind Classes | Usage |
234
+ |-------------------|------------------|-------|
235
+ | 12px Regular | `text-xs` | Small captions |
236
+ | 14px Regular | `text-sm` | Body text small |
237
+ | 14px Medium | `text-sm font-medium` | Labels |
238
+ | 16px Regular | `text-base` | Body text |
239
+ | 16px Semibold | `text-base font-semibold` | Emphasized text |
240
+ | 18px Semibold | `text-lg font-semibold` | Subheadings |
241
+ | 20px Bold | `text-xl font-bold` | Section titles |
242
+ | 24px Bold | `text-2xl font-bold` | Page titles |
243
+ | 32px Bold | `text-3xl font-bold` | Hero titles |
244
+
245
+ **Usage in Code:**
246
+
247
+ ```tsx
248
+ // Headings
249
+ <h1 className="text-3xl font-bold">Hero Title</h1>
250
+ <h2 className="text-2xl font-bold">Page Title</h2>
251
+ <h3 className="text-xl font-bold">Section Title</h3>
252
+
253
+ // Body text
254
+ <p className="text-base">Regular paragraph text</p>
255
+ <p className="text-sm text-default-600">Secondary text</p>
256
+
257
+ // Labels
258
+ <label className="text-sm font-medium">Form Label</label>
259
+ ```
260
+
261
+ ### Border Radius Mapping
262
+
263
+ Berndorf project uses **sharp corners (no border radius)** by default.
264
+
265
+ | Figma Radius | HeroUI Token | Tailwind Class |
266
+ |--------------|--------------|----------------|
267
+ | 0px | `none` | `rounded-none` |
268
+ | 4px | `sm` | `rounded-sm` |
269
+ | 8px | `md` | `rounded-md` |
270
+ | 12px | `lg` | `rounded-lg` |
271
+ | Full | `full` | `rounded-full` |
272
+
273
+ **Default for Berndorf:**
274
+ - Buttons: `radius="none"`
275
+ - Inputs: `radius="none"`
276
+ - Cards: `rounded-none`
277
+
278
+ ---
279
+
280
+ ## Component Mapping Rules
281
+
282
+ Map Figma components to existing HeroUI components.
283
+
284
+ ### Form Elements
285
+
286
+ | Figma Component | HeroUI Component | Example |
287
+ |----------------|------------------|---------|
288
+ | Text Input | `<Input />` | `<Input label="Email" />` |
289
+ | Password Input | `<PasswordInput />` | `<PasswordInput label="Password" />` |
290
+ | Text Area | `<Textarea />` | `<Textarea label="Message" />` |
291
+ | Dropdown | `<Select />` | `<Select><SelectItem>...</SelectItem></Select>` |
292
+ | Searchable Dropdown | `<Autocomplete />` | `<Autocomplete items={...} />` |
293
+ | Checkbox | `<Checkbox />` | `<Checkbox>Label</Checkbox>` |
294
+ | Radio Group | `<RadioGroup />` | `<RadioGroup><Radio>...</Radio></RadioGroup>` |
295
+ | Number Input | `<NumberInput />` | `<NumberInput min={1} max={100} />` |
296
+ | Date Picker | `<DatePicker />` | `<DatePicker label="Date" />` |
297
+ | File Upload | `<FileInput />` | `<FileInput accept=".pdf" />` |
298
+
299
+ ### Buttons
300
+
301
+ | Figma Design | Component Props | Example |
302
+ |-------------|----------------|---------|
303
+ | Filled Primary | `variant="solid" color="primary"` | `<Button variant="solid" color="primary">Submit</Button>` |
304
+ | Outlined | `variant="bordered"` | `<Button variant="bordered">Cancel</Button>` |
305
+ | Text Only | `variant="light"` | `<Button variant="light">Learn More</Button>` |
306
+ | Danger Filled | `variant="solid" color="danger"` | `<Button variant="solid" color="danger">Delete</Button>` |
307
+ | Danger Text | `variant="light" color="danger"` | `<Button variant="light" color="danger">Remove</Button>` |
308
+
309
+ ### Display Components
310
+
311
+ | Figma Component | HeroUI Component | Example |
312
+ |----------------|------------------|---------|
313
+ | Badge/Tag | `<Chip />` | `<Chip color="success">New</Chip>` |
314
+ | Modal/Dialog | `<Modal />` | `<Modal isOpen={open} onClose={...}>...</Modal>` |
315
+ | Tabs | `<Tabs />` | `<Tabs><Tab>...</Tab></Tabs>` |
316
+ | Breadcrumb | `<Breadcrumbs />` | `<Breadcrumbs><BreadcrumbItem>...</BreadcrumbItem></Breadcrumbs>` |
317
+ | Carousel | `<Carousel />` | `<Carousel items={slides} />` |
318
+
319
+ ### Cards
320
+
321
+ | Figma Design | Element Component | Example |
322
+ |-------------|-------------------|---------|
323
+ | Product Card | `<ProductCard />` | `<ProductCard name="..." price={...} />` |
324
+ | News Card | `<NewsCard />` | `<NewsCard title="..." image="..." />` |
325
+ | Collection Card | `<CollectionCard />` | `<CollectionCard name="..." />` |
326
+ | Store Card | `<StoreCard />` | `<StoreCard name="..." address="..." />` |
327
+
328
+ ---
329
+
330
+ ## AI Decision Tree
331
+
332
+ Follow this decision tree when analyzing Figma designs.
333
+
334
+ ### Decision Tree
335
+
336
+ ```
337
+ START: Analyze Figma Component
338
+
339
+ ├─> Is it a form element?
340
+ │ ├─> YES → Check Form Elements mapping table
341
+ │ │ └─> Use Input, Select, Checkbox, etc.
342
+ │ └─> NO → Continue
343
+
344
+ ├─> Is it a button?
345
+ │ ├─> YES → Check button style
346
+ │ │ ├─> Filled → variant="solid"
347
+ │ │ ├─> Outlined → variant="bordered"
348
+ │ │ └─> Text only → variant="light"
349
+ │ └─> NO → Continue
350
+
351
+ ├─> Is it a card showing content?
352
+ │ ├─> YES → Check card type
353
+ │ │ ├─> Product → Use ProductCard
354
+ │ │ ├─> News → Use NewsCard
355
+ │ │ ├─> Collection → Use CollectionCard
356
+ │ │ └─> Custom → Use HeroUI Card with custom content
357
+ │ └─> NO → Continue
358
+
359
+ ├─> Is it a navigation element?
360
+ │ ├─> YES → Check type
361
+ │ │ ├─> Tabs → Use Tabs
362
+ │ │ ├─> Breadcrumbs → Use Breadcrumbs
363
+ │ │ └─> Menu → Use HeroUI Dropdown
364
+ │ └─> NO → Continue
365
+
366
+ ├─> Is it an overlay/popup?
367
+ │ ├─> YES → Use Modal
368
+ │ └─> NO → Continue
369
+
370
+ ├─> Is it a badge/tag?
371
+ │ ├─> YES → Use Chip
372
+ │ └─> NO → Continue
373
+
374
+ └─> Custom layout
375
+ └─> Use div with Tailwind classes
376
+ ```
377
+
378
+ ### Analysis Checklist
379
+
380
+ For each Figma component, ask:
381
+
382
+ 1. **Does an exact UI component exist?**
383
+ - YES → Use it with proper props
384
+ - NO → Check element components
385
+
386
+ 2. **Does an element component exist?**
387
+ - YES → Use it (ProductCard, NewsCard, etc.)
388
+ - NO → Build with HeroUI primitives
389
+
390
+ 3. **What are the variants/states?**
391
+ - Hover state?
392
+ - Active state?
393
+ - Disabled state?
394
+ - Loading state?
395
+
396
+ 4. **What are the color tokens?**
397
+ - Map to primary, secondary, success, danger, default
398
+
399
+ 5. **What is the spacing?**
400
+ - Map to Tailwind spacing scale
401
+
402
+ 6. **Is it responsive?**
403
+ - Define breakpoints: sm, md, lg, xl
404
+
405
+ ---
406
+
407
+ ## Examples
408
+
409
+ ### Example 1: Login Form from Figma
410
+
411
+ **Figma Analysis:**
412
+ - 2 text inputs (email, password)
413
+ - 1 primary button
414
+ - 1 text link
415
+ - Spacing: 24px between elements
416
+ - Colors: Primary blue, gray text
417
+
418
+ **Code Implementation:**
419
+
420
+ ```tsx
421
+ 'use client';
422
+
423
+ import { useForm } from 'react-hook-form';
424
+ import { z } from 'zod';
425
+ import { Form } from '@/components/ui/form/Form';
426
+ import { Input } from '@/components/ui/Input';
427
+ import { PasswordInput } from '@/components/ui/PasswordInput';
428
+ import { Button } from '@/components/ui/Button';
429
+ import { useTranslations } from 'next-intl';
430
+
431
+ const schema = z.object({
432
+ email: z.string().email('Errors.validation.email'),
433
+ password: z.string().min(8, 'Errors.validation.minLength|{"min":8}'),
434
+ });
435
+
436
+ type FormData = z.infer<typeof schema>;
437
+
438
+ export function LoginForm() {
439
+ const t = useTranslations('Auth');
440
+ const form = useForm<FormData>();
441
+
442
+ const onSubmit = (data: FormData) => {
443
+ console.log(data);
444
+ };
445
+
446
+ return (
447
+ <div className="w-full max-w-md mx-auto">
448
+ <h1 className="text-2xl font-bold mb-6">{t('login')}</h1>
449
+
450
+ <Form form={form} validationSchema={schema}>
451
+ <Form.Item name="email">
452
+ {(props) => (
453
+ <Input
454
+ {...props}
455
+ label={t('email')}
456
+ type="email"
457
+ placeholder="your@email.com"
458
+ />
459
+ )}
460
+ </Form.Item>
461
+
462
+ <Form.Item name="password">
463
+ {(props) => (
464
+ <PasswordInput
465
+ {...props}
466
+ label={t('password')}
467
+ placeholder="Enter password"
468
+ />
469
+ )}
470
+ </Form.Item>
471
+
472
+ <div className="col-span-10">
473
+ <Button
474
+ variant="solid"
475
+ color="primary"
476
+ className="w-full"
477
+ onPress={form.handleSubmit(onSubmit)}
478
+ >
479
+ {t('submit')}
480
+ </Button>
481
+ </div>
482
+
483
+ <div className="col-span-10 text-center">
484
+ <a href="/auth/forgot-password" className="text-sm text-primary hover:underline">
485
+ {t('forgotPassword')}
486
+ </a>
487
+ </div>
488
+ </Form>
489
+ </div>
490
+ );
491
+ }
492
+ ```
493
+
494
+ ### Example 2: Product Grid from Figma
495
+
496
+ **Figma Analysis:**
497
+ - Grid of product cards
498
+ - 3 columns on desktop, 2 on tablet, 1 on mobile
499
+ - Each card shows image, name, price, add to cart button
500
+ - 24px gap between cards
501
+
502
+ **Code Implementation:**
503
+
504
+ ```tsx
505
+ 'use client';
506
+
507
+ import { ProductCard } from '@/components/elements/ProductCard';
508
+ import { useProductsQuery } from '@/services/product';
509
+
510
+ export function ProductGrid() {
511
+ const { data: products, isLoading } = useProductsQuery();
512
+
513
+ if (isLoading) {
514
+ return <div>Loading...</div>;
515
+ }
516
+
517
+ return (
518
+ <div className="container mx-auto px-4 py-8">
519
+ <h2 className="text-2xl font-bold mb-6">Our Products</h2>
520
+
521
+ <div className="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3">
522
+ {products?.map((product) => (
523
+ <ProductCard
524
+ key={product.id}
525
+ id={product.id}
526
+ name={product.name}
527
+ price={product.price}
528
+ image={product.primaryImage}
529
+ onAddToCart={(id) => console.log('Add to cart:', id)}
530
+ />
531
+ ))}
532
+ </div>
533
+ </div>
534
+ );
535
+ }
536
+ ```
537
+
538
+ ### Example 3: Hero Section from Figma
539
+
540
+ **Figma Analysis:**
541
+ - Full-width background image
542
+ - Centered text overlay
543
+ - Large heading (48px bold)
544
+ - Subheading (18px regular)
545
+ - CTA button
546
+ - 64px padding top/bottom
547
+
548
+ **Code Implementation:**
549
+
550
+ ```tsx
551
+ import { Button } from '@/components/ui/Button';
552
+ import Image from 'next/image';
553
+
554
+ export function HeroSection() {
555
+ return (
556
+ <div className="relative h-[500px] w-full">
557
+ {/* Background Image */}
558
+ <Image
559
+ src="/hero-background.jpg"
560
+ alt="Hero background"
561
+ fill
562
+ className="object-cover"
563
+ priority
564
+ />
565
+
566
+ {/* Overlay */}
567
+ <div className="absolute inset-0 bg-black/40" />
568
+
569
+ {/* Content */}
570
+ <div className="relative z-10 flex h-full flex-col items-center justify-center px-4 py-16 text-center text-white">
571
+ <h1 className="mb-4 text-5xl font-bold max-w-3xl">
572
+ Premium Cutlery Collection
573
+ </h1>
574
+ <p className="mb-8 text-lg max-w-2xl">
575
+ Discover our handcrafted cutlery designed for elegance and durability
576
+ </p>
577
+ <Button
578
+ variant="solid"
579
+ color="primary"
580
+ size="lg"
581
+ href="/products"
582
+ >
583
+ Explore Collection
584
+ </Button>
585
+ </div>
586
+ </div>
587
+ );
588
+ }
589
+ ```
590
+
591
+ ### Example 4: Filter Sidebar from Figma
592
+
593
+ **Figma Analysis:**
594
+ - Sidebar with filters
595
+ - Category checkboxes
596
+ - Price range inputs
597
+ - Apply filters button
598
+ - 16px padding, 12px gaps
599
+
600
+ **Code Implementation:**
601
+
602
+ ```tsx
603
+ 'use client';
604
+
605
+ import { useState } from 'react';
606
+ import { Checkbox } from '@/components/ui/Checkbox';
607
+ import { NumberInput } from '@/components/ui/NumberInput';
608
+ import { Button } from '@/components/ui/Button';
609
+ import { useProductStore } from '@/services/product';
610
+
611
+ export function FilterSidebar() {
612
+ const [selectedCategories, setSelectedCategories] = useState<string[]>([]);
613
+ const [minPrice, setMinPrice] = useState(0);
614
+ const [maxPrice, setMaxPrice] = useState(1000);
615
+ const setFilters = useProductStore((state) => state.setFilters);
616
+
617
+ const handleApply = () => {
618
+ setFilters({
619
+ categories: selectedCategories,
620
+ minPrice,
621
+ maxPrice,
622
+ });
623
+ };
624
+
625
+ return (
626
+ <div className="w-64 border-r border-default-200 p-4">
627
+ <h3 className="text-lg font-semibold mb-4">Filters</h3>
628
+
629
+ {/* Categories */}
630
+ <div className="mb-6">
631
+ <h4 className="text-sm font-medium mb-3">Categories</h4>
632
+ <div className="flex flex-col gap-3">
633
+ <Checkbox
634
+ isSelected={selectedCategories.includes('cutlery')}
635
+ onValueChange={(checked) => {
636
+ setSelectedCategories(
637
+ checked
638
+ ? [...selectedCategories, 'cutlery']
639
+ : selectedCategories.filter(c => c !== 'cutlery')
640
+ );
641
+ }}
642
+ >
643
+ Cutlery
644
+ </Checkbox>
645
+ <Checkbox
646
+ isSelected={selectedCategories.includes('cookware')}
647
+ onValueChange={(checked) => {
648
+ setSelectedCategories(
649
+ checked
650
+ ? [...selectedCategories, 'cookware']
651
+ : selectedCategories.filter(c => c !== 'cookware')
652
+ );
653
+ }}
654
+ >
655
+ Cookware
656
+ </Checkbox>
657
+ </div>
658
+ </div>
659
+
660
+ {/* Price Range */}
661
+ <div className="mb-6">
662
+ <h4 className="text-sm font-medium mb-3">Price Range</h4>
663
+ <div className="flex flex-col gap-3">
664
+ <NumberInput
665
+ label="Min"
666
+ value={minPrice}
667
+ onChange={setMinPrice}
668
+ min={0}
669
+ />
670
+ <NumberInput
671
+ label="Max"
672
+ value={maxPrice}
673
+ onChange={setMaxPrice}
674
+ min={0}
675
+ />
676
+ </div>
677
+ </div>
678
+
679
+ {/* Apply Button */}
680
+ <Button
681
+ variant="solid"
682
+ color="primary"
683
+ className="w-full"
684
+ onPress={handleApply}
685
+ >
686
+ Apply Filters
687
+ </Button>
688
+ </div>
689
+ );
690
+ }
691
+ ```
692
+
693
+ ---
694
+
695
+ ## Quality Checklist
696
+
697
+ Before completing Figma to code conversion:
698
+
699
+ ### Design Accuracy
700
+
701
+ - [ ] All colors match design tokens
702
+ - [ ] All spacing matches Tailwind scale
703
+ - [ ] All typography matches design
704
+ - [ ] All components match Figma exactly
705
+ - [ ] Hover states implemented
706
+ - [ ] Active states implemented
707
+ - [ ] Disabled states implemented
708
+
709
+ ### Component Usage
710
+
711
+ - [ ] Using existing UI components only
712
+ - [ ] No custom UI components created
713
+ - [ ] Element components used where available
714
+ - [ ] Props correctly configured
715
+ - [ ] Variants match design
716
+
717
+ ### Responsive Design
718
+
719
+ - [ ] Mobile layout tested (< 640px)
720
+ - [ ] Tablet layout tested (640px - 1024px)
721
+ - [ ] Desktop layout tested (> 1024px)
722
+ - [ ] Grid columns adjust correctly
723
+ - [ ] Text sizes scale appropriately
724
+ - [ ] Images are responsive
725
+
726
+ ### Accessibility
727
+
728
+ - [ ] Alt text for images
729
+ - [ ] Labels for form inputs
730
+ - [ ] Keyboard navigation works
731
+ - [ ] Color contrast meets WCAG AA
732
+ - [ ] Focus states visible
733
+
734
+ ### Code Quality
735
+
736
+ - [ ] TypeScript types defined
737
+ - [ ] No ESLint errors
738
+ - [ ] Translations used (no hardcoded text)
739
+ - [ ] Proper semantic HTML
740
+ - [ ] Clean, readable code
741
+
742
+ ### Performance
743
+
744
+ - [ ] Images optimized
745
+ - [ ] No unnecessary re-renders
746
+ - [ ] Lazy loading where appropriate
747
+ - [ ] Bundle size reasonable
748
+
749
+ ---
750
+
751
+ ## Summary
752
+
753
+ When converting Figma to code:
754
+
755
+ 1. **Analyze design thoroughly** using Figma MCP Server
756
+ 2. **Map design tokens** to project tokens
757
+ 3. **Use existing components** from UI library
758
+ 4. **Follow decision tree** for component selection
759
+ 5. **Implement responsively** with Tailwind breakpoints
760
+ 6. **Test thoroughly** against design and functionality
761
+ 7. **Verify quality** with checklist
762
+
763
+ ## Need More Information?
764
+
765
+ - **Quick Reference** → See `AI_QUICK_REFERENCE.md`
766
+ - **UI Components** → See `UI_COMPONENTS_GUIDE.md`
767
+ - **Architecture** → See `ARCHITECTURE_PATTERNS.md`
768
+ - **Implementation** → See `IMPLEMENTATION_GUIDE.md`