|
| 1 | +# Text Size System Update |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +This document details the recent update to the text sizing system in the Page Constructor library, specifically the enhancement of the `textSize` constant and related TypeScript types. |
| 6 | + |
| 7 | +## Changes Made |
| 8 | + |
| 9 | +### Constants Update |
| 10 | + |
| 11 | +**File**: `src/schema/validators/common.ts` |
| 12 | + |
| 13 | +**Previous Value**: |
| 14 | + |
| 15 | +```typescript |
| 16 | +export const textSize = ['s', 'm', 'l']; |
| 17 | +``` |
| 18 | + |
| 19 | +**Updated Value**: |
| 20 | + |
| 21 | +```typescript |
| 22 | +export const textSize = ['xs', 's', 'sm', 'm', 'l']; |
| 23 | +``` |
| 24 | + |
| 25 | +### TypeScript Type Update |
| 26 | + |
| 27 | +**File**: `src/models/constructor-items/common.ts` |
| 28 | + |
| 29 | +**Previous Type**: |
| 30 | + |
| 31 | +```typescript |
| 32 | +export type TextSize = 's' | 'm' | 'l'; |
| 33 | +``` |
| 34 | + |
| 35 | +**Updated Type**: |
| 36 | + |
| 37 | +```typescript |
| 38 | +export type TextSize = 'xs' | 's' | 'sm' | 'm' | 'l'; |
| 39 | +``` |
| 40 | + |
| 41 | +## New Size Options |
| 42 | + |
| 43 | +### Added Sizes |
| 44 | + |
| 45 | +1. **`'xs'` (Extra Small)**: |
| 46 | + |
| 47 | + - Smallest text size option |
| 48 | + - Provides finer control for very small text elements |
| 49 | + - Useful for captions, footnotes, or secondary information |
| 50 | + |
| 51 | +2. **`'sm'` (Small-Medium)**: |
| 52 | + - Intermediate size between 's' and 'm' |
| 53 | + - Fills the gap in the sizing scale |
| 54 | + - Provides more granular typography control |
| 55 | + |
| 56 | +### Existing Sizes (Unchanged) |
| 57 | + |
| 58 | +- **`'s'` (Small)**: Standard small text size |
| 59 | +- **`'m'` (Medium)**: Standard medium text size |
| 60 | +- **`'l'` (Large)**: Standard large text size |
| 61 | + |
| 62 | +## Impact Analysis |
| 63 | + |
| 64 | +### Affected Components |
| 65 | + |
| 66 | +The `textSize` property is used across multiple components: |
| 67 | + |
| 68 | +1. **Link Components** (`LinkProps`): |
| 69 | + |
| 70 | + - Links now support the extended size range |
| 71 | + - Better typography control for navigation and inline links |
| 72 | + |
| 73 | +2. **FileLink Components** (`FileLinkProps`): |
| 74 | + |
| 75 | + - File download links can use finer size control |
| 76 | + - Improved visual hierarchy for file listings |
| 77 | + |
| 78 | +3. **Title Components** (`TitleProps`): |
| 79 | + |
| 80 | + - Titles support more granular sizing |
| 81 | + - Better heading hierarchy control |
| 82 | + |
| 83 | +4. **Block Components**: |
| 84 | + - Various blocks that use text sizing inherit the new options |
| 85 | + - Slider blocks (`src/blocks/Slider/schema.ts`, `src/blocks/SliderOld/schema.ts`) |
| 86 | + - PriceDetailed block (`src/sub-blocks/PriceDetailed/schema.ts`) |
| 87 | + |
| 88 | +### Schema Validation |
| 89 | + |
| 90 | +All JSON schemas that reference `textSize` have been automatically updated to include the new values: |
| 91 | + |
| 92 | +- Form validation now accepts `'xs'` and `'sm'` values |
| 93 | +- Editor interfaces will show the new size options |
| 94 | +- Runtime validation ensures type safety |
| 95 | + |
| 96 | +## Benefits |
| 97 | + |
| 98 | +### Enhanced Typography Control |
| 99 | + |
| 100 | +1. **Finer Granularity**: More size options allow for better visual hierarchy |
| 101 | +2. **Design Flexibility**: Designers have more tools for creating consistent typography scales |
| 102 | +3. **Accessibility**: Better size options can improve readability for different user needs |
| 103 | + |
| 104 | +### Backward Compatibility |
| 105 | + |
| 106 | +- **No Breaking Changes**: Existing `'s'`, `'m'`, and `'l'` values continue to work |
| 107 | +- **Gradual Adoption**: Teams can adopt new sizes incrementally |
| 108 | +- **Default Behavior**: Components without explicit size settings remain unchanged |
| 109 | + |
| 110 | +### Developer Experience |
| 111 | + |
| 112 | +- **Type Safety**: TypeScript ensures only valid size values are used |
| 113 | +- **IntelliSense**: IDEs will show all available size options |
| 114 | +- **Validation**: JSON schema validation catches invalid size values |
| 115 | + |
| 116 | +## Usage Examples |
| 117 | + |
| 118 | +### Link with Extra Small Text |
| 119 | + |
| 120 | +```json |
| 121 | +{ |
| 122 | + "text": "Terms and Conditions", |
| 123 | + "url": "/terms", |
| 124 | + "textSize": "xs" |
| 125 | +} |
| 126 | +``` |
| 127 | + |
| 128 | +### Title with Small-Medium Size |
| 129 | + |
| 130 | +```json |
| 131 | +{ |
| 132 | + "text": "Section Subtitle", |
| 133 | + "textSize": "sm" |
| 134 | +} |
| 135 | +``` |
| 136 | + |
| 137 | +### FileLink with Fine-Tuned Sizing |
| 138 | + |
| 139 | +```json |
| 140 | +{ |
| 141 | + "href": "/document.pdf", |
| 142 | + "text": "Download PDF", |
| 143 | + "textSize": "sm" |
| 144 | +} |
| 145 | +``` |
| 146 | + |
| 147 | +## Migration Guide |
| 148 | + |
| 149 | +### For Existing Projects |
| 150 | + |
| 151 | +No migration is required as this is a non-breaking change. Existing size values (`'s'`, `'m'`, `'l'`) continue to work as before. |
| 152 | + |
| 153 | +### For New Development |
| 154 | + |
| 155 | +Consider using the new size options where appropriate: |
| 156 | + |
| 157 | +- Use `'xs'` for secondary information, captions, or legal text |
| 158 | +- Use `'sm'` when you need a size between small and medium |
| 159 | +- Continue using existing sizes for established design patterns |
| 160 | + |
| 161 | +## Testing Considerations |
| 162 | + |
| 163 | +### Visual Regression Testing |
| 164 | + |
| 165 | +- Existing components should render identically |
| 166 | +- New size options should be tested across different themes |
| 167 | +- Responsive behavior should be verified for all sizes |
| 168 | + |
| 169 | +### Schema Validation Testing |
| 170 | + |
| 171 | +- Ensure new size values pass validation |
| 172 | +- Verify that invalid size values are rejected |
| 173 | +- Test editor interfaces with new options |
| 174 | + |
| 175 | +## Future Considerations |
| 176 | + |
| 177 | +### Potential Enhancements |
| 178 | + |
| 179 | +1. **CSS Custom Properties**: Consider mapping sizes to CSS custom properties for easier theming |
| 180 | +2. **Responsive Sizing**: Explore size variations across different screen sizes |
| 181 | +3. **Semantic Naming**: Consider more semantic size names in future versions |
| 182 | + |
| 183 | +### Deprecation Strategy |
| 184 | + |
| 185 | +If size names need to change in the future, follow the established deprecation pattern: |
| 186 | + |
| 187 | +1. Add new names while keeping old ones |
| 188 | +2. Mark old names as deprecated in documentation |
| 189 | +3. Remove deprecated names in next major version |
| 190 | + |
| 191 | +## Related Documentation |
| 192 | + |
| 193 | +- [System Patterns](systemPatterns.md) - Component architecture patterns |
| 194 | +- [Tech Context](techContext.md) - Technical implementation details |
| 195 | +- [Progress](progress.md) - Current project status and achievements |
0 commit comments