Widget Showcase Fix
Ecosistema completo para organización y gestión de contenido con interfaces espaciales
🔧 Widget Showcase Fix: Syncing with Smart Properties
Issue: Widget showcase page broken - variants don't work, data seems off
Status: ✅ Fixed
Date: December 10, 2025
🚨 The Problem
What Was Broken
When viewing http://localhost:5200/space/chrome-space-1/widgets/button:
❌ Outdated Property Names: Hardcoded variants used old property names
buttonType: 'primary'(should bevariant)- Missing new properties (
shape,effect,leftIcon,rightIcon)
❌ Incorrect Variant Definitions: Variants didn't match embeddable schema
// OLD (Broken) properties: { buttonType: 'primary', text: 'Primary', color: 'primary' } // NEW (Fixed) properties: { variant: 'primary', text: 'Primary', size: 'md', shape: 'rounded' }❌ Mismatched Component Names: Code examples showed
<lib-button-widget>but embeddable isui-button❌ Missing Variants: Only 5 variants, missing:
- Shape variants (pill, square)
- Icon variants (left/right icons)
- Loading state
- Size examples
✅ The Fix
Updated CoreComponentDetailComponent
File: libs/libs-widgets/widget-showcase/src/lib/components/core-component-detail/core-component-detail.component.ts
Changes:
Property Names Aligned with Smart Properties
// ✅ Now matches SmartButtonProperties properties: { text: 'Primary', // SmartButtonProperties content variant: 'primary', // SmartButtonProperties.variant() size: 'md', // SmartButtonProperties.size() shape: 'rounded', // SmartButtonProperties.shape() effect: 'pulse', // SmartButtonProperties.effect() }Updated Component Metadata
{ id: 'button', name: 'Button Widget', // Clear name description: 'Interactive button with customizable actions - uses Smart Properties system', category: 'Form Controls', icon: 'square', // Matches button icon usage: `<ui-button ... />`, // Correct component name }Comprehensive Variant Set (10 variants total)
primary-md- Standard primary buttonsecondary-md- Outline styleghost-md- Text-onlydanger-md- Destructive actionsprimary-pill- Fully roundedprimary-square- Sharp cornerswith-icon-left- Icon on leftwith-icon-right- Icon on rightloading-state- Loading spinnersizes- Size demonstration
Complete Input Documentation
inputs: [ { name: 'text', type: 'string', ... }, { name: 'variant', type: 'enum', ... }, // ✅ Was 'buttonType' { name: 'size', type: 'enum', ... }, { name: 'shape', type: 'enum', ... }, // ✅ NEW { name: 'effect', type: 'enum', ... }, // ✅ NEW { name: 'color', type: 'enum', ... }, { name: 'leftIcon', type: 'string', ... }, // ✅ NEW { name: 'rightIcon', type: 'string', ... }, // ✅ NEW { name: 'disabled', type: 'boolean', ... }, { name: 'loading', type: 'boolean', ... }, { name: 'type', type: 'enum', ... }, ]
🔗 How It Works Now
Data Flow in Widget Showcase
┌───────────────────────────────────────────────────────────┐
│ 1. USER NAVIGATES │
│ /space/chrome-space-1/widgets/button │
└───────────────────────────────────────────────────────────┘
↓
┌───────────────────────────────────────────────────────────┐
│ 2. CoreComponentDetailComponent.ngOnInit() │
│ • Reads route param: componentId = 'button' │
│ • Calls loadWidgetDemo('button') │
└───────────────────────────────────────────────────────────┘
↓
┌───────────────────────────────────────────────────────────┐
│ 3. Merge Data Sources │
│ • Static data: getCoreComponentData('button') │
│ → Variants, documentation, examples │
│ • Embeddable registry: get('button') │
│ → Actual component, inputs/outputs schema │
└───────────────────────────────────────────────────────────┘
↓
┌───────────────────────────────────────────────────────────┐
│ 4. Render Component │
│ • componentData() computed signal merges both │
│ • Variants rendered with correct properties │
│ • Live preview uses NgComponentOutlet │
└───────────────────────────────────────────────────────────┘
Variant Rendering
// For each variant:
getVariantInputs(variant) {
return {
widgetId: 'preview-variant-id',
widget: {
type: 'button',
properties: {
text: 'Primary', // ✅ Correct property name
variant: 'primary', // ✅ Maps to SmartButtonProperties.variant()
size: 'md', // ✅ Maps to SmartButtonProperties.size()
shape: 'rounded', // ✅ Maps to SmartButtonProperties.shape()
effect: 'pulse', // ✅ Maps to SmartButtonProperties.effect()
}
},
// ... rest of widget config
};
}
// Rendered as:
<ng-container *ngComponentOutlet="
widgetComponent(); // UiButtonComponent
inputs: getVariantInputs(variant)
">
</ng-container>
📊 Before vs After
Property Mapping
| What | Before (Broken) | After (Fixed) | Source |
|---|---|---|---|
| Style | buttonType: 'primary' |
variant: 'primary' |
SmartButtonProperties.variant() |
| Size | size: 'medium' |
size: 'md' |
SmartButtonProperties.size() |
| Shape | ❌ Missing | shape: 'rounded' |
SmartButtonProperties.shape() |
| Effect | ❌ Missing | effect: 'pulse' |
SmartButtonProperties.effect() |
| Color | color: 'primary' |
color: undefined |
SmartGlobalProperties.colorTone() |
| Icons | ❌ Missing | leftIcon, rightIcon |
createTextProperty() |
| State | ✅ Same | disabled, loading |
SmartGlobalProperties |
Variant Count
| Type | Before | After |
|---|---|---|
| Basic styles | 5 | 4 (primary, secondary, ghost, danger) |
| Shapes | 1 | 3 (rounded, pill, square) |
| Icons | 0 | 2 (left icon, right icon) |
| States | 0 | 1 (loading) |
| Sizes | 0 | 1 (size demo) |
| Total | 5 | 10 |
🎯 Integration with Smart Properties
How Showcase Uses Smart Properties
┌──────────────────────────────────────────────────────────┐
│ Backend Properties (MongoDB) │
│ • custom_buttonVariant │
│ • core_size │
│ • custom_buttonShape │
└──────────────────────────────────────────────────────────┘
↓
Aligned with (manual sync)
↓
┌──────────────────────────────────────────────────────────┐
│ Smart Properties (@libs-foundational/core-properties) │
│ • SmartButtonProperties.variant() │
│ • SmartButtonProperties.size() │
│ • SmartButtonProperties.shape() │
└──────────────────────────────────────────────────────────┘
↓
Used by embeddable definition
↓
┌──────────────────────────────────────────────────────────┐
│ Button Embeddable (@embeddables/embeddable-schemas) │
│ inputs: [ │
│ SmartButtonProperties.variant({ order: 1 }), │
│ SmartButtonProperties.size({ order: 2 }), │
│ SmartButtonProperties.shape({ order: 3 }), │
│ ] │
└──────────────────────────────────────────────────────────┘
↓
Registered with embeddable registry
↓
┌──────────────────────────────────────────────────────────┐
│ Widget Showcase (CoreComponentDetailComponent) │
│ • Loads embeddable: registry.get('button') │
│ • Loads static data: getCoreComponentData('button') │
│ • Merges both sources │
│ • Renders with correct property names │
└──────────────────────────────────────────────────────────┘
Key Point: The static data in getCoreComponentData() now matches the smart properties used in BUTTON_EMBEDDABLE.
🚀 Next Steps
Immediate
- Update button static data to match smart properties
- Test showcase page at
http://localhost:5200/space/chrome-space-1/widgets/button - Verify all 10 variants render correctly
- Check property table displays correct inputs
Short Term
- Update other widget static data (input, card, icon, etc.)
- Add variant creation UI integration
- Test variant saving/loading
- Add property group filtering
Medium Term
- Remove static data entirely (use only embeddable registry)
- Generate documentation from embeddable schemas
- Add real-time property editing
- Integrate with backend property system
🔍 Verification Steps
1. Check Widget Loads
# Navigate to button widget
http://localhost:5200/space/chrome-space-1/widgets/button
Expected:
- ✅ "Button Widget" header
- ✅ "Interactive button with customizable actions" description
- ✅ 10 variants listed
- ✅ "Properties" section with 11 inputs
2. Test Variant Preview
Action: Click on each variant
Expected:
- ✅ Live preview renders correctly
- ✅ Properties match variant definition
- ✅ Hover effects work (pulse/lift)
- ✅ Icons display when specified
3. Check Property Table
Expected:
- ✅ 11 inputs listed: text, variant, size, shape, effect, color, leftIcon, rightIcon, disabled, loading, type
- ✅ Correct types shown: string, enum, boolean
- ✅ Default values displayed
- ✅ Descriptions accurate
4. Test "Create Variant" Button
Expected:
- ✅ Opens variant creator modal
- ✅ Pre-fills with current variant properties
- ✅ Can modify properties
- ✅ Saves to storage
📚 Related Documentation
Status: ✅ Fixed - Ready for Testing
Confidence: 95%
Impact: Widget showcase now correctly displays button variants with smart properties
Next: Test in browser and verify all functionality