Collapse more utilities by expanding their declarations#19842
Collapse more utilities by expanding their declarations#19842RobinMalfait merged 11 commits intomainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
WalkthroughAdded variadic expansion mappings for 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
packages/tailwindcss/src/expand-declaration.test.ts (1)
598-612: Semantically incorrect value1pxforborder-inline-style.While the expansion logic works regardless of the value, using
1pxfor a style property is confusing. Consider using a valid style keyword for clarity.♻️ Suggested improvement
test('border-inline-style', () => { let input = css` .example { - border-inline-style: 1px; + border-inline-style: solid; } ` expect(expand(input, options)).toMatchInlineSnapshot(` ".example { - border-left-style: 1px; - border-right-style: 1px; + border-left-style: solid; + border-right-style: solid; } " `) })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/tailwindcss/src/expand-declaration.test.ts` around lines 598 - 612, The test "border-inline-style" in expand-declaration.test.ts uses an invalid semantic value "1px" for the CSS property; update the test input in the test case (the css`...` block) to use a valid border style keyword such as "solid" (e.g., border-inline-style: solid;) and update the expected inline snapshot produced by expand(...) accordingly so it asserts border-left-style: solid; and border-right-style: solid; (reference the test name "border-inline-style" and the expand(...) call).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/tailwindcss/src/expand-declaration.test.ts`:
- Around line 614-628: The test currently mislabels and duplicates the
inline-axis test: update the test so it actually covers block-axis expansion by
changing the input CSS to use border-block-style instead of border-inline-style,
use a valid style keyword value (e.g. "solid" or "dashed") instead of "1px", and
update the expectation from left/right properties to block-start/block-end
equivalents (border-top-style and border-bottom-style) to match the expand(...)
behavior; refer to the test name "border-block-style" and the expand(...) helper
to locate and modify this test.
- Around line 582-596: The test labelled "border-block-width" currently uses
`border-inline-width` in the CSS input and expected snapshot, so update the test
to actually exercise `border-block-width`: change the CSS input in the test
block named "border-block-width" to use `border-block-width: 1px;` and update
the expected snapshot produced by `expand(input, options)` to the expansion that
`expand` should produce (i.e., `border-top-width: 1px;` and
`border-bottom-width: 1px;`) so the test verifies block-axis expansion rather
than duplicating the inline-axis test.
---
Nitpick comments:
In `@packages/tailwindcss/src/expand-declaration.test.ts`:
- Around line 598-612: The test "border-inline-style" in
expand-declaration.test.ts uses an invalid semantic value "1px" for the CSS
property; update the test input in the test case (the css`...` block) to use a
valid border style keyword such as "solid" (e.g., border-inline-style: solid;)
and update the expected inline snapshot produced by expand(...) accordingly so
it asserts border-left-style: solid; and border-right-style: solid; (reference
the test name "border-inline-style" and the expand(...) call).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 04686721-c0c3-462a-8863-d46818ee83fb
📒 Files selected for processing (3)
packages/tailwindcss/src/canonicalize-candidates.test.tspackages/tailwindcss/src/expand-declaration.test.tspackages/tailwindcss/src/expand-declaration.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@CHANGELOG.md`:
- Around line 21-22: The two changelog examples incorrectly use `scroll-x-*` for
the lateral shorthand; update the Canonicalization lines so `scroll-m{l,r}-*`
collapses to `scroll-mx-*` (replace `scroll-x-*` with `scroll-mx-*`) and
`scroll-p{l,r}-*` collapses to `scroll-px-*` (replace `scroll-x-*` with
`scroll-px-*`) — adjust the strings in the entries referencing `scroll-m{l,r}-*`
and `scroll-p{l,r}-*` accordingly.
94661e3 to
ffa86fd
Compare
This PR adds more declaration expansions such that we can collapse more utilities.
While testing #19837 I noticed that in my tests some utilities weren't canonicalized correctly. As part of that PR, we check for
parsedCandidate.value === null, which means that a functional utility without a value is skipped. We do have utilities like that such asborder(which is equivalent toborder-1). But while testing, I noticed thatborder-x border-yshould collapse toborderbut they didn't. This PR fixes that.By expanding these properties to their long-form physical properties (instead of the shorter logical properties) we make the signatures of utilities a bit bigger, but also more correct such that we can collapse the physical form into logical utilities.
To make this more concrete, this PR allows for the following canonicalizations now:
border-t-123 border-r-123 border-b-123 border-l-123border-123border-t-1 border-r-1 border-b-1 border-l-1borderborder-t-123 border-b-123border-y-123border-l-123 border-r-123border-x-123border-t-red-500 border-r-red-500 border-b-red-500 border-l-red-500border-red-500border-t-red-500 border-b-red-500border-y-red-500border-l-red-500 border-r-red-500border-x-red-500scroll-mt-123 scroll-mr-123 scroll-mb-123 scroll-ml-123scroll-m-123scroll-mt-123 scroll-mb-123scroll-my-123scroll-ml-123 scroll-mr-123scroll-mx-123scroll-pt-123 scroll-pr-123 scroll-pb-123 scroll-pl-123scroll-p-123scroll-pt-123 scroll-pb-123scroll-py-123scroll-pl-123 scroll-pr-123scroll-px-123overflow-x-hidden overflow-y-hiddenoverflow-hiddenoverscroll-x-contain overscroll-y-containoverscroll-containTest plan