Skip to content

Toggle: codeai-next (CADS) brand styles#74004

Open
levadadenys wants to merge 2 commits into
stagingfrom
denys/re/codeai-next-toggle
Open

Toggle: codeai-next (CADS) brand styles#74004
levadadenys wants to merge 2 commits into
stagingfrom
denys/re/codeai-next-toggle

Conversation

@levadadenys

@levadadenys levadadenys commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Before:
Знімок екрана 2026-07-21 о 20 13 15

After:
Знімок екрана 2026-07-21 о 20 13 11

What

Adds [data-brand='codeai-next']-scoped styles to the DSCO Toggle component, per-component brand-override pattern from #73901 (Tags) / #74003 (Chips):

state legacy (code / codeai) bridge would give codeai-next (this PR)
ON track --background-brand-teal-primary --background-brand-primary (purple-50) --background-selected-primary
ON icon --text-neutral-white-fixed (always white) white --text-selected-primary
ON thumb --background-neutral-white-fixed white --background-selected-primary-inverse (see below)
ON hover/pressed track --background-brand-teal-strong --background-brand-strong --background-selected-hover (+ matching pressed border)
OFF track --background-neutral-senary same (gray-50) --background-neutral-septenary
OFF hover/pressed track --background-neutral-septenary same (gray-70) --background-neutral-octonary
Disabled icons white fixed white fixed --text-disabled-neutral-inverse (white in Light, black in Dark)

The ON side is the mode-inverted selected triple from the Figma component spec (background/state/selected/primary track, background/state/selected/primary-inverse thumb, text/state/selected/primary icon): brand track + seafoam thumb/icon in Light, seafoam track + navy thumb/icon in Dark. The OFF neutrals are the same-name tokens read off the Figma variants — one ramp step darker than legacy, which the name-for-name bridge cannot express.

Everything else resolves correctly through the token bridge (#73701): the focus ring (legacy teal → --border-brand-primary, the CADS indigo), the disabled track fills (--background-neutral-disabled--background-disabled-neutral), the label text, and the OFF/disabled thumb (white fixed).

Legacy brands render byte-identically — every new declaration sits under the [data-brand='codeai-next'] scope.

The missing thumb token

The Figma thumb token background/state/selected/primary-inverse is not in the colors_codeAi.css sandbox export yet. The thumb references it with a fallback:

background: var(--background-selected-primary-inverse, var(--text-selected-primary));

--text-selected-primary carries the identical value pair by design (the export documents that selected text always pairs with the selected background), so the rendering is correct today, and the reference self-heals when a sandbox re-export adds the token — same forward-compat pattern as var(--shape-sm, …) in #73901.

Cascade notes

Each override mirrors its legacy counterpart's selector plus the [data-brand] attribute — no !important. Verified against the compiled output:

  • The ON-default override ties with the legacy hover rule, so hover (and pressed) are re-declared; block order mirrors the legacy cascade.
  • The thumb override is scoped :checked:not(:disabled), so the disabled thumb stays white (per Figma).
  • The legacy disabled fills outrank every fill override here, so disabled tracks stay on the bridge-mapped grays; only the disabled icon color is re-declared (it would otherwise inherit the ON recolor — which in Dark would put a navy icon on a dark gray track).
  • Pressed borders blend into the fill: --border-selected-hover matches --background-selected-hover by design on the ON side; the OFF side has no matching border token, so its pressed border stays at the transparent base.

Deliberately not in this PR

  • Sizing (the 2.625 × 1.375rem geometry / padding from the CADS spec) — same separate-pass plan as Tags/Chips.
  • Icon-in-thumb: the CADS spec draws the check/× inside the thumb; legacy DSCO draws it on the track half. That is a structural (DOM/pseudo-element) redesign, not a color swap — flagged for the sizing/structure pass. The color pairing (seafoam-on-navy) is correct either way.

QA

  • Storybook: Toggle story → Brand toolbar → "CodeAI · CADS"; walk ON/OFF × hover/focus/pressed/disabled, flip Light/Dark (ON side inverts to seafoam track + navy thumb by design). Back to code.org brand to confirm legacy is untouched.
  • Dark-mode OFF is worth an eyeball: the neutral ramp inverts (septenary → gray-30), so the OFF track goes light with a white thumb — that's what the semantic tokens give; if design wants different Dark OFF neutrals it's a token-choice follow-up.
  • Dashboard: any page with toggles + ?brand=codeai-next (needs DCDO brand-router-enabled); ?brand-reset=1 to clear.

Testing

  • stylelint + prettier clean (pre-commit hook); dart-sass compile verified the emitted selectors and their specificity against the base rules.
  • No JS/TSX changes; jest Toggle tests don't assert styles.

🤖 Generated with Claude Code

Brand-scoped override block for the states the token bridge cannot
express: the ON side moves to the dedicated mode-inverted selected
tokens (track, thumb, icon), the OFF track shifts one step down the
neutral ramp (septenary/octonary vs legacy senary/septenary — same-name
tokens the bridge cannot retarget), and disabled icons take the
disabled-inverse label. The thumb references the not-yet-exported
--background-selected-primary-inverse with a --text-selected-primary
fallback that carries the identical value pair. Legacy brands render
byte-identically; every declaration sits under
[data-brand='codeai-next']. Same pattern as Tags (#73901) and
Chips (#74003).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@levadadenys
levadadenys requested a review from a team as a code owner July 21, 2026 17:03

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f01b73137e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread frontend/packages/component-library/src/toggle/toggle.module.scss
@levadadenys
levadadenys requested a review from Copilot July 21, 2026 17:15
@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown

🖼️ Storybook Visual Comparison Report

✅ No Storybook eyes differences detected!

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.

Pull request overview

Adds data-brand='codeai-next'-scoped (CADS) styling overrides to the DSCO Toggle component so Toggle colors match CADS semantics under the CodeAI-next brand while keeping legacy brands byte-identical.

Changes:

  • Add a [data-brand='codeai-next'] override block in Toggle SCSS to swap ON/OFF track, thumb, and icon colors to CADS selected/neutral tokens.
  • Re-declare hover/pressed/disabled combinations under the brand scope to preserve the intended cascade without !important.
  • Add a CSS variable fallback for the selected thumb “primary-inverse” token until it exists in the sandbox export.

Comment thread frontend/packages/component-library/src/toggle/toggle.module.scss
Fixes the dark-mode contrast finding from review: the CADS neutral ramp
inverts in Dark (septenary resolves to gray-30), so the legacy
fixed-white thumb and x icon sat at ~1.9:1 on the OFF track, below the
3:1 UI-component threshold. Per the Figma spec the thumb fill is
background/neutral/primary (theme-following); the OFF icon pairs with
text-neutral-primary-inverse. Light rendering is unchanged (both
resolve to white); Dark now renders black-on-gray. The disabled thumb
keeps the legacy white-fixed fill.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@levadadenys

Copy link
Copy Markdown
Contributor Author

Re the Eyes report: the diffs are all in the markdown package's e2e visual tests, which this PR doesn't touch — the same markdown / e2e failure is currently hitting staging itself and essentially every open branch (stale markdown baseline repo-wide), not a regression here. The component-library / eyes job — the one that snapshots the Toggle stories (at the default legacy brand) — passed, which is the byte-identical-legacy guarantee this PR claims.

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