The effectiveness of the Component Generator heavily depends on the quality and completeness of your component analysis. This guide explains what information sources make for the best analysis and how to gather them.
- Component implementation (
.tsfiles) - Templates (inline or
.htmlfiles) - Styles (
.scss,.cssfiles) - Type definitions and interfaces
- Component stories showing different states
- Props documentation
- Usage examples
- Edge cases and variations
- Interactive examples
- README files
- JSDoc comments
- API documentation
- Design system documentation
- Real implementation examples from your codebase
- Integration patterns
- Service usage patterns
- Common combinations with other components
- Unit tests showing expected behavior
- Integration tests showing component relationships
- Test fixtures demonstrating prop combinations
- Edge case handling
Each source provides unique insights that help the AI understand:
-
Component Behavior
- Source code shows implementation
- Tests reveal edge cases
- Stories demonstrate intended use
-
Integration Patterns
- Usage examples show real-world applications
- Integration tests reveal component relationships
- Service interactions demonstrate dependencies
-
State Management
- Source code shows internal state
- Tests reveal state transitions
- Stories demonstrate state variations
-
Props and Events
- Type definitions show API design
- Stories show prop combinations
- Tests validate event handling
If your project doesn't use Storybook, you can still get good results by focusing on:
-
Test Coverage
- Unit tests often contain comprehensive usage examples
- Test fixtures show valid prop combinations
- Integration tests reveal component relationships
-
Code Comments
- JSDoc comments documenting props and usage
- Implementation comments explaining patterns
- TODO comments indicating potential issues
-
Real Usage
- Find multiple instances of component usage
- Look for different configurations
- Document common patterns
-
Type Definitions
- Props and their types
- Event definitions
- Interfaces and enums
-
Gather Multiple Examples
- Don't rely on a single usage pattern
- Look for edge cases and variations
- Document both simple and complex uses
-
Document Relationships
- Note which components are often used together
- Identify parent-child relationships
- Map service dependencies
-
Capture State Management
- Document state initialization
- Note state transitions
- Record side effects
-
Track Dependencies
- List required imports
- Note optional features
- Document service requirements
✅ Have you included:
- Complete component source code
- Documentation (Storybook or alternatives)
- At least 3 different usage examples
- Test cases or fixtures
- Type definitions
- Service interactions (if applicable)
- Common component combinations
- State management patterns
- Prop variations
- Event handling examples
-
Insufficient Examples
- Problem: Only analyzing the component in isolation
- Solution: Find multiple real-world usage examples
-
Missing Service Context
- Problem: Not documenting service dependencies
- Solution: Include service interaction patterns
-
Incomplete State Analysis
- Problem: Only capturing initial state
- Solution: Document state transitions and effects
-
Limited Pattern Recognition
- Problem: Missing common combinations
- Solution: Analyze multiple implementations
Better analysis leads to:
- More accurate component generation
- Better pattern matching
- Proper service integration
- Correct state management
- Appropriate prop usage
- Better type safety
Remember: The AI can only be as good as the analysis we provide. Comprehensive analysis leads to better generated components.