Skip to content

Canonicalize calc(var(--spacing)*…) expressions into --spacing(…)#19769

Merged
RobinMalfait merged 3 commits intomainfrom
fix/canonicalize-calc-spacing
Mar 8, 2026
Merged

Canonicalize calc(var(--spacing)*…) expressions into --spacing(…)#19769
RobinMalfait merged 3 commits intomainfrom
fix/canonicalize-calc-spacing

Conversation

@RobinMalfait
Copy link
Copy Markdown
Member

This PR canonicalizes usages of calc(var(--spacing)*…) to --spacing(…) when used in arbitrary values.

Some examples:

Before After
pt-[min(20%,calc(var(--spacing)*8))] pt-[min(20%,--spacing(8))]
pt-[min(20%,calc(var(--spacing)*var(--other)))] pt-[min(20%,--spacing(var(--other)))]
pt-[calc(var(--spacing)*8)] pt-8
pt-[calc(var(--spacing)*var(--other))] pt-[--spacing(var(--other))]
[padding-top:min(20%,calc(var(--spacing)*8))] pt-[min(20%,--spacing(8))]
[padding-top:min(20%,calc(var(--spacing)*var(--other)))] pt-[min(20%,--spacing(var(--other)))]
[padding-top:calc(var(--spacing)*8)] pt-8
[padding-top:calc(var(--spacing)*var(--other))] pt-[--spacing(var(--other))]

Test plan

  1. Existing tests pass
  2. Added new tests

@RobinMalfait RobinMalfait requested a review from a team as a code owner March 7, 2026 18:06
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 7, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 897a8073-86ce-494c-ba7d-036e2210374c

📥 Commits

Reviewing files that changed from the base of the PR and between 7922696 and f89deeb.

📒 Files selected for processing (1)
  • CHANGELOG.md

Walkthrough

Adds a canonicalization step that normalizes calc(...) expressions referencing the spacing variable into a spacing-function form. Implements calcToSpacingFunction and spacingCalcToSpacingFunction, integrates them into the utility canonicalization pipeline, and updates packages/tailwindcss/src/canonicalize-candidates.test.ts with new padding-related test cases covering standard and arbitrary-property patterns. Also adds a changelog entry noting the change.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly describes the main change: canonicalizing calc(var(--spacing)*…) expressions into --spacing(…), which matches the primary functionality added in the PR.
Description check ✅ Passed The description is directly related to the changeset, providing clear examples of the transformations being made and explaining the test plan, which aligns with the code changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

@RobinMalfait RobinMalfait merged commit c586bd6 into main Mar 8, 2026
7 checks passed
@RobinMalfait RobinMalfait deleted the fix/canonicalize-calc-spacing branch March 8, 2026 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant