fix(text): keep CSS functions intact in the margin shorthand

DU
1d ago
+78-1

Related issue or discussion

Fixes #3939

What this changes

<Text> breaks the margin shorthand into its four sides, but it split the value on every space. That meant anything with a CSS function in it fell apart. For example, margin: 'calc(10px + 2px) 0' came out as margin-top:calc(10px;margin-right:+;margin-bottom:2px), which email clients just ignore.

Now the value is only split on spaces that sit outside parentheses, so calc(), max(), clamp() and nested var() stay in one piece. Plain values like 10px 20px work the same as before.

I added tests for computeMargins and for the rendered <Text> output. Both fail without the fix and pass with it.


Summary by cubic

Fixes the <Text> component's margin shorthand parsing so CSS functions like calc(), max(), and clamp() stay intact instead of being split into broken pieces.

Previously, margin: 'calc(10px + 2px) 0' was split on every space, producing invalid CSS that email clients ignored. The value is now only split on spaces outside parentheses, so CSS functions and nested var() calls survive while plain values like 10px 20px work as before. Added tests for both the margin computation utility and the rendered <Text> output.