Skip to content

JM: Introduce button_classes helper (move buttons off @apply) - #2297

Draft
maebeale wants to merge 1 commit into
mainfrom
maebeale/button-helper
Draft

JM: Introduce button_classes helper (move buttons off @apply)#2297
maebeale wants to merge 1 commit into
mainfrom
maebeale/button-helper

Conversation

@maebeale

Copy link
Copy Markdown
Collaborator

🤖 suggested review level: 3 Read 📖 new helper + reference conversion of the event-flow buttons; rest of the app unchanged

Why

  • Evil Martians best practice Remove Coffeescript #4: express reusable button styles as utilities in a helper, not @apply component classes in CSS. @apply hides where styles change and bloats the bundle.

What

  • New ButtonHelper#button_classes(variant, size:, extra:) — single source of truth for base + all variants + sizes. Tailwind already scans app/helpers/**/*.rb, so the utility strings generate normally.
  • Converted the event registration-flow buttons as the reference pattern: registration section, event show, event card, scholarship callout.
  • Helper spec added.

Deliberately incremental

  • buttons.css (.btn / .btn-* @apply) stays — the ~200 remaining call sites still use it, so helper + @apply coexist with zero visual change. Convert-on-next-touch, per the same Evil Martians guidance against big-bang @apply rewrites.

Gotcha this design handles

  • Today .btn's padding lives in the components layer, so a call site's px-10/text-2xl (in the utilities layer) overrides it. Once styles are inlined they're all utilities in one class list, where conflicts resolve by Tailwind's generation order, not markup order. So size: is explicit: :md (default), :sm, or nil when the call site supplies its own padding/text-size via extra:.

Open question

  • Full sweep of the remaining ~200 files now (large diff) vs. incremental next-touch? See PR thread.

Introduce ButtonHelper#button_classes as the single source of truth for button
styling, emitting Tailwind utilities from a helper (scanned via @source) instead
of the @apply-based .btn/.btn-* component classes — per Evil Martians best
practice #4. Convert the event registration-flow buttons (registration section,
event show, event card, scholarship callout) as the reference pattern.

buttons.css is intentionally left in place: the ~200 remaining call sites still
depend on it, so the helper and the @apply classes coexist during an incremental
rollout (no visual change, nothing breaks).

Size handling is explicit (size: :md default, :sm, or nil) because conflicting
utilities in one class list resolve by Tailwind's generation order, not markup
order — the old component/utility layer split is gone once styles are inlined.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@maebeale
maebeale requested a review from jmilljr24 August 21, 2026 13:38
@maebeale

Copy link
Copy Markdown
Collaborator Author

@jmilljr24 curious if you think this work it to move off tailwind apply

@maebeale maebeale changed the title Introduce button_classes helper (move buttons off @apply) JM: Introduce button_classes helper (move buttons off @apply) Aug 21, 2026
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