Skip to content

Sort named design-system colors as known - #150

Open
praveenperera wants to merge 6 commits into
masterfrom
more-tailwind-parity-custom-colors
Open

Sort named design-system colors as known#150
praveenperera wants to merge 6 commits into
masterfrom
more-tailwind-parity-custom-colors

Conversation

@praveenperera

@praveenperera praveenperera commented Jul 21, 2026

Copy link
Copy Markdown
Member

Summary

Classify arbitrary named design-system values such as bg-muted, text-foreground, border-input, and bg-card/90 as color utilities so they sort like Prettier instead of falling through as unknown classes.

  • Side border names (border-{t,r,b,l,x,y,s,e}-<name>) resolve to border color rather than border width
  • Shadow-family named values stay unclassified because they are ambiguous with custom --shadow-* sizes
  • Parity harness stylesheet includes a shadcn-style semantic palette so these tokens are graded against Prettier

Why

Projects that use semantic/design-system color tokens (e.g. shadcn-style palettes) currently get inconsistent sort order versus prettier-plugin-tailwindcss. Treating those named values as known color utilities closes that gap for the common cases without misclassifying ambiguous shadow sizes.

Test plan

  • Unit/integration coverage updated for opacity and parenthesized ring utilities
  • Tailwind compare harness extended with semantic palette fixtures
  • CI green on this branch

Summary by CodeRabbit

  • Bug Fixes
    • Improved recognition and sorting of Tailwind v4 named theme color values across color-capable utilities (including ring-offset, gradients, and opacity-suffixed variants).
    • Better handling of side border color utilities; shadow-family named values remain unclassified to avoid ambiguity.
  • New Features / Breaking Changes
    • Added --no-named-colors to disable named-color inference and keep ambiguous project-defined names unchanged.
  • Tests
    • Expanded opacity, ring, and named-color sorting/probing coverage, plus cache-behavior verification.
  • Documentation
    • Updated usage and Tailwind comparison guidance with a pinned semantic @theme palette and the new flag’s behavior.
  • Chores
    • Added automated “Compare Tailwind” workflow.

Classify arbitrary named design-system values such as
bg-muted, text-foreground, and bg-card/90 as color utilities
so they sort like Prettier. Side border names map to border
color rather than width; shadow-family names stay unclassified
because they are ambiguous with custom sizes. The parity
harness now includes a shadcn-style semantic palette for
grading these tokens.
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • ✅ Review completed - (🔄 Check again to review again)
📝 Walkthrough

Walkthrough

Named design-system theme values are recognized as color utilities across Tailwind utility families. Sorting, opacity, ring, CLI, parity-harness, CI, and documentation updates reflect configurable named-color inference.

Changes

Named color inference

