[CLOV-CSS] Migrate bpk-component-radio to CSS custom properties - #4935
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Migrates bpk-component-radio theming away from SCSS-only theming helpers toward CSS custom properties, while adding Storybook coverage for dark mode and documenting a gap token.
Changes:
- Replaced radio SCSS theme mixin usage with
var(--*, fallback)usage for theming. - Introduced
allRadioThemeAttributesexport (and updated tests) to expose private radio CSS var keys while keeping the legacyradioCheckedColorexport. - Added dark mode Storybook coverage and documented
$bpk-one-pixel-remas a gap token with no CSS var equivalent.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/backpack-web/src/bpk-component-select/src/BpkSelect.stories.tsx | Adds a dark mode visual test story using BpkDarkExampleWrapper. |
| packages/backpack-web/src/bpk-component-select/src/BpkSelect.module.scss | Documents $bpk-one-pixel-rem as a gap token without a CSS var equivalent. |
| packages/backpack-web/src/bpk-component-radio/src/themeAttributes.tsx | Adds allRadioThemeAttributes and keeps the deprecated legacy themeAttributes default export. |
| packages/backpack-web/src/bpk-component-radio/src/themeAttributes.ts | Removes the old default export in favor of the new TSX module. |
| packages/backpack-web/src/bpk-component-radio/src/themeAttributes-test.ts | Extends tests to assert both legacy and new theme attribute exports. |
| packages/backpack-web/src/bpk-component-radio/src/BpkRadio.stories.tsx | Adds a dark mode Storybook story using BpkDarkExampleWrapper. |
| packages/backpack-web/src/bpk-component-radio/src/BpkRadio.module.scss | Switches radio styles to CSS custom properties with SCSS fallbacks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export const allRadioThemeAttributes = [ | ||
| 'privateRadioBgDefaultDisabled', | ||
| 'privateRadioBgDefaultOn', | ||
| 'privateRadioBgOnContrastOff', | ||
| 'privateRadioBgOnContrastOn', | ||
| 'privateRadioBorder', | ||
| 'privateRadioBorderDefaultOff', | ||
| ]; | ||
|
|
||
| /** | ||
| * @deprecated Use allRadioThemeAttributes instead. | ||
| * This key pre-dates the CSS custom property migration and mapped to | ||
| * --bpk-radio-checked-color which is no longer used in the SCSS. | ||
| * Will be removed in the next major release. | ||
| */ | ||
| const themeAttributes = ['radioCheckedColor']; | ||
|
|
||
| export default themeAttributes; |
There was a problem hiding this comment.
Outdated — themeAttributes.tsx is no longer part of this PR's current diff (superseded by a later commit, which only touches BpkRadio.module.scss now). No action needed.
| /** | ||
| * Combined deduplicated array of all radio private theme attributes. | ||
| * Only exposes component-scoped (private) radio tokens — global semantic vars | ||
| * (text, deprecated-link) can be overridden at the theme level independently. | ||
| * | ||
| * Camelcase conversion: strip `--bpk-`, convert kebab to camelCase. | ||
| * e.g. --bpk-private-radio-bg-default-on -> privateRadioBgDefaultOn | ||
| */ |
There was a problem hiding this comment.
Outdated — themeAttributes.tsx is no longer part of this PR's current diff. No action needed.
| export const DarkMode = { | ||
| render: () => <DarkExample />, | ||
| }; |
There was a problem hiding this comment.
Outdated — BpkRadio.stories.tsx is no longer part of this PR's current diff (scope is now consistent with the title/description, only BpkRadio.module.scss). No action needed.
51be041 to
a047532
Compare
|
Visit https://backpack.github.io/storybook-prs/4935 to see this build running in a browser. |
Closes #4816 - Replace bpk-themeable-property mixin with plain var() in __circle bg - Replace bare SASS color tokens with CSS vars + SASS fallbacks: - tokens.\$bpk-text-disabled-on-dark-day => var(--bpk-text-disabled-on-dark, ...) - tokens.\$bpk-text-disabled-day => var(--bpk-text-disabled, ...) - tokens.\$bpk-text-link-day => var(--bpk-text-deprecated-link, ...) - Add comment for \$bpk-one-pixel-rem (no CSS var equivalent) - Create themeAttributes.tsx with allRadioThemeAttributes for all --bpk-private-radio-* vars and deprecated radioCheckedColor key - Create themeAttributes-test.tsx asserting both exports - Remove old themeAttributes.ts and themeAttributes-test.ts - Add DarkMode story using BpkDarkExampleWrapper Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
a047532 to
dc8069f
Compare
|
Visit https://backpack.github.io/storybook-prs/4935 to see this build running in a browser. |
|
Visit https://backpack.github.io/storybook-prs/4935 to see this build running in a browser. |
|
Visit https://backpack.github.io/storybook-prs/4935 to see this build running in a browser. |
|
Token value audit — verified every new CSS var against
All new/old values match — no visual regression risk from this migration. |
Closes #4816
Summary
bpk-themeable-propertymixin with plainvar()for the circle backgroundtokens.$bpk-text-disabled-on-dark-day→var(--bpk-text-disabled-on-dark, ...)tokens.$bpk-text-disabled-day→var(--bpk-text-disabled, ...)tokens.$bpk-text-link-day→var(--bpk-text-deprecated-link, ...)$bpk-one-pixel-rem(no CSS var equivalent — gap token)themeAttributes.tsxwithallRadioThemeAttributesexposing all--bpk-private-radio-*vars as camelCase keys, plus deprecatedradioCheckedColorkeythemeAttributes-test.tsxasserting both exportsthemeAttributes.tsandthemeAttributes-test.tsDarkModeStorybook story usingBpkDarkExampleWrapperTest plan
themeAttributes-test.tsxasserts boththemeAttributes(legacy) andallRadioThemeAttributesstylelintandeslintpass on all modified files$bpk-one-pixel-remleft as bare SASS token with comment per spec🤖 Generated with Claude Code