mozaic-mcp-server 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 (161) hide show
  1. package/INSTALLATION.md +232 -0
  2. package/README.md +262 -0
  3. package/SKILLS.md +411 -0
  4. package/bin/install-skills.js +171 -0
  5. package/data/mozaic.db +0 -0
  6. package/data/mozaic.db-shm +0 -0
  7. package/data/mozaic.db-wal +0 -0
  8. package/dist/__tests__/sanity-check.test.d.ts +2 -0
  9. package/dist/__tests__/sanity-check.test.d.ts.map +1 -0
  10. package/dist/__tests__/sanity-check.test.js +167 -0
  11. package/dist/__tests__/sanity-check.test.js.map +1 -0
  12. package/dist/__tests__/tools.integration.test.d.ts +2 -0
  13. package/dist/__tests__/tools.integration.test.d.ts.map +1 -0
  14. package/dist/__tests__/tools.integration.test.js +220 -0
  15. package/dist/__tests__/tools.integration.test.js.map +1 -0
  16. package/dist/db/queries.d.ts +144 -0
  17. package/dist/db/queries.d.ts.map +1 -0
  18. package/dist/db/queries.js +536 -0
  19. package/dist/db/queries.js.map +1 -0
  20. package/dist/db/schema.d.ts +4 -0
  21. package/dist/db/schema.d.ts.map +1 -0
  22. package/dist/db/schema.js +253 -0
  23. package/dist/db/schema.js.map +1 -0
  24. package/dist/index.d.ts +3 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +416 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/parsers/__tests__/docs-parser.test.d.ts +2 -0
  29. package/dist/parsers/__tests__/docs-parser.test.d.ts.map +1 -0
  30. package/dist/parsers/__tests__/docs-parser.test.js +251 -0
  31. package/dist/parsers/__tests__/docs-parser.test.js.map +1 -0
  32. package/dist/parsers/__tests__/icons-parser.test.d.ts +2 -0
  33. package/dist/parsers/__tests__/icons-parser.test.d.ts.map +1 -0
  34. package/dist/parsers/__tests__/icons-parser.test.js +169 -0
  35. package/dist/parsers/__tests__/icons-parser.test.js.map +1 -0
  36. package/dist/parsers/__tests__/react-parser.test.d.ts +2 -0
  37. package/dist/parsers/__tests__/react-parser.test.d.ts.map +1 -0
  38. package/dist/parsers/__tests__/react-parser.test.js +274 -0
  39. package/dist/parsers/__tests__/react-parser.test.js.map +1 -0
  40. package/dist/parsers/__tests__/scss-parser.test.d.ts +2 -0
  41. package/dist/parsers/__tests__/scss-parser.test.d.ts.map +1 -0
  42. package/dist/parsers/__tests__/scss-parser.test.js +364 -0
  43. package/dist/parsers/__tests__/scss-parser.test.js.map +1 -0
  44. package/dist/parsers/__tests__/tokens-parser.test.d.ts +2 -0
  45. package/dist/parsers/__tests__/tokens-parser.test.d.ts.map +1 -0
  46. package/dist/parsers/__tests__/tokens-parser.test.js +172 -0
  47. package/dist/parsers/__tests__/tokens-parser.test.js.map +1 -0
  48. package/dist/parsers/__tests__/vue-parser.test.d.ts +2 -0
  49. package/dist/parsers/__tests__/vue-parser.test.d.ts.map +1 -0
  50. package/dist/parsers/__tests__/vue-parser.test.js +207 -0
  51. package/dist/parsers/__tests__/vue-parser.test.js.map +1 -0
  52. package/dist/parsers/docs-parser.d.ts +4 -0
  53. package/dist/parsers/docs-parser.d.ts.map +1 -0
  54. package/dist/parsers/docs-parser.js +237 -0
  55. package/dist/parsers/docs-parser.js.map +1 -0
  56. package/dist/parsers/icons-parser.d.ts +33 -0
  57. package/dist/parsers/icons-parser.d.ts.map +1 -0
  58. package/dist/parsers/icons-parser.js +125 -0
  59. package/dist/parsers/icons-parser.js.map +1 -0
  60. package/dist/parsers/react-parser.d.ts +3 -0
  61. package/dist/parsers/react-parser.d.ts.map +1 -0
  62. package/dist/parsers/react-parser.js +406 -0
  63. package/dist/parsers/react-parser.js.map +1 -0
  64. package/dist/parsers/scss-parser.d.ts +9 -0
  65. package/dist/parsers/scss-parser.d.ts.map +1 -0
  66. package/dist/parsers/scss-parser.js +351 -0
  67. package/dist/parsers/scss-parser.js.map +1 -0
  68. package/dist/parsers/tokens/border-parser.d.ts +3 -0
  69. package/dist/parsers/tokens/border-parser.d.ts.map +1 -0
  70. package/dist/parsers/tokens/border-parser.js +83 -0
  71. package/dist/parsers/tokens/border-parser.js.map +1 -0
  72. package/dist/parsers/tokens/color-parser.d.ts +3 -0
  73. package/dist/parsers/tokens/color-parser.d.ts.map +1 -0
  74. package/dist/parsers/tokens/color-parser.js +88 -0
  75. package/dist/parsers/tokens/color-parser.js.map +1 -0
  76. package/dist/parsers/tokens/grid-parser.d.ts +3 -0
  77. package/dist/parsers/tokens/grid-parser.d.ts.map +1 -0
  78. package/dist/parsers/tokens/grid-parser.js +97 -0
  79. package/dist/parsers/tokens/grid-parser.js.map +1 -0
  80. package/dist/parsers/tokens/index.d.ts +9 -0
  81. package/dist/parsers/tokens/index.d.ts.map +1 -0
  82. package/dist/parsers/tokens/index.js +10 -0
  83. package/dist/parsers/tokens/index.js.map +1 -0
  84. package/dist/parsers/tokens/screen-parser.d.ts +3 -0
  85. package/dist/parsers/tokens/screen-parser.d.ts.map +1 -0
  86. package/dist/parsers/tokens/screen-parser.js +54 -0
  87. package/dist/parsers/tokens/screen-parser.js.map +1 -0
  88. package/dist/parsers/tokens/shadow-parser.d.ts +3 -0
  89. package/dist/parsers/tokens/shadow-parser.d.ts.map +1 -0
  90. package/dist/parsers/tokens/shadow-parser.js +62 -0
  91. package/dist/parsers/tokens/shadow-parser.js.map +1 -0
  92. package/dist/parsers/tokens/spacing-parser.d.ts +4 -0
  93. package/dist/parsers/tokens/spacing-parser.d.ts.map +1 -0
  94. package/dist/parsers/tokens/spacing-parser.js +85 -0
  95. package/dist/parsers/tokens/spacing-parser.js.map +1 -0
  96. package/dist/parsers/tokens/types.d.ts +33 -0
  97. package/dist/parsers/tokens/types.d.ts.map +1 -0
  98. package/dist/parsers/tokens/types.js +42 -0
  99. package/dist/parsers/tokens/types.js.map +1 -0
  100. package/dist/parsers/tokens/typography-parser.d.ts +3 -0
  101. package/dist/parsers/tokens/typography-parser.d.ts.map +1 -0
  102. package/dist/parsers/tokens/typography-parser.js +76 -0
  103. package/dist/parsers/tokens/typography-parser.js.map +1 -0
  104. package/dist/parsers/tokens-parser.d.ts +18 -0
  105. package/dist/parsers/tokens-parser.d.ts.map +1 -0
  106. package/dist/parsers/tokens-parser.js +57 -0
  107. package/dist/parsers/tokens-parser.js.map +1 -0
  108. package/dist/parsers/vue-parser.d.ts +3 -0
  109. package/dist/parsers/vue-parser.d.ts.map +1 -0
  110. package/dist/parsers/vue-parser.js +343 -0
  111. package/dist/parsers/vue-parser.js.map +1 -0
  112. package/dist/tools/generate-react-component.d.ts +35 -0
  113. package/dist/tools/generate-react-component.d.ts.map +1 -0
  114. package/dist/tools/generate-react-component.js +81 -0
  115. package/dist/tools/generate-react-component.js.map +1 -0
  116. package/dist/tools/generate-vue-component.d.ts +35 -0
  117. package/dist/tools/generate-vue-component.d.ts.map +1 -0
  118. package/dist/tools/generate-vue-component.js +81 -0
  119. package/dist/tools/generate-vue-component.js.map +1 -0
  120. package/dist/tools/get-component-info.d.ts +52 -0
  121. package/dist/tools/get-component-info.d.ts.map +1 -0
  122. package/dist/tools/get-component-info.js +94 -0
  123. package/dist/tools/get-component-info.js.map +1 -0
  124. package/dist/tools/get-css-utility.d.ts +41 -0
  125. package/dist/tools/get-css-utility.d.ts.map +1 -0
  126. package/dist/tools/get-css-utility.js +57 -0
  127. package/dist/tools/get-css-utility.js.map +1 -0
  128. package/dist/tools/get-design-tokens.d.ts +44 -0
  129. package/dist/tools/get-design-tokens.d.ts.map +1 -0
  130. package/dist/tools/get-design-tokens.js +124 -0
  131. package/dist/tools/get-design-tokens.js.map +1 -0
  132. package/dist/tools/get-icon.d.ts +32 -0
  133. package/dist/tools/get-icon.d.ts.map +1 -0
  134. package/dist/tools/get-icon.js +108 -0
  135. package/dist/tools/get-icon.js.map +1 -0
  136. package/dist/tools/get-install-info.d.ts +39 -0
  137. package/dist/tools/get-install-info.d.ts.map +1 -0
  138. package/dist/tools/get-install-info.js +160 -0
  139. package/dist/tools/get-install-info.js.map +1 -0
  140. package/dist/tools/list-components.d.ts +32 -0
  141. package/dist/tools/list-components.d.ts.map +1 -0
  142. package/dist/tools/list-components.js +62 -0
  143. package/dist/tools/list-components.js.map +1 -0
  144. package/dist/tools/list-css-utilities.d.ts +27 -0
  145. package/dist/tools/list-css-utilities.d.ts.map +1 -0
  146. package/dist/tools/list-css-utilities.js +48 -0
  147. package/dist/tools/list-css-utilities.js.map +1 -0
  148. package/dist/tools/search-documentation.d.ts +37 -0
  149. package/dist/tools/search-documentation.d.ts.map +1 -0
  150. package/dist/tools/search-documentation.js +120 -0
  151. package/dist/tools/search-documentation.js.map +1 -0
  152. package/dist/tools/search-icons.d.ts +41 -0
  153. package/dist/tools/search-icons.d.ts.map +1 -0
  154. package/dist/tools/search-icons.js +134 -0
  155. package/dist/tools/search-icons.js.map +1 -0
  156. package/package.json +98 -0
  157. package/skills/mozaic-css-utilities/skill.md +633 -0
  158. package/skills/mozaic-design-tokens/skill.md +621 -0
  159. package/skills/mozaic-icons/skill.md +624 -0
  160. package/skills/mozaic-react-builder/skill.md +652 -0
  161. package/skills/mozaic-vue-builder/skill.md +491 -0