Layer / File(s) Summary
Named theme color mapping
rustywind-core/src/utility_map.rs
Named theme keys are mapped across color-capable utilities, while shadow-family values, excluded keywords, and typed lengths retain distinct handling.
Inference-aware sorting
rustywind-core/src/pattern_sorter.rs, rustywind-core/src/hybrid_sorter.rs, rustywind-core/src/app.rs, rustywind-core/tests/*
Sorter configuration carries named-color inference, isolates prefixed caches by mode, clears cached keys when changed, and validates named-color ordering.
CLI option and integration
rustywind-cli/src/*, rustywind-cli/tests/named_colors.rs
--no-named-colors controls RustyWind::infer_named_colors, conflicts with CSS-derived inputs, and is covered by parsing and stdin sorting tests.
Parity validation and documentation
tests/tailwind-compare/*, .github/workflows/compare-tailwind.yml, README.md, CHANGELOG.md, rustywind-core/CHANGELOG.md
Semantic theme tokens, known-class probes, comparison CI, usage guidance, limitations, and breaking-change notes are updated.

Estimated code review effort: 4 (Complex) | ~45 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title concisely matches the main change: treating named design-system colors as known utilities during sorting.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch more-tailwind-parity-custom-colors

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@praveenperera
praveenperera marked this pull request as ready for review July 21, 2026 18:54
Merge duplicate color-like and named-color arms into single
guards, simplify is_named_color_value, expand side-border and
keyword coverage, and clarify the changelog note about shadow
ambiguity vs the parity palette.
Include the theme-key denylist in the color-like check so call
sites stop repeating OR named guards, and keep shadow-family
prefixes on a known-only helper so sizes stay unambiguous.
@greptile-apps

greptile-apps Bot commented Jul 21, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds configurable recognition of named design-system colors. The main changes are:

  • Classifies named values across color-capable Tailwind utilities.
  • Adds --no-named-colors for ambiguous project-defined names.
  • Separates sorter caches by named-color inference mode.
  • Expands semantic-color parity and regression coverage.
  • Adds an automated Tailwind comparison workflow.

Confidence Score: 5/5

No additional blocking issue was identified in this review.

  • The opt-out reaches the CLI and core sorter paths.
  • Prefixed and unprefixed sorter caches remain isolated across inference modes.
  • No separate production failure requiring another change was found.

Important Files Changed

Filename Overview
rustywind-core/src/utility_map.rs Adds configurable named-color matching and updates color-capable utility families.
rustywind-core/src/app.rs Propagates the inference setting and isolates global and prefixed sorter caches by mode.
rustywind-core/src/pattern_sorter.rs Passes the configured inference mode into utility property lookup.
rustywind-cli/src/main.rs Adds the named-color inference opt-out and validates incompatible sorter options.

Reviews (2): Last reviewed commit: "Harden compare-tailwind checkout permiss..." | Re-trigger Greptile

Run just compare-tailwind on push and pull requests so
ordering regressions against Prettier are caught in CI.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/compare-tailwind.yml (1)

9-33: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Pin third-party actions to immutable SHAs.

The workflow executes several external actions from mutable version tags. Pin each uses: reference to a full commit SHA, retaining the version in a comment, to prevent tag retargeting or compromised releases from changing CI behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/compare-tailwind.yml around lines 9 - 33, Update every
third-party uses reference in the workflow, including actions/checkout,
actions-rust-lang/setup-rust-toolchain, actions/setup-node,
extractions/setup-just, and actions/upload-artifact, to a full immutable commit
SHA. Retain each action’s current version tag in an adjacent comment for
traceability, without changing the workflow steps or configuration.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/compare-tailwind.yml:
- Around line 3-9: Update the compare-tailwind workflow by adding workflow-level
contents: read permissions and configuring the actions/checkout@v4 step with
persist-credentials set to false, while preserving the existing triggers and job
behavior.

---

Nitpick comments:
In @.github/workflows/compare-tailwind.yml:
- Around line 9-33: Update every third-party uses reference in the workflow,
including actions/checkout, actions-rust-lang/setup-rust-toolchain,
actions/setup-node, extractions/setup-just, and actions/upload-artifact, to a
full immutable commit SHA. Retain each action’s current version tag in an
adjacent comment for traceability, without changing the workflow steps or
configuration.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f83b2823-dd97-4eaf-a38c-0be215c191f4

📥 Commits

Reviewing files that changed from the base of the PR and between c4e7eee and f40ff86.

📒 Files selected for processing (1)
  • .github/workflows/compare-tailwind.yml

Comment thread .github/workflows/compare-tailwind.yml
Default named-color inference treats ambiguous project names such as
text-display as colors. Projects that use those names for other
purposes can disable inference while still recognizing palette,
arbitrary, and CSS-variable colors. Also resolve typed (length:...)
parentheses to width/position slots for Tailwind parity.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
rustywind-core/src/utility_map.rs (1)

2226-2243: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Expand typed parenthesized hints beyond length. Tailwind accepts other data types here (number, angle, percentage, etc.), so treating every non-length value as Color misclassifies valid classes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@rustywind-core/src/utility_map.rs` around lines 2226 - 2243, Update
ParenthesizedValueKind::parse so recognized typed hints such as number, angle,
and percentage are classified appropriately instead of falling through to Color.
Add or reuse distinct enum variants for the supported data types, while
preserving Color for untyped hints and only unsupported types according to the
existing contract.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@rustywind-core/src/utility_map.rs`:
- Around line 2226-2243: Update ParenthesizedValueKind::parse so recognized
typed hints such as number, angle, and percentage are classified appropriately
instead of falling through to Color. Add or reuse distinct enum variants for the
supported data types, while preserving Color for untyped hints and only
unsupported types according to the existing contract.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b558d1f6-3a19-4343-91b3-8ed3c309394b

📥 Commits

Reviewing files that changed from the base of the PR and between f40ff86 and 80c292c.

📒 Files selected for processing (12)
  • CHANGELOG.md
  • README.md
  • rustywind-cli/src/main.rs
  • rustywind-cli/src/options.rs
  • rustywind-cli/tests/named_colors.rs
  • rustywind-core/CHANGELOG.md
  • rustywind-core/src/app.rs
  • rustywind-core/src/hybrid_sorter.rs
  • rustywind-core/src/pattern_sorter.rs
  • rustywind-core/src/utility_map.rs
  • rustywind-core/tests/test_tailwind_prefix.rs
  • tests/tailwind-compare/README.md

Scope the workflow to contents: read and disable
persisted checkout credentials for this PR job.
@praveenperera

Copy link
Copy Markdown
Member Author

@greptileai

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