FONT PROPERTIES FIX
Comprehensive guidelines for AI-assisted development within the Editor platform
๐ค Font Properties System - Fixed & Enhanced
Overview
Fixed critical issue where font properties were not working because they were saved to widget.properties but widgets were reading from widget.styles.
๐ The Problem
Issue
Font properties (fontFamily, fontSize, fontWeight, etc.) were not being applied to widgets.
Root Cause
// โ Font properties saved HERE:
widget.properties = {
fontFamily: 'Arial',
fontSize: 16,
fontWeight: 'bold'
}
// โ But button widget reading from HERE:
containerStyles = computed(() => {
const widgetStyles = this.responsiveWidgetService.getWidgetStyles(...); // Reads widget.styles
return {
'font-family': widgetStyles.fontFamily, // โ WRONG - undefined!
'font-size': widgetStyles.fontSize, // โ WRONG - undefined!
};
});
Result: Font changes in properties panel had zero effect on the actual widget rendering.
โ The Solution
Fixed: Button Widget Now Reads Font Properties Correctly
containerStyles = computed(() => {
const widgetStyles = this.responsiveWidgetService.getWidgetStyles(...);
// โ
FIXED: Read font properties from widget.properties
const props = this.widget()?.properties || {};
return {
// โ
Font properties from widget.properties
'font-family': props['fontFamily'] || 'inherit',
'font-size': props['fontSize'] ? `${props['fontSize']}px` : '14px',
'font-weight': props['fontWeight'] || 'normal',
'font-style': props['fontStyle'] || 'normal',
'text-align': props['textAlign'] || 'left',
'text-decoration': props['textDecoration'] || 'none',
'text-transform': props['textTransform'] || 'none',
'line-height': props['lineHeight'] || 'normal',
'letter-spacing': props['letterSpacing'] ? `${props['letterSpacing']}px` : 'normal',
// โ
Custom styles from widget.styles (colors, borders)
'--button-bg': widgetStyles.backgroundColor || 'inherit',
'--button-color': widgetStyles.color || 'inherit',
};
});
๐ Data Flow Architecture
Widget Property Structure
{
"widgetId": "button-123",
"type": "button",
"properties": {
// โ
Content & Typography properties here
"text": "Click Me",
"fontFamily": "Roboto",
"fontSize": 16,
"fontWeight": "600",
"fontStyle": "normal",
"textAlign": "center",
"textDecoration": "none",
"textTransform": "uppercase",
"lineHeight": 1.5,
"letterSpacing": 0.5,
// โ
Behavioral properties here
"action": "event",
"eventName": "button_click",
"disabled": false,
"loading": false
},
"styles": {
// โ
Visual appearance properties here (theme-based OR custom)
"base": {
"backgroundColor": "#3b82f6",
"color": "#ffffff",
"borderWidth": 0,
"borderColor": "#000000",
"borderRadius": 8,
"opacity": 1
}
}
}
๐ฏ Property Categories
1. Typography Properties โ widget.properties
fontFamily- Font family namefontSize- Font size in pixelsfontWeight- Font weight (normal, bold, 100-900)fontStyle- Font style (normal, italic)textAlign- Text alignment (left, center, right, justify)textDecoration- Text decoration (none, underline, line-through)textTransform- Text transform (none, uppercase, lowercase, capitalize)lineHeight- Line height (number or string)letterSpacing- Letter spacing in pixels
2. Visual Styles โ widget.styles
backgroundColor- Background colorcolor- Text color (for custom variant only)borderWidth- Border widthborderColor- Border colorborderRadius- Border radiusopacity- Opacity (0-1)
3. Content Properties โ widget.properties
text- Button textleftIcon- Left icon classrightIcon- Right icon class
4. Behavioral Properties โ widget.properties
buttonType- Variant (primary, secondary, custom, etc.)size- Size (small, medium, large)shape- Shape (rounded, pill, square)effect- Hover effectaction- Action type (event, link, submit, reset)eventName- Event name for event actionslink- URL for link actionsdisabled- Disabled stateloading- Loading state
๐ง Implementation Details
Font Properties Group
Location: libs/libs-widgets/widgets/src/lib/providers/default-properties/default-group-font.ts
Uses custom component: FontPropertiesGroupComponent
export const DEFAULT_GROUP_FONT: PropertyGroup = {
id: GROUP_ID.FONT,
title: 'Font and Text',
icon: 'fa-font',
order: GROUP_ORDER.FONT, // Order: 35 (after Appearance)
expanded: false, // Collapsed by default (advanced)
properties: [
{
key: 'font',
label: 'Font Properties',
type: 'custom',
component: FontPropertiesGroupComponent,
getValue: (widget: Widget) => widget,
setValue: (widget: Widget, data: Record<string, any>) => {
// Updates widget.properties with font changes
return updateFontProperty(widget, data);
},
},
],
};
Button Widget Integration
The button widget now:
- โ
Reads font properties from
widget.properties - โ
Applies them to
containerStyles - โ Logs font changes for debugging
- โ Falls back to sensible defaults
๐งช Testing
Test Procedure
Open Editor: http://localhost:5200/space/chrome-space-1/editor
Select Button Widget
Expand "Font and Text" Property Group
Change Font Properties:
- Font Family: Change to "Roboto" or "Arial"
- Font Size: Change to different values (12px, 16px, 24px)
- Font Weight: Try different weights (normal, bold, 600)
- Text Transform: Try "uppercase", "lowercase"
Expected Results:
- โ Button text font changes IMMEDIATELY
- โ
Console shows:
๐ค [ButtonWidget] Font properties: { fontFamily: 'Roboto', fontSize: 16, ... } - โ Changes persist across page refreshes
- โ
Font properties saved to
widget.properties
Debug Logging
Watch browser console for:
๐ค [ButtonWidget] Font properties: {
fontFamily: 'Roboto',
fontSize: 18,
fontWeight: '600'
}
๐ Next Steps
1. Apply This Pattern to All Widgets
All widgets should read font properties from widget.properties:
// โ
Standard pattern for all widgets
containerStyles = computed(() => {
const props = this.widget()?.properties || {};
return {
'font-family': props['fontFamily'] || 'inherit',
'font-size': props['fontSize'] ? `${props['fontSize']}px` : 'inherit',
'font-weight': props['fontWeight'] || 'inherit',
// ... other font properties
};
});
Widgets to update:
- โ ButtonWidget (DONE)
- โณ TextWidget
- โณ CardWidget
- โณ LinkWidget
- โณ InputWidget
- โณ SelectWidget
- โณ All other text-containing widgets
2. Create Independent Property Editors
As mentioned: "we must have an independent set of editors based on the property group or property"
Current State:
- โ
FontPropertiesGroupComponent- Custom editor for font properties - โ Color picker - Uses basic
<input type="color">(needs enhancement) - โ No spacing editor (needs custom component)
- โ No border editor (needs custom component)
Needed Custom Editors:
ColorPickerComponent ๐จ
- Theme color tokens vs manual hex
- Recent colors
- Saved palettes
- Alpha channel support
SpacingEditorComponent ๐
- Visual padding/margin editor
- Linked/unlinked sides
- Responsive values
- Unit selector (px, rem, em, %)
BorderEditorComponent ๐ผ๏ธ
- All-sides or per-side
- Style selector (solid, dashed, dotted)
- Width slider
- Color picker integration
ShadowEditorComponent โจ
- Box shadow composer
- Multiple shadows
- Presets (elevation levels)
TypographyEditorComponent ๐ค (Enhance current)
- Font family with preview
- Font weight with visual slider
- Line height visual editor
- Letter spacing visual editor
3. Theme Token Integration
Colors and fonts should support theme tokens:
// Example: Color with theme token support
interface ColorValue {
mode: 'theme' | 'manual';
value: string; // Either '--ux-primary' or '#3b82f6'
}
This allows:
- โ Consistent theming across widgets
- โ Dark mode support
- โ Brand color changes propagate automatically
- โ Still allows manual overrides for advanced users
๐ Related Documentation
โ Summary
What Was Fixed
- โ
Font properties now read from correct location (
widget.properties) - โ Button widget applies all font properties correctly
- โ Debug logging added for troubleshooting
- โ Proper data flow architecture documented
What Works Now
- โ Font Family changes apply instantly
- โ Font Size changes apply instantly
- โ Font Weight changes apply instantly
- โ All typography properties work correctly
- โ Changes persist via flash-persistence
What's Next
- โณ Apply pattern to all other widgets
- โณ Create custom property editors (color, spacing, border)
- โณ Add theme token support
- โณ Enhance font editor with visual previews
Last Updated: December 6, 2024
Status: โ
FIXED - Font properties fully functional
Next: Apply pattern to remaining widgets