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

🔄 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


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:

  1. Widget Component (actual widget) → Move to @libs-widgets/widgets
  2. 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):

  1. UxButtonComponent ⭐⭐⭐⭐⭐

    • 5K+ lines, AI generation, presets
    • Move core widget → widgets/button/
    • Move AI gen → widget-builder/generators/
    • Move demo → widget-showcase/demos/button-demo/
  2. UxMenuComponent ⭐⭐⭐⭐⭐

    • 8 files, 12 themes, templates
    • Move core → widgets/menu/
    • Move templates → widgets/menu/templates/
    • Move demo → widget-showcase/demos/menu-demo/
  3. UxInputComponent ⭐⭐⭐⭐

    • Move → widgets/input/
  4. UxPanelComponent ⭐⭐⭐⭐

    • Move → widgets/panel/
  5. UxDashboardComponent ⭐⭐⭐⭐

    • Move → widgets/dashboard/
  6. UxTodoComponent ⭐⭐⭐⭐

    • 18 files, full app
    • Move → widgets/todo/
  7. UxRangeComponent ⭐⭐⭐

  8. UxToastComponent ⭐⭐⭐

  9. UxTabsComponent ⭐⭐⭐

  10. UxSelectComponent ⭐⭐⭐

  11. UxSideNavComponent ⭐⭐⭐

  12. 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:

🔄 Step 3.3: Update Navigation

Update navigation menus:


Testing Strategy

Phase 1 Testing:

Phase 2 Testing:

Integration Testing:


Success Metrics


Rollback Plan

If issues arise:

  1. New libraries are isolated - no impact on existing code
  2. Routes use redirects - can revert easily
  3. Old ui-builder stays intact until migration complete
  4. Gradual migration allows testing at each step

Next Actions

  1. ✅ Copy theme components to theme-showcase
  2. ✅ Create widget-showcase library
  3. ✅ Extract first widget (Button) as proof of concept
  4. ⏳ Test integration
  5. ⏳ Continue with remaining widgets
  6. ⏳ Update routes and navigation
  7. ⏳ Final testing and documentation

Timeline


Status: 🚀 EXECUTING BOTH PHASES SIMULTANEOUSLY Progress: Theme storage fixed ✅ | Analysis complete ✅ | Execution started ✅