[v12] fix(emotion): calcMarginFromShorthand direct CSS value handling
Summary
Fixed console warnings when using direct CSS values (like 0, auto, 12px) in the margin prop of components. The calcMarginFromShorthand utility now properly recognizes valid CSS values before attempting theme token lookup, eliminating unnecessary warnings while maintaining full backward compatibility.
Changes
Added CSS value recognition logic to calcMarginFromShorthand before theme token lookup: New helper functions: isCSSValue(): Detects valid CSS margin values using pattern matching normalizeCSSValue(): Normalizes values (e.g., 'none' → '0') Execution order (unchanged, just added CSS check first):
- CSS value check (NEW) → if valid, return immediately
- Flat token lookup → spacingMap[token]
- Nested path lookup → spacingMap.gap.sm
- Warning + fallback
Recognized CSS values: Keywords: '0', 'auto', 'none' (converted to '0') Units: '12px', '0.5rem', '2em', '100%', etc.
Test plan
Apply different margin values to the Avatar (e.g., margin="0 small"), then verify the console warnings.
Co-Authored-By: 🤖 Claude
PR Preview Action v1.6.3 :---: |
:rocket: View preview athttps://instructure.design/pr-preview/pr-2290/
|