@@ -0,0 +1,652 @@
1
+ ---
2
+ name: mozaic-react-builder
3
+ description: Interactive React/TSX component generator with Mozaic Design System. Helps discover, configure, and generate production-ready React components with TypeScript support, proper imports, and installation guidance.
4
+ version: 1.0.0
5
+ ---
6
+
7
+ # Mozaic React Builder
8
+
9
+ An interactive assistant for building React applications with the Mozaic Design System by ADEO. This skill helps you discover components, understand their props, generate ready-to-use TypeScript/JSX code, and set up installation properly.
10
+
11
+ ## What This Skill Does
12
+
13
+ 1. **Discover Components**: Browse Mozaic React components by category (forms, navigation, feedback, etc.)
14
+ 2. **Interactive Selection**: Propose component combinations based on your needs
15
+ 3. **Generate Code**: Create complete React/TSX code with proper imports and TypeScript types
16
+ 4. **Installation Guidance**: Provide package manager commands and setup instructions
17
+ 5. **Props Configuration**: Help configure component props with full type safety
18
+
19
+ ## MCP Tools Used
20
+
21
+ This skill uses the Mozaic MCP server tools:
22
+ - `mcp__mozaic__list_components` - Browse available components by category
23
+ - `mcp__mozaic__get_component_info` - Get detailed component information (props, events, types)
24
+ - `mcp__mozaic__generate_react_component` - Generate React/TSX component code
25
+ - `mcp__mozaic__get_install_info` - Get installation commands and imports
26
+
27
+ ## When to Use This Skill
28
+
29
+ Use this skill when you:
30
+ - Need to build React UI components with Mozaic
31
+ - Want to explore available Mozaic components
32
+ - Need help with component props and TypeScript types
33
+ - Want installation and import guidance
34
+ - Are building forms, navigation, modals, or other UI elements
35
+ - Need TypeScript-ready React code
36
+
37
+ ## Interactive Workflow
38
+
39
+ ### Step 1: Understanding Your Needs
40
+
41
+ When you activate this skill, I'll ask:
42
+
43
+ **"What type of component do you need to build?"**
44
+
45
+ Common options:
46
+ - A) Form (inputs, selects, checkboxes, validation)
47
+ - B) Navigation (tabs, breadcrumb, pagination)
48
+ - C) Modal/Dialog (overlay, confirmation, form modal)
49
+ - D) Button/Action (primary, secondary, with icons)
50
+ - E) Layout (cards, containers, grids)
51
+ - F) Data Display (tables, lists, badges)
52
+ - G) Other (describe your needs)
53
+
54
+ ### Step 2: Browse Available Components
55
+
56
+ Based on your answer, I'll use `mcp__mozaic__list_components` to show relevant components.
57
+
58
+ **Example**:
59
+ ```
60
+ For forms, Mozaic offers:
61
+ - TextInput (text, email, password fields)
62
+ - Select (dropdowns with single/multiple selection)
63
+ - Checkbox (single or group)
64
+ - Radio (radio button groups)
65
+ - Toggle (switch control)
66
+ - FileUpload (file input with drag-drop)
67
+ ```
68
+
69
+ ### Step 3: Component Details
70
+
71
+ I'll use `mcp__mozaic__get_component_info` to show:
72
+ - Available props with TypeScript types and defaults
73
+ - Events and callbacks
74
+ - Component examples
75
+ - TypeScript interfaces
76
+
77
+ **Example**:
78
+ ```typescript
79
+ // TextInput Props Interface
80
+ interface TextInputProps {
81
+ value: string; // Controlled value
82
+ onChange: (value: string) => void; // Change handler
83
+ label?: string; // Field label
84
+ placeholder?: string; // Placeholder text
85
+ type?: 'text' | 'email' | 'password' | 'number'; // Input type
86
+ disabled?: boolean; // Disable state
87
+ error?: string; // Error message
88
+ required?: boolean; // Required field
89
+ size?: 's' | 'm' | 'l'; // Size variant
90
+ }
91
+ ```
92
+
93
+ ### Step 4: Propose Component Combinations
94
+
95
+ I'll suggest 2-3 combinations that work well together:
96
+
97
+ **Example for "Login Form"**:
98
+
99
+ **Option 1: Simple Login**
100
+ ```tsx
101
+ import { TextInput, Button } from '@mozaic-ds/react';
102
+
103
+ function LoginForm() {
104
+ const [email, setEmail] = useState('');
105
+ const [password, setPassword] = useState('');
106
+
107
+ return (
108
+ <form>
109
+ <TextInput
110
+ label="Email"
111
+ type="email"
112
+ value={email}
113
+ onChange={setEmail}
114
+ />
115
+ <TextInput
116
+ label="Password"
117
+ type="password"
118
+ value={password}
119
+ onChange={setPassword}
120
+ />
121
+ <Button theme="primary">Login</Button>
122
+ </form>
123
+ );
124
+ }
125
+ ```
126
+
127
+ **Option 2: Enhanced Login with Validation**
128
+ ```tsx
129
+ import { useState } from 'react';
130
+ import { TextInput, Button, Checkbox } from '@mozaic-ds/react';
131
+
132
+ interface FormErrors {
133
+ email?: string;
134
+ password?: string;
135
+ }
136
+
137
+ function LoginForm() {
138
+ const [email, setEmail] = useState('');
139
+ const [password, setPassword] = useState('');
140
+ const [rememberMe, setRememberMe] = useState(false);
141
+ const [errors, setErrors] = useState<FormErrors>({});
142
+
143
+ const isValid = email && password;
144
+
145
+ const handleSubmit = (e: React.FormEvent) => {
146
+ e.preventDefault();
147
+ // Your submit logic
148
+ };
149
+
150
+ return (
151
+ <form onSubmit={handleSubmit}>
152
+ <TextInput
153
+ label="Email"
154
+ type="email"
155
+ value={email}
156
+ onChange={setEmail}
157
+ error={errors.email}
158
+ required
159
+ />
160
+ <TextInput
161
+ label="Password"
162
+ type="password"
163
+ value={password}
164
+ onChange={setPassword}
165
+ error={errors.password}
166
+ required
167
+ />
168
+ <Checkbox
169
+ checked={rememberMe}
170
+ onChange={setRememberMe}
171
+ label="Remember me"
172
+ />
173
+ <Button
174
+ theme="primary"
175
+ disabled={!isValid}
176
+ >
177
+ Login
178
+ </Button>
179
+ </form>
180
+ );
181
+ }
182
+ ```
183
+
184
+ ### Step 5: Refinement & Configuration
185
+
186
+ You can:
187
+ - Choose an option: "I like Option 2"
188
+ - Customize: "Add a forgot password link"
189
+ - Combine: "Use Option 1 but add TypeScript from Option 2"
190
+ - Request changes: "Make the button larger"
191
+ - Ask for TypeScript types: "Show me the full type definitions"
192
+
193
+ ### Step 6: Generate Final Code
194
+
195
+ I'll use `mcp__mozaic__generate_react_component` to create complete code:
196
+
197
+ ```tsx
198
+ import { useState, FormEvent } from 'react';
199
+ import { TextInput, Button, Checkbox } from '@mozaic-ds/react';
200
+ import '@mozaic-ds/react/dist/styles.css';
201
+
202
+ interface FormData {
203
+ email: string;
204
+ password: string;
205
+ rememberMe: boolean;
206
+ }
207
+
208
+ interface FormErrors {
209
+ email?: string;
210
+ password?: string;
211
+ }
212
+
213
+ export function LoginForm() {
214
+ const [formData, setFormData] = useState<FormData>({
215
+ email: '',
216
+ password: '',
217
+ rememberMe: false
218
+ });
219
+ const [errors, setErrors] = useState<FormErrors>({});
220
+
221
+ const isValid = formData.email && formData.password;
222
+
223
+ const handleSubmit = (e: FormEvent<HTMLFormElement>) => {
224
+ e.preventDefault();
225
+ // Your submit logic
226
+ console.log('Form submitted:', formData);
227
+ };
228
+
229
+ return (
230
+ <form onSubmit={handleSubmit} className="login-form">
231
+ <TextInput
232
+ label="Email"
233
+ type="email"
234
+ placeholder="Enter your email"
235
+ value={formData.email}
236
+ onChange={(value) => setFormData({ ...formData, email: value })}
237
+ error={errors.email}
238
+ required
239
+ />
240
+ <TextInput
241
+ label="Password"
242
+ type="password"
243
+ placeholder="Enter your password"
244
+ value={formData.password}
245
+ onChange={(value) => setFormData({ ...formData, password: value })}
246
+ error={errors.password}
247
+ required
248
+ />
249
+ <Checkbox
250
+ checked={formData.rememberMe}
251
+ onChange={(checked) => setFormData({ ...formData, rememberMe: checked })}
252
+ label="Remember me"
253
+ />
254
+ <Button
255
+ theme="primary"
256
+ size="l"
257
+ disabled={!isValid}
258
+ type="submit"
259
+ >
260
+ Login
261
+ </Button>
262
+ </form>
263
+ );
264
+ }
265
+ ```
266
+
267
+ ```css
268
+ /* styles.css */
269
+ .login-form {
270
+ display: flex;
271
+ flex-direction: column;
272
+ gap: 1rem;
273
+ max-width: 400px;
274
+ }
275
+ ```
276
+
277
+ ### Step 7: Installation Guidance
278
+
279
+ I'll use `mcp__mozaic__get_install_info` to provide:
280
+
281
+ **Package Manager Choice**:
282
+ - npm
283
+ - yarn
284
+ - pnpm (default)
285
+
286
+ **Installation Commands**:
287
+ ```bash
288
+ # Install Mozaic React
289
+ pnpm add @mozaic-ds/react
290
+
291
+ # Install peer dependencies
292
+ pnpm add react@^18.0.0 react-dom@^18.0.0
293
+
294
+ # Install TypeScript (if not already installed)
295
+ pnpm add -D typescript @types/react @types/react-dom
296
+ ```
297
+
298
+ **Import Setup**:
299
+ ```tsx
300
+ // In your component or App.tsx
301
+ import { TextInput, Button } from '@mozaic-ds/react';
302
+ import '@mozaic-ds/react/dist/styles.css';
303
+ ```
304
+
305
+ **TypeScript Configuration** (tsconfig.json):
306
+ ```json
307
+ {
308
+ "compilerOptions": {
309
+ "jsx": "react-jsx",
310
+ "esModuleInterop": true,
311
+ "strict": true
312
+ }
313
+ }
314
+ ```
315
+
316
+ ## Common Use Cases
317
+
318
+ ### Use Case 1: Contact Form
319
+
320
+ **User**: "I need a contact form with TypeScript"
321
+
322
+ **Workflow**:
323
+ 1. List form components
324
+ 2. Propose: Name, Email, Message (textarea), Submit button
325
+ 3. Show validation patterns with TypeScript
326
+ 4. Generate code with proper types
327
+ 5. Provide installation commands
328
+
329
+ ### Use Case 2: Navigation Tabs
330
+
331
+ **User**: "Build tab navigation for dashboard"
332
+
333
+ **Workflow**:
334
+ 1. Show navigation components
335
+ 2. Demonstrate Tabs component
336
+ 3. Configure tabs with icons and TypeScript
337
+ 4. Generate code with tab content
338
+ 5. Provide styling guidance
339
+
340
+ ### Use Case 3: Modal Dialog
341
+
342
+ **User**: "Confirmation modal for delete action"
343
+
344
+ **Workflow**:
345
+ 1. Show feedback components
346
+ 2. Demonstrate Modal component
347
+ 3. Configure: title, message, actions with TypeScript
348
+ 4. Add danger button styling
349
+ 5. Generate code with controlled visibility
350
+
351
+ ### Use Case 4: Data Table
352
+
353
+ **User**: "Display user list in a table with TypeScript"
354
+
355
+ **Workflow**:
356
+ 1. Show data-display components
357
+ 2. Demonstrate Table component
358
+ 3. Configure columns with proper types
359
+ 4. Add pagination and row actions
360
+ 5. Generate code with typed data
361
+
362
+ ## Component Categories Reference
363
+
364
+ ### Form Components
365
+ - **TextInput**: Text, email, password, number inputs
366
+ - **Select**: Dropdown with single/multiple selection
367
+ - **Checkbox**: Single checkbox or checkbox group
368
+ - **Radio**: Radio button groups
369
+ - **Toggle**: Switch control
370
+ - **FileUpload**: File input with drag-drop support
371
+ - **DatePicker**: Date selection
372
+ - **Textarea**: Multi-line text input
373
+
374
+ ### Navigation Components
375
+ - **Tabs**: Tab navigation with content panels
376
+ - **Breadcrumb**: Hierarchical navigation trail
377
+ - **Pagination**: Page navigation controls
378
+ - **Stepper**: Multi-step progress indicator
379
+
380
+ ### Feedback Components
381
+ - **Modal**: Overlay dialog/modal
382
+ - **Toast**: Notification messages
383
+ - **Alert**: Inline alerts and warnings
384
+ - **ProgressBar**: Progress indication
385
+ - **Loader**: Loading spinners
386
+
387
+ ### Action Components
388
+ - **Button**: Primary, secondary, tertiary buttons
389
+ - **IconButton**: Button with icon only
390
+ - **Link**: Styled hyperlinks
391
+
392
+ ### Layout Components
393
+ - **Card**: Content container with header/footer
394
+ - **Accordion**: Collapsible content sections
395
+ - **Divider**: Visual separator
396
+
397
+ ### Data Display Components
398
+ - **Table**: Data grid with sorting/filtering
399
+ - **Badge**: Status indicators
400
+ - **Tag**: Labeled items
401
+ - **Avatar**: User profile images
402
+
403
+ ## Best Practices
404
+
405
+ ### 1. Use TypeScript for Type Safety
406
+ ```tsx
407
+ // Good: Define interfaces for your data
408
+ interface User {
409
+ id: number;
410
+ name: string;
411
+ email: string;
412
+ }
413
+
414
+ interface UserFormProps {
415
+ user?: User;
416
+ onSubmit: (user: User) => void;
417
+ }
418
+
419
+ function UserForm({ user, onSubmit }: UserFormProps) {
420
+ // Component implementation
421
+ }
422
+ ```
423
+
424
+ ### 2. Controlled Components
425
+ ```tsx
426
+ // Good: Use controlled components
427
+ const [value, setValue] = useState('');
428
+
429
+ <TextInput
430
+ value={value}
431
+ onChange={setValue}
432
+ label="Username"
433
+ />
434
+
435
+ // Avoid: Uncontrolled components
436
+ <TextInput defaultValue="username" />
437
+ ```
438
+
439
+ ### 3. Proper Event Handling
440
+ ```tsx
441
+ // Good: Type your event handlers
442
+ const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
443
+ event.preventDefault();
444
+ // Your logic
445
+ };
446
+
447
+ <Button onClick={handleClick}>Submit</Button>
448
+ ```
449
+
450
+ ### 4. Component Composition
451
+ ```tsx
452
+ // Good: Compose components
453
+ function UserCard({ user }: { user: User }) {
454
+ return (
455
+ <Card>
456
+ <Card.Header>
457
+ <h2>{user.name}</h2>
458
+ </Card.Header>
459
+ <Card.Body>
460
+ <TextInput value={user.email} readOnly />
461
+ </Card.Body>
462
+ <Card.Footer>
463
+ <Button theme="primary">Edit</Button>
464
+ </Card.Footer>
465
+ </Card>
466
+ );
467
+ }
468
+ ```
469
+
470
+ ### 5. Use React Hooks Properly
471
+ ```tsx
472
+ // Good: Use hooks for state and effects
473
+ import { useState, useEffect, useCallback } from 'react';
474
+
475
+ function FormComponent() {
476
+ const [data, setData] = useState<FormData>({});
477
+
478
+ const handleSubmit = useCallback(() => {
479
+ // Submit logic
480
+ }, [data]);
481
+
482
+ useEffect(() => {
483
+ // Side effects
484
+ }, []);
485
+ }
486
+ ```
487
+
488
+ ### 6. Props Destructuring with Types
489
+ ```tsx
490
+ // Good: Destructure props with types
491
+ interface ButtonProps {
492
+ label: string;
493
+ onClick: () => void;
494
+ disabled?: boolean;
495
+ }
496
+
497
+ function CustomButton({ label, onClick, disabled = false }: ButtonProps) {
498
+ return <Button onClick={onClick} disabled={disabled}>{label}</Button>;
499
+ }
500
+ ```
501
+
502
+ ## TypeScript Patterns
503
+
504
+ ### Generic Components
505
+ ```tsx
506
+ interface SelectOption<T> {
507
+ value: T;
508
+ label: string;
509
+ }
510
+
511
+ interface TypedSelectProps<T> {
512
+ options: SelectOption<T>[];
513
+ value: T;
514
+ onChange: (value: T) => void;
515
+ }
516
+
517
+ function TypedSelect<T>({ options, value, onChange }: TypedSelectProps<T>) {
518
+ // Implementation
519
+ }
520
+ ```
521
+
522
+ ### Form State Management
523
+ ```tsx
524
+ type FormState<T> = {
525
+ values: T;
526
+ errors: Partial<Record<keyof T, string>>;
527
+ touched: Partial<Record<keyof T, boolean>>;
528
+ };
529
+
530
+ function useFormState<T>(initialValues: T) {
531
+ const [state, setState] = useState<FormState<T>>({
532
+ values: initialValues,
533
+ errors: {},
534
+ touched: {}
535
+ });
536
+
537
+ // Form logic
538
+ return state;
539
+ }
540
+ ```
541
+
542
+ ## Troubleshooting
543
+
544
+ ### Issue: TypeScript errors with props
545
+
546
+ **Solution**: Check prop types
547
+ ```tsx
548
+ // Use mcp__mozaic__get_component_info to verify prop types
549
+ // Ensure you're using the correct interface
550
+ ```
551
+
552
+ ### Issue: Styles not applying
553
+
554
+ **Solution**: Import CSS
555
+ ```tsx
556
+ import '@mozaic-ds/react/dist/styles.css';
557
+ ```
558
+
559
+ ### Issue: Components not rendering
560
+
561
+ **Solution**: Check React version compatibility
562
+ ```bash
563
+ pnpm list react react-dom
564
+ # Should be ^18.0.0 or higher
565
+ ```
566
+
567
+ ### Issue: Event handlers not working
568
+
569
+ **Solution**: Use correct callback signatures
570
+ ```tsx
571
+ // Check component docs for callback types
572
+ onChange={(value: string) => handleChange(value)}
573
+ ```
574
+
575
+ ## Commands
576
+
577
+ When this skill is active:
578
+
579
+ - **"Show me [category] components"**: Browse components by category
580
+ - **"I need a [type]"**: Build specific component type
581
+ - **"How do I configure [component]?"**: Get component details with TypeScript
582
+ - **"Generate code for [description]"**: Create TypeScript component code
583
+ - **"Install instructions"**: Get setup guidance
584
+ - **"Show TypeScript examples"**: See typed usage examples
585
+ - **"What are the types for [component]?"**: Get TypeScript interfaces
586
+
587
+ ## Integration with Other Skills
588
+
589
+ This skill works well with:
590
+ - **mozaic-design-tokens**: Get color/spacing tokens for styling
591
+ - **mozaic-css-utilities**: Add layout utilities (Flexy grid, spacing)
592
+ - **mozaic-icons**: Add icons to buttons and components
593
+
594
+ ## Example Session
595
+
596
+ **User**: "I need a registration form with TypeScript"
597
+
598
+ **Skill**:
599
+ I'll help you build a registration form with Mozaic React components and full TypeScript support!
600
+
601
+ What fields do you need?
602
+ - A) Basic (name, email, password)
603
+ - B) Extended (+ phone, address, terms)
604
+ - C) Custom (tell me what fields)
605
+
606
+ **User**: "B - Extended"
607
+
608
+ **Skill**:
609
+ Perfect! Here's a registration form with extended fields and TypeScript:
610
+
611
+ [Uses `mcp__mozaic__list_components` and `mcp__mozaic__get_component_info`]
612
+
613
+ **Proposed Components**:
614
+ 1. TextInput (Name)
615
+ 2. TextInput (Email - type="email")
616
+ 3. TextInput (Password - type="password")
617
+ 4. TextInput (Phone - type="tel")
618
+ 5. Textarea (Address)
619
+ 6. Checkbox (Terms agreement)
620
+ 7. Button (Submit - theme="primary")
621
+
622
+ **TypeScript Interfaces**:
623
+ ```typescript
624
+ interface RegistrationData {
625
+ name: string;
626
+ email: string;
627
+ password: string;
628
+ phone: string;
629
+ address: string;
630
+ termsAccepted: boolean;
631
+ }
632
+ ```
633
+
634
+ [Uses `mcp__mozaic__generate_react_component`]
635
+
636
+ Here's your complete registration form with TypeScript... [Generated code]
637
+
638
+ Would you like me to:
639
+ - Add validation logic with types?
640
+ - Include password confirmation field?
641
+ - Add installation instructions?
642
+
643
+ **User**: "Add installation instructions"
644
+
645
+ **Skill**:
646
+ [Uses `mcp__mozaic__get_install_info`]
647
+
648
+ Here's how to install and set up...
649
+
650
+ ---
651
+
652
+ **Let's build amazing React applications with Mozaic Design System and TypeScript!**