Delegate smart_merge to the tailwind_merge gem#1
Merged
Conversation
Drops the hand-rolled CATEGORIES/SPACING/modifier tables in favor of gjtorikian/tailwind_merge, which mirrors tailwind-merge (JS) semantics and tracks Tailwind utility groups upstream. The public API is unchanged (smart_merge still takes a list of strings and returns a merged string), but conflict resolution now covers every Tailwind utility group rather than the subset previously encoded in CATEGORIES. Breaking: `hidden` is now part of the display conflict group, so `"flex hidden"` collapses to `"hidden"`. The previous carve-out was non-standard; the recommended replacement for JS-toggle visibility is the HTML5 `hidden` attribute via the existing `attribute` DSL. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the hand-rolled Tailwind conflict-resolution logic in
smart_mergewith a delegation togjtorikian/tailwind_merge(the Ruby port of tailwind-merge). The public API is unchanged.lib/view_component_css_dsl.rb: -165 lines net. DroppedSPACING_REGEX,SPACING_AXIS_MAP,BORDER_REGEX,CATEGORIES,KNOWN_MODIFIERS,MODIFIER_PATTERNS, plusspacing_info,detect_category,extract_modifier_prefix,known_modifier?. Added one module-levelMERGER = TailwindMerge::Merger.newshared across the process.view_component_css_dsl.gemspec: addedtailwind_merge ~> 1.0dependency.CHANGELOG.md: noted under Changed (broader coverage) and Breaking (hiddensemantics).README.md: noted the delegation and added a JS-toggle visibility subsection pointing to the HTML5hiddenattribute pattern.TODO.md: removed the resolved investigation item.Why
smart_mergeonly categorized ~14 utility groups.tailwind_mergecovers every Tailwind utility group and tracks upstream Tailwind releases (1.5.0 ships TW 4.3 support, May 2026). Groups now correctly merged that weren't before:shadow-*,ring-*,gap-*,space-*,divide-*,z-*,opacity-*,leading-*,tracking-*,transition-*,scale-*,rotate-*,translate-*,blur-*, plus arbitrary-value negative spacing and stacked!importantmarkers._css_cache/_css_merge_cachesit above this and continue to work unchanged.Breaking change
hiddenis now treated as part of the display group, so"flex hidden"collapses to"hidden"(matching upstream tailwind-merge). The previous carve-out preserved both classes for JS-toggle patterns. The supported replacement is the HTML5hiddenattribute via the existingattributeDSL —:hiddenis already inHTML_ATTR_KEYS, so callers can passhidden: trueor components can declareattribute hidden: -> { ... }. JS then toggles withelement.toggleAttribute('hidden')instead ofclassList.toggle('hidden').Test plan
bundle exec rspec— 139 examples, 0 failures (no spec changes needed)bundle exec standardrb— cleansmart_mergeon 40+ cases (spacing/border/modifiers/arbitrary/important/negative) — all spacing cases identical, all coverage-gap cases newly handled correctlyhiddencarve-out and will be migrated separately after this lands🤖 Generated with Claude Code