UI Builder Reorganization - Execution Plan
Step-by-step execution plan for simultaneous Phase 1 & 2
🚀 Reorganization Execution Plan
Status: Phase 1 & 2 Executing Simultaneously
Phase 1: Theme System Separation
✅ Step 1.1: Fixed Storage Integration
- Replaced MockStorageService with real GgStorage
- Configured theme-specific storage with 'speed' strategy
- Added 100KB micro-cache for CSS variables
- Verified offline-first + cloud sync capability
🔄 Step 1.2: Copy Theme Components to @theme-system/theme-showcase
From ui-builder → To theme-showcase:
libs/libs-ui/demos-lib/src/lib/ux-themes/components/
├── advanced-theme-effects/ → theme-showcase/components/effects/
├── color-showcase/ → theme-showcase/components/colors/
├── glass-card-demo/ → theme-showcase/components/effects/
├── gradient-demo/ → theme-showcase/components/effects/
├── gradient-showcase/ → theme-showcase/components/effects/
├── interactive-elements/ → theme-showcase/components/interactive/
├── modern-materials/ → theme-showcase/components/materials/
├── neumorphism-showcase/ → theme-showcase/components/effects/
├── theme-best-practices/ → theme-showcase/guides/
├── theme-editor-demo/ → theme-showcase/tools/
├── theme-guide/ → theme-showcase/guides/
├── theme-picker-demo/ → theme-showcase/tools/
├── theme-reference-guide/ → theme-showcase/guides/
├── theme-utility-demo/ → theme-showcase/components/utilities/
├── utility-classes-guide/ → theme-showcase/guides/
└── theme-typography-showcase → theme-showcase/components/typography/
🔄 Step 1.3: Add Theme Utilities
libs/libs-ui/demos-lib/src/lib/ui-work/
├── ux-colors/ → theme-showcase/utilities/colors/
└── ux-typography/ → theme-showcase/utilities/typography/
🔄 Step 1.4: Create Enhanced Theme Showcase Routes
- Integrate all theme components into THEME_SHOWCASE_ROUTES
- Create logical navigation structure
- Add metadata for AI trainability
Phase 2: Widget System Enhancement
🔄 Step 2.1: Create Widget Showcase Library
nx generate @nx/angular:library widget-showcase \
--directory=libs/libs-widgets/widget-showcase \
--standalone \
--buildable \
--publishable \
--importPath=@libs-widgets/widget-showcase
Structure:
libs/libs-widgets/widget-showcase/
├── src/
│ ├── index.ts
│ ├── lib/
│ │ ├── components/
│ │ │ ├── widget-showcase-home/
│ │ │ └── widget-category-showcase/
│ │ ├── demos/
│ │ │ ├── button-demo/
│ │ │ ├── input-demo/
│ │ │ ├── menu-demo/
│ │ │ ├── panel-demo/
│ │ │ ├── dashboard-demo/
│ │ │ ├── todo-demo/
│ │ │ └── ... (all other widget demos)
│ │ └── widget-showcase.routes.ts
│ └── widget-showcase.routes.ts
🔄 Step 2.2: Extract Widget Components
Pattern: Each demo has:
- Widget Component (actual widget) → Move to
@libs-widgets/widgets - Demo Component (showcase) → Move to
@libs-widgets/widget-showcase
Example - Button Widget:
// FROM: libs/libs-ui/demos-lib/src/lib/demos/buttons-demos/button-demo/
//
// EXTRACT:
// 1. UxButtonComponent → libs/libs-widgets/widgets/src/lib/widgets/button/
// 2. ButtonDemoComponent → libs/libs-widgets/widget-showcase/src/lib/demos/button-demo/
// 3. Button AI Generation → libs/libs-widgets/widget-builder/src/lib/generators/button-generator/
// 4. Button Presets → libs/libs-widgets/widgets/src/lib/presets/button-presets.ts
Widgets to Extract (Priority Order):
UxButtonComponent ⭐⭐⭐⭐⭐
- 5K+ lines, AI generation, presets
- Move core widget →
widgets/button/ - Move AI gen →
widget-builder/generators/ - Move demo →
widget-showcase/demos/button-demo/
UxMenuComponent ⭐⭐⭐⭐⭐
- 8 files, 12 themes, templates
- Move core →
widgets/menu/ - Move templates →
widgets/menu/templates/ - Move demo →
widget-showcase/demos/menu-demo/
UxInputComponent ⭐⭐⭐⭐
- Move →
widgets/input/
- Move →
UxPanelComponent ⭐⭐⭐⭐
- Move →
widgets/panel/
- Move →
UxDashboardComponent ⭐⭐⭐⭐
- Move →
widgets/dashboard/
- Move →
UxTodoComponent ⭐⭐⭐⭐
- 18 files, full app
- Move →
widgets/todo/
UxRangeComponent ⭐⭐⭐
UxToastComponent ⭐⭐⭐
UxTabsComponent ⭐⭐⭐
UxSelectComponent ⭐⭐⭐
UxSideNavComponent ⭐⭐⭐
UxTextBoxComponent ⭐⭐⭐
🔄 Step 2.3: Widget Metadata Registration
Create widget metadata for each widget:
// libs/libs-widgets/widgets/src/lib/widgets/button/button.metadata.ts
import { WidgetMetadata } from '@libs-widgets/widgets';
export const BUTTON_WIDGET_METADATA: WidgetMetadata = {
id: 'ux-button',
name: 'Button Widget',
category: 'input',
tags: ['button', 'action', 'interactive', 'clickable'],
description: 'A versatile button widget with theme integration and AI generation',
version: '1.0.0',
author: 'GoGrab Space',
// AI Trainability
aiTrainable: true,
aiDescription: 'Use this widget for any user action or interaction. Supports 50+ presets and AI-powered generation.',
// Configuration
configurable: true,
configSchema: {
size: ['small', 'medium', 'large'],
shape: ['square', 'rounded', 'pill'],
type: ['primary', 'secondary', 'tertiary', 'accent', 'success', 'warning', 'danger'],
shadow: ['none', 'small', 'medium', 'large', 'floating'],
icon: 'string',
iconPosition: ['left', 'right', 'only']
},
// Theme Integration
themeAware: true,
themeVariables: [
'--ux-primary',
'--ux-on-primary',
'--ux-surface',
'--ux-shadow'
],
// Storage
persistable: true,
storageKeys: ['button-presets', 'button-history'],
// Presets
presets: 50,
aiGeneration: true,
// Examples
examples: [
{
name: 'Primary Action',
config: { type: 'primary', size: 'large', text: 'Get Started' }
},
{
name: 'Secondary Action',
config: { type: 'secondary', size: 'medium', text: 'Learn More' }
}
]
};
🔄 Step 2.4: Integrate AI Generation with Widget Builder
Button AI Generation Integration:
// FROM: button-demo.component.ts (5K+ lines)
// EXTRACT: AI generation logic
// TO: libs/libs-widgets/widget-builder/src/lib/generators/button-generator.service.ts
@Injectable({ providedIn: 'root' })
export class ButtonGeneratorService {
private aiFactory = inject(AIFactoryService);
private storage = inject(StorageService);
async generateButton(prompt: string): Promise<ButtonConfig> {
// AI generation logic from button-demo
}
async savePreset(preset: ButtonPreset): Promise<void> {
// Save to widget-builder presets
}
getPresets(): ButtonPreset[] {
// Return all button presets
}
}
Integration Steps
🔄 Step 3.1: Update Routes
Update apps/gograb-space/src/app/app.routes.ts:
// Theme Showcase (NEW)
{
path: 'theme-showcase',
loadChildren: () => import('@theme-system/theme-showcase').then(m => m.THEME_SHOWCASE_ROUTES),
title: '🎨 Theme Showcase',
data: {
tool: 'theme-showcase',
icon: 'palette',
description: 'Explore theme system capabilities'
}
},
// Widget Showcase (NEW)
{
path: 'widget-showcase',
loadChildren: () => import('@libs-widgets/widget-showcase').then(m => m.WIDGET_SHOWCASE_ROUTES),
title: '🧩 Widget Showcase',
data: {
tool: 'widget-showcase',
icon: 'widgets',
description: 'Explore available widgets'
}
},
// UI Builder (REFOCUSED - optional, might deprecate)
{
path: 'ui-builder',
redirectTo: 'theme-showcase', // or keep for UX guides
},
// Backwards compatibility
{
path: 'ui-builder/themes',
redirectTo: 'theme-showcase'
},
{
path: 'ui-builder/widgets',
redirectTo: 'widget-showcase'
}
🔄 Step 3.2: Update Imports
Update all imports across the platform:
- Theme components →
@theme-system/theme-showcase - Widget components →
@libs-widgets/widgets - Widget demos →
@libs-widgets/widget-showcase
🔄 Step 3.3: Update Navigation
Update navigation menus:
- Add "Theme Showcase" link
- Add "Widget Showcase" link
- Update/remove "UI Builder" link
Testing Strategy
Phase 1 Testing:
- Theme switching works
- Theme storage persists
- Theme showcase components render
- Theme utilities display correctly
- No console errors
Phase 2 Testing:
- All widgets render in widget-showcase
- Widgets work in widget-builder
- AI generation works
- Widget metadata registered
- Widget presets load
- No circular dependencies
Integration Testing:
- Routes work
- Redirects work
- Navigation works
- Theme applies to widgets
- Storage persists across reloads
- Performance is optimal
Success Metrics
- ✅ Theme showcase has 20+ components
- ✅ Widget system has 15+ widgets
- ✅ Widget-builder can generate all widgets
- ✅ AI generation integrated
- ✅ Storage integration complete
- ✅ Performance: Theme switching < 50ms
- ✅ Performance: Widget render < 100ms
- ✅ Zero breaking changes to existing features
- ✅ All routes work with redirects
Rollback Plan
If issues arise:
- New libraries are isolated - no impact on existing code
- Routes use redirects - can revert easily
- Old ui-builder stays intact until migration complete
- Gradual migration allows testing at each step
Next Actions
- ✅ Copy theme components to theme-showcase
- ✅ Create widget-showcase library
- ✅ Extract first widget (Button) as proof of concept
- ⏳ Test integration
- ⏳ Continue with remaining widgets
- ⏳ Update routes and navigation
- ⏳ Final testing and documentation
Timeline
- Week 1: Theme separation + Widget showcase setup (IN PROGRESS)
- Week 2: Widget extraction (Button, Menu, Input, Panel, Dashboard)
- Week 3: Widget extraction (remaining widgets)
- Week 4: AI integration + testing
- Week 5: Routes, navigation, documentation
- Week 6: Final polish and deployment
Status: 🚀 EXECUTING BOTH PHASES SIMULTANEOUSLY Progress: Theme storage fixed ✅ | Analysis complete ✅ | Execution started ✅