Skip to content

refacto: token-driven button variants, radius tokens & DRY component rendering#7

Merged
PhilMeyr merged 5 commits into
masterfrom
refacto/token-driven-buttons-radius
Jun 15, 2026
Merged

refacto: token-driven button variants, radius tokens & DRY component rendering#7
PhilMeyr merged 5 commits into
masterfrom
refacto/token-driven-buttons-radius

Conversation

@PhilMeyr

Copy link
Copy Markdown
Contributor

Contexte

Trois implémentations parallèles d'un même bouton/box coexistaient : composants natifs Cta/InfoBox (token-driven mais jamais consommés), forks applicatifs DsCta/DsInfoBox (mêmes structures, source de tokens différente), et classes CSS. Les forks ne différaient du natif que par la source des tokens et par deux capacités manquantes côté gem : un border-radius paramétrable et une vraie variante outline.

Objectif : rendre la gem assez expressive pour qu'aucun fork ne soit jamais nécessaire — la personnalisation passe par la configuration de tokens (Open/Closed), pas par la réécriture de composants.

Changements

Tokens

  • Registre généralisé derrière une table GROUPS (ajouter un groupe = une entrée), nouveau groupe radius.
  • Résolveur button_style(variant) → fond / texte / bordure / radius : variante outline par config seule, défauts 100 % rétro-compatibles.
  • Bulk-loader tokens.load(color: {...}, radius: {...}), lecteur unique to_h.
  • Extractions SRP : value object Tokens::ButtonStyle (+ factory .from) et Tokens::ScssSerializer.

Composants

  • Scaffold bulletproof partagé bulletproof_button_table dans Base, consommé par Cta et Button.
  • Cta inline ses styles token-driven (gain : outline secondary) ; Button reste CSS-driven (modèle de robustesse distinct, rendu inchangé). Padding centralisé.
  • Suppression du border-radius:4px hardcodé dans Cta → token radius!(:button).
  • InfoBox : tokens dédiés info_box_* (fallback vers la palette page, anti-collision) + radius box.

SCSS

  • Radius toujours appliqué sur .button/.cta (plus d'opt-in .radius).
  • Miroir CSS de la variante secondary (color/border) et du radius info-box.

Divers

  • Generator initializer documenté (nouveaux tokens, bulk-loader, source de vérité Ruby→SCSS unique).
  • .rubocop.yml : CountAsOne: [array, hash] sur Metrics/ClassLength (tables de tokens = données déclaratives).

Tests

282 runs / 761 assertions, 0 échec. RuboCop 0 offense. Sorbet clean. Nouveau info_box_test, couverture radius / outline / bulk-loader.

…nt rendering

Make the gem expressive enough that downstream forks (DsCta/DsInfoBox) are
unnecessary: customization happens through token configuration, not component
rewrites.

- tokens: generalize storage/emission behind a GROUPS table (adding a group is
  one entry), add a radius group, a button_style(variant) resolver, a bulk
  load(...) helper, and a single to_h snapshot reader
- extract ButtonStyle (value object + .from factory) and ScssSerializer (SRP)
- Cta/Button share a bulletproof_button_table scaffold in Base; Cta is
  token-inline-driven (now supporting outline secondary via tokens) while
  Button stays CSS-driven; drop the hardcoded 4px radius
- InfoBox: box-scoped info_box_* tokens (fall back to page palette) + box radius
- SCSS: radius always applied on .button/.cta (drop opt-in .radius), mirror
  secondary color/border and info-box radius from tokens
- document new tokens + bulk loader in the generator initializer
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e58a15a. Configure here.

…text

- Cta inlined the secondary border on both the cell and the nested anchor; keep it
  on the cell only (a stacked <a> border doubles the line in many clients)
- dark mode forced button-text on .secondary, unreadable on an outline (light)
  fill; restore the secondary text color in both dark-mode strategies
- mirror the cell-only border in the .button/.cta SCSS
@AdVitam AdVitam deleted a comment from cursor Bot Jun 15, 2026
@AdVitam AdVitam deleted a comment from cursor Bot Jun 15, 2026
@PhilMeyr
PhilMeyr merged commit 03be839 into master Jun 15, 2026
12 checks passed
@PhilMeyr
PhilMeyr deleted the refacto/token-driven-buttons-radius branch June 15, 2026 18:06

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

There are 4 total unresolved issues (including 2 from previous reviews).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f3600df. Configure here.

.cta.secondary table td,
.cta.secondary a {
background: $am-color-secondary !important;
color: $am-button-secondary-color !important;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Dark mode ignores secondary_text

High Severity

Dark-mode rules force secondary .cta/.button link text to $am-button-secondary-color, which is aliased to button_text, not the secondary_text color token. Token-driven outline secondaries inline a dark secondary_text color, but !important stylesheet rules override it—often yielding light-on-light text when secondary is a light fill.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f3600df. Configure here.

.cta.secondary table td,
.cta.secondary a {
background: $am-color-secondary !important;
color: $am-button-secondary-color !important;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Dark mode overrides info box tokens

Medium Severity

Dark-mode panel rules apply !important background, border, and text colors to .info-box td, overriding the inline styles built from info_box_background, info_box_border, and info_box_text. Custom box-scoped tokens work in light rendering but are replaced by generic dark panel colors in dark mode.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f3600df. Configure here.

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