@intentsolutionsio/fullstack-starter-pack 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.
@@ -0,0 +1,343 @@
1
+ ---
2
+ name: component-generator
3
+ description: >
4
+ Generate React components from descriptions with TypeScript and tests
5
+ shortcut: cg
6
+ category: frontend
7
+ difficulty: beginner
8
+ estimated_time: 2-5 minutes
9
+ ---
10
+ # Component Generator
11
+
12
+ Generates production-ready React components from natural language descriptions, including TypeScript types, styling, and tests.
13
+
14
+ ## What This Command Does
15
+
16
+ **Component Generation:**
17
+ - Creates React component with TypeScript
18
+ - Generates prop types and interfaces
19
+ - Adds basic styling (CSS modules or Tailwind)
20
+ - Creates test file (React Testing Library)
21
+ - Includes JSDoc comments
22
+ - Follows React best practices
23
+
24
+ **Output:** Complete component with types, styles, and tests
25
+
26
+ **Time:** 2-5 minutes
27
+
28
+ ---
29
+
30
+ ## Usage
31
+
32
+ ```bash
33
+ # Generate component from description
34
+ /component-generator "Create a Card component with image, title, description, and action button"
35
+
36
+ # Shortcut
37
+ /cg "Button component with loading state and icon support"
38
+
39
+ # Specify framework/style
40
+ /cg "Modal dialog with animations" --style tailwind --test vitest
41
+
42
+ # Generate with directory
43
+ /cg "UserProfile component" --output src/components/UserProfile
44
+ ```
45
+
46
+ ---
47
+
48
+ ## Example Output
49
+
50
+ **Input:**
51
+ ```
52
+ /cg "Create a Button component with variants (primary, secondary, ghost), sizes (sm, md, lg), loading state, and icon support"
53
+ ```
54
+
55
+ **Generated Files:**
56
+
57
+ **Button.tsx:**
58
+ ```tsx
59
+ import { ButtonHTMLAttributes, ReactNode } from 'react'
60
+ import styles from './Button.module.css'
61
+
62
+ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
63
+ /** Button visual variant */
64
+ variant?: 'primary' | 'secondary' | 'ghost'
65
+ /** Button size */
66
+ size?: 'sm' | 'md' | 'lg'
67
+ /** Show loading spinner */
68
+ loading?: boolean
69
+ /** Icon to display before text */
70
+ icon?: ReactNode
71
+ /** Button content */
72
+ children: ReactNode
73
+ }
74
+
75
+ /**
76
+ * Button component with multiple variants and sizes
77
+ *
78
+ * @example
79
+ * ```tsx
80
+ * <Button variant="primary" size="md" onClick={handleClick}>
81
+ * Click me
82
+ * </Button>
83
+ * ```
84
+ */
85
+ export function Button({
86
+ variant = 'primary',
87
+ size = 'md',
88
+ loading = false,
89
+ icon,
90
+ children,
91
+ disabled,
92
+ className = '',
93
+ ...props
94
+ }: ButtonProps) {
95
+ return (
96
+ <button
97
+ className={`${styles.button} ${styles[variant]} ${styles[size]} ${className}`}
98
+ disabled={disabled || loading}
99
+ aria-busy={loading}
100
+ {...props}
101
+ >
102
+ {loading ? (
103
+ <span className={styles.spinner} aria-label="Loading" />
104
+ ) : (
105
+ <>
106
+ {icon && <span className={styles.icon}>{icon}</span>}
107
+ {children}
108
+ </>
109
+ )}
110
+ </button>
111
+ )
112
+ }
113
+ ```
114
+
115
+ **Button.module.css:**
116
+ ```css
117
+ .button {
118
+ display: inline-flex;
119
+ align-items: center;
120
+ justify-content: center;
121
+ gap: 0.5rem;
122
+ border: none;
123
+ border-radius: 0.375rem;
124
+ font-weight: 500;
125
+ cursor: pointer;
126
+ transition: all 0.2s;
127
+ }
128
+
129
+ .button:disabled {
130
+ opacity: 0.5;
131
+ cursor: not-allowed;
132
+ }
133
+
134
+ /* Variants */
135
+ .primary {
136
+ background: #3b82f6;
137
+ color: white;
138
+ }
139
+
140
+ .primary:hover:not(:disabled) {
141
+ background: #2563eb;
142
+ }
143
+
144
+ .secondary {
145
+ background: #e5e7eb;
146
+ color: #374151;
147
+ }
148
+
149
+ .ghost {
150
+ background: transparent;
151
+ color: #3b82f6;
152
+ }
153
+
154
+ /* Sizes */
155
+ .sm {
156
+ padding: 0.5rem 1rem;
157
+ font-size: 0.875rem;
158
+ }
159
+
160
+ .md {
161
+ padding: 0.75rem 1.5rem;
162
+ font-size: 1rem;
163
+ }
164
+
165
+ .lg {
166
+ padding: 1rem 2rem;
167
+ font-size: 1.125rem;
168
+ }
169
+
170
+ .spinner {
171
+ display: inline-block;
172
+ width: 1em;
173
+ height: 1em;
174
+ border: 2px solid currentColor;
175
+ border-right-color: transparent;
176
+ border-radius: 50%;
177
+ animation: spin 0.6s linear infinite;
178
+ }
179
+
180
+ @keyframes spin {
181
+ to { transform: rotate(360deg); }
182
+ }
183
+ ```
184
+
185
+ **Button.test.tsx:**
186
+ ```tsx
187
+ import { render, screen, fireEvent } from '@testing-library/react'
188
+ import { Button } from './Button'
189
+
190
+ describe('Button', () => {
191
+ it('renders button with text', () => {
192
+ render(<Button>Click me</Button>)
193
+ expect(screen.getByRole('button')).toHaveTextContent('Click me')
194
+ })
195
+
196
+ it('handles click events', () => {
197
+ const handleClick = jest.fn()
198
+ render(<Button onClick={handleClick}>Click</Button>)
199
+
200
+ fireEvent.click(screen.getByRole('button'))
201
+ expect(handleClick).toHaveBeenCalledTimes(1)
202
+ })
203
+
204
+ it('shows loading state', () => {
205
+ render(<Button loading>Submit</Button>)
206
+
207
+ const button = screen.getByRole('button')
208
+ expect(button).toHaveAttribute('aria-busy', 'true')
209
+ expect(button).toBeDisabled()
210
+ })
211
+
212
+ it('disables button when disabled prop is true', () => {
213
+ render(<Button disabled>Disabled</Button>)
214
+ expect(screen.getByRole('button')).toBeDisabled()
215
+ })
216
+
217
+ it('renders with icon', () => {
218
+ const icon = <span data-testid="icon"></span>
219
+ render(<Button icon={icon}>With Icon</Button>)
220
+
221
+ expect(screen.getByTestId('icon')).toBeInTheDocument()
222
+ })
223
+
224
+ it('applies correct variant classes', () => {
225
+ const { rerender } = render(<Button variant="primary">Primary</Button>)
226
+ expect(screen.getByRole('button')).toHaveClass('primary')
227
+
228
+ rerender(<Button variant="secondary">Secondary</Button>)
229
+ expect(screen.getByRole('button')).toHaveClass('secondary')
230
+ })
231
+ })
232
+ ```
233
+
234
+ ---
235
+
236
+ ## Component Templates
237
+
238
+ ### Common Components Generated
239
+
240
+ **1. Card Component:**
241
+ ```tsx
242
+ <Card
243
+ image="/product.jpg"
244
+ title="Product Name"
245
+ description="Product description"
246
+ action={<Button>Buy Now</Button>}
247
+ />
248
+ ```
249
+
250
+ **2. Modal Component:**
251
+ ```tsx
252
+ <Modal
253
+ isOpen={isOpen}
254
+ onClose={handleClose}
255
+ title="Confirm Action"
256
+ >
257
+ <p>Are you sure?</p>
258
+ </Modal>
259
+ ```
260
+
261
+ **3. Form Field Component:**
262
+ ```tsx
263
+ <FormField
264
+ label="Email"
265
+ type="email"
266
+ error={errors.email}
267
+ required
268
+ />
269
+ ```
270
+
271
+ **4. Dropdown Component:**
272
+ ```tsx
273
+ <Dropdown
274
+ items={options}
275
+ value={selected}
276
+ onChange={handleChange}
277
+ placeholder="Select option"
278
+ />
279
+ ```
280
+
281
+ ---
282
+
283
+ ## Features
284
+
285
+ ### Accessibility Built-In
286
+ - Semantic HTML elements
287
+ - ARIA attributes where needed
288
+ - Keyboard navigation support
289
+ - Focus management
290
+ - Screen reader announcements
291
+
292
+ ### TypeScript Support
293
+ - Full type definitions
294
+ - Prop validation
295
+ - IntelliSense support
296
+ - Generic types where appropriate
297
+
298
+ ### Testing Included
299
+ - Unit tests with React Testing Library
300
+ - Accessibility tests
301
+ - User interaction tests
302
+ - Edge case coverage
303
+
304
+ ### Styling Options
305
+ - CSS Modules (default)
306
+ - Tailwind CSS
307
+ - Styled Components
308
+ - Emotion
309
+ - Plain CSS
310
+
311
+ ---
312
+
313
+ ## Best Practices Applied
314
+
315
+ **Component Structure:**
316
+ - Single responsibility
317
+ - Composable design
318
+ - Prop drilling avoided
319
+ - Performance optimized (React.memo where beneficial)
320
+
321
+ **Code Quality:**
322
+ - ESLint compliant
323
+ - Prettier formatted
324
+ - TypeScript strict mode
325
+ - JSDoc comments
326
+
327
+ **Testing:**
328
+ - 80%+ code coverage
329
+ - User-centric tests (not implementation details)
330
+ - Accessibility assertions
331
+ - Happy path + edge cases
332
+
333
+ ---
334
+
335
+ ## Related Commands
336
+
337
+ - `/css-utility-generator` - Generate utility CSS classes
338
+ - React Specialist (agent) - React architecture guidance
339
+ - UI/UX Expert (agent) - Design review
340
+
341
+ ---
342
+
343
+ **Generate components in seconds. Ship features faster.** ️