Skip to content

Automate Tailwind class ordering + tokenize sub-xs text sizes - #2175

Open
maebeale wants to merge 1 commit into
mainfrom
maebeale/tailwind-class-order-and-text-tokens
Open

Automate Tailwind class ordering + tokenize sub-xs text sizes#2175
maebeale wants to merge 1 commit into
mainfrom
maebeale/tailwind-class-order-and-text-tokens

Conversation

@maebeale

Copy link
Copy Markdown
Collaborator

🤖 suggested review level: 3 Read 📖 wide but low-risk — mechanical class reordering + a font-size token rename across 63 view files, plus one dev script and config

Adopts two of the practices from Evil Martians — "5 best practices for preventing chaos in Tailwind CSS": automated class ordering and semantic design tokens for our scattered tiny font sizes.

What & why

  • Class ordering (rustywind). The article's tool (prettier-plugin-tailwindcss) can't parse ERB, where ~all our classes live. rustywind is the ERB-native equivalent: it reorders only class-attribute tokens, leaving <%= … %> and markup untouched. Added ai/tw-sort (defaults to files changed vs main for gradual convergence; --all / --check) plus npm run format:classes / lint:classes.
  • Text tokens. Replaced ~139 arbitrary text-[10px] / text-[0.6rem] / text-[0.65rem] / text-[0.55rem] with two named @theme tokens: text-2xs (0.625rem/10px) and text-3xs (0.55rem). The ~10px cluster is normalized to 10px (sub-0.5px shift); compiled output is font-size only, so no line-height change.
  • Only files already touched by the token swap were class-sorted — no extra churn. Convergence continues as files are edited.

Notes for reviewer

  • text-[0.7rem], text-[11px], text-[7px], text-[5px] (11 total) left as-is — genuine one-offs / distinct sizes, out of the consolidated cluster.
  • Verified: bin/vite build green; .text-2xs{font-size:var(--text-2xs)} / .text-3xs{…} present with no injected line-height.

Scorecard — where the codebase stands vs the article's 5 practices

# Practice Status Notes
1 Use fewer utility classes 🟡 Partial Handled by other means — components/buttons.css extracts .btn*, and CLAUDE.md pushes model presentation into decorators.
2 Group & name design tokens semantically 🟢 Strong @theme already has semantic colors; this PR adds the missing tiny-text tokens.
3 Keep class ordering 🟢 Now automated Was 🔴 (no sorter). This PR adds rustywind + ai/tw-sort.
4 Prevent inconsistencies when overriding/extending 🟢 Good Rails-adapted: extracted .btn* variants + CLAUDE.md rules against interpolated classes (static literals + safelist).
5 Minimize build size 🟢 Automatic Tailwind v4 minifies via Lightning CSS in the Vite prod build.

Adopt two Tailwind chaos-prevention practices: automated class ordering
(via rustywind, since Prettier's Tailwind plugin can't parse ERB) and
semantic design tokens for the tiny font sizes that were scattered as
arbitrary text-[…] values. Consolidating them keeps the dense-UI type
consistent and adjustable in one place.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 12, 2026 13:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@maebeale
maebeale marked this pull request as ready for review August 12, 2026 14:26
@maebeale
maebeale requested a review from jmilljr24 August 12, 2026 14:36
@maebeale

Copy link
Copy Markdown
Collaborator Author

@jmilljr24 this is in response to the tailwind article. any reservations w adding rustywind?

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.

2 participants