AI BUTTON GENERATION
Comprehensive guidelines for AI-assisted development within the Editor platform
AI Button Generation System
Overview
The AI Button Generation system provides intelligent, automated button design creation with real-time customization, theme integration, and cross-platform export capabilities for the nx monorepo.
Features
🎨 Intelligent Design Variations
- Mood-based styling: Choose from friendly, professional, serious, playful, elegant, and bold moods
- Style variations: Modern, classic, minimal, rounded, and sharp styling options
- Industry-specific: Tailored designs for technology, healthcare, finance, education, retail, and creative industries
- Dynamic combinations: Over 30 unique design patterns based on mood-style-industry combinations
🎯 Smart Theme Integration
- Theme Color Support: Automatically use your app's existing theme colors
- Color Schemes: Primary, secondary, accent, success, warning, and error color schemes
- Custom Colors: Full color picker support with real-time preview
- Accessibility: Automatic contrast ratio calculation and color-blind friendly options
📱 Cross-Platform Export
- localStorage Integration: Seamlessly export designs across all nx apps
- Editor-web Compatible: Direct import into editor-web at port 5200
- Component Generation: Auto-generate Angular standalone components
- CSS Export: Complete CSS with responsive breakpoints and variants
How to Use
1. Access the AI Generator
Navigate to http://localhost:5300/#/ux/widgets/button and scroll to the "🤖 AI Button Generator" section.
2. Configure Your Design
Basic Settings
- Style: Choose your preferred visual style (modern, classic, minimal, etc.)
- Purpose: Define the button's function (call-to-action, navigation, form-submit, etc.)
- Mood: Select the emotional tone (friendly, professional, serious, etc.)
- Industry: Pick your target industry for optimized styling
- Size: Choose from small, medium, or large button sizes
- Text: Enter your button text
Color Configuration
Choose between two color modes:
Theme Colors (Recommended):
- Check "Use Theme Colors"
- Select a theme scheme (Primary, Secondary, Accent, etc.)
- Colors automatically adapt to your app's theme
Custom Colors:
- Uncheck "Use Theme Colors"
- Use color pickers to select primary and secondary colors
- Real-time preview updates automatically
Advanced Options
- Accessibility Priority: Enable for WCAG compliant designs
- Responsive Design: Automatic mobile and tablet optimizations
- Animation Support: Hover and focus state animations
3. Generate Designs
Click "✨ Generate AI Designs" to create 3 unique button variations:
- Primary Design: Solid button optimized for your specifications
- Outline Design: Border-based alternative for secondary actions
- Creative Design: Unique gradient or special effect button
4. Preview & Apply
- Live Preview: See buttons rendered with actual styles
- Apply Design: Apply any design to your current button widget
- Accessibility Score: View contrast ratios and accessibility compliance
- Usage Notes: Get recommendations for optimal usage
5. Export & Share
Export to Other Apps
- Click "📤 Export Widget" on any design
- Widget is saved to localStorage with key
exported-ai-widgets - Access in editor-web or other nx apps via
WidgetImportService
Copy CSS
- Click "📋 Copy CSS" to get complete CSS code
- Includes hover states, focus states, and responsive breakpoints
- Ready to use in any application
Technical Implementation
Core Services
ButtonGenerationService
generateButtonDesigns(request: ButtonGenerationRequest): Observable<ButtonDesign[]>
- Handles intelligent design generation
- Supports theme color integration
- Provides fallback designs when AI services unavailable
WidgetImportService
getExportedWidgets(): Observable<ImportedWidget[]>
importWidget(widget: ImportedWidget, targetApp: string): Observable<boolean>
exportAsFiles(widget: ImportedWidget): void
- Manages cross-app widget sharing
- Handles localStorage persistence
- Generates Angular component code
Data Flow
- User configures design parameters in UI
ButtonGenerationServiceprocesses request with theme colors- Enhanced fallback system creates varied designs based on mood-style combinations
- UI renders live previews with actual CSS
- Export system saves to localStorage for cross-app usage
Integration Points
With Theme System
- Automatically detects and uses theme colors when enabled
- Respects theme color schemes (primary, secondary, accent, etc.)
- Maintains consistency across the design system
With Widget System
- Exports compatible with existing widget architecture
- Supports all button widget properties and configurations
- Seamless integration with button-widget component
With Storage System
- Uses localStorage for persistence
- Compatible with existing database storage options
- Supports both local and cloud storage backends
API Reference
ButtonGenerationRequest Interface
interface ButtonGenerationRequest {
style: string; // Design style preference
purpose: string; // Button functionality
mood: string; // Emotional tone
primaryColor: string; // Main color (if not using theme)
secondaryColor: string; // Accent color
text: string; // Button text content
size: 'small' | 'medium' | 'large';
industry: string; // Target industry
accessibility: boolean; // Prioritize accessibility
useThemeColors?: boolean; // Use app theme colors
themeColorScheme?: 'primary' | 'secondary' | 'accent' | 'success' | 'warning' | 'error';
}
ButtonDesign Interface
interface ButtonDesign {
id: string;
name: string;
description: string;
styles: Record<string, any>; // Complete CSS styles
cssClass: string; // Generated CSS class name
cssCode: string; // Complete CSS code
properties: Record<string, any>; // Widget properties
accessibility: AccessibilityInfo; // WCAG compliance data
usage: UsageInfo; // Best practices recommendations
responsive: ResponsiveStyles; // Mobile/tablet variations
variants: ButtonVariants; // Outline/ghost/soft variations
themeTokens?: Record<string, string>; // CSS custom properties
}
Best Practices
Design Selection
- Primary buttons: Use solid designs for main actions
- Secondary buttons: Use outline designs for alternative actions
- Creative buttons: Use for marketing, CTAs, and attention-grabbing elements
Accessibility
- Always enable accessibility priority for public-facing applications
- Verify contrast ratios meet WCAG AA standards (4.5:1 minimum)
- Test with screen readers and keyboard navigation
Performance
- Export only needed variants to minimize CSS payload
- Use theme colors when possible for consistency
- Leverage responsive breakpoints for optimal mobile experience
Cross-App Usage
- Export designs early in development for team sharing
- Use consistent naming conventions for easy identification
- Document design intent in usage notes
Troubleshooting
Common Issues
"No designs generated"
- Check network connectivity for AI services
- Fallback designs should always generate - check console for errors
- Verify button-generation.service is properly imported
"Theme colors not applying"
- Ensure theme-application.service is properly configured
- Check that useThemeColors is enabled
- Verify theme color scheme is valid
"Export not working"
- Check localStorage permissions in browser
- Verify target app is running and accessible
- Ensure widget-import.service is available in target app
Development Mode
Enable debug mode in the component to see:
- AI generation logs
- Color processing details
- Export operation status
- Service availability checks
Future Enhancements
Planned Features
- AI Integration: Real OpenAI/Claude API integration when services available
- Design Library: Save and share custom design patterns
- Batch Export: Export multiple designs simultaneously
- Advanced Animations: Micro-interactions and transition effects
- A/B Testing: Compare design performance metrics
Contributing
To enhance the AI generation system:
- Extend
getCreativeFeatures()with new mood-style combinations - Add new theme color schemes in theme configuration
- Implement additional export formats (Figma, Sketch, etc.)
- Create industry-specific design patterns
Need Help? Check the component's debug mode for detailed logging and service status information.