[CLOV-CSS] Migrate bpk-component-slider to CSS custom properties - #4923
[CLOV-CSS] Migrate bpk-component-slider to CSS custom properties#4923Gert-Jan Vercauteren (gert-janvercauteren) wants to merge 2 commits into
Conversation
|
Visit https://backpack.github.io/storybook-prs/4923 to see this build running in a browser. |
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 parts of bpk-component-slider to CSS custom properties for improved theming (including dark mode) and updates theme attribute exports/tests, while also adding dark-mode Storybook coverage and introducing additional CSS custom property migrations in other components.
Changes:
- Updated slider styling to use semantic CSS custom properties for track/range/thumb colours and updated exported theme attribute keys accordingly.
- Added dark mode visual/test stories for Slider, Tooltip, Dialog, and InsetBanner.
- Switched several InsetBanner/Dialog SCSS values to CSS custom property fallbacks.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/backpack-web/src/bpk-component-tooltip/src/BpkTooltip.stories.tsx | Adds a dark-mode Percy visual test story for tooltip. |
| packages/backpack-web/src/bpk-component-slider/src/themeAttributes.ts | Replaces old slider theme attribute key(s) with new semantic keys and exports a named constant. |
| packages/backpack-web/src/bpk-component-slider/src/themeAttributes-test.ts | Updates assertions to match the new theme attribute exports/keys. |
| packages/backpack-web/src/bpk-component-slider/src/BpkSlider.stories.tsx | Adds a dark-mode visual test story using BpkDarkExampleWrapper. |
| packages/backpack-web/src/bpk-component-slider/src/BpkSlider.module.scss | Migrates slider colours from tokens to CSS custom property fallbacks. |
| packages/backpack-web/src/bpk-component-inset-banner/src/BpkInsetBannerV3/BpkInsetBannerV3.module.scss | Migrates radius/text colours to CSS custom property fallbacks. |
| packages/backpack-web/src/bpk-component-inset-banner/src/BpkInsetBannerV2/BpkInsetBannerSponsored.module.scss | Migrates radius/text colours to CSS custom property fallbacks and adds “gap” comments. |
| packages/backpack-web/src/bpk-component-inset-banner/src/BpkInsetBanner.stories.tsx | Adds a dark-mode story for inset banner. |
| packages/backpack-web/src/bpk-component-inset-banner/src/BpkInsetBanner.module.scss | Migrates radius/background/text colours to CSS custom property fallbacks. |
| packages/backpack-web/src/bpk-component-dialog/src/BpkDialogInner.module.scss | Adds CSS custom property fallback for surface contrast and adds “gap” comments. |
| packages/backpack-web/src/bpk-component-dialog/src/BpkDialog.stories.js | Adds a dark-mode story for dialog using BpkDarkExampleWrapper. |
| packages/backpack-web/src/bpk-component-dialog/src/BpkDialog.module.scss | Migrates dialog flare colours to CSS custom property fallbacks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7e23ee9 to
7e493fa
Compare
|
Visit https://backpack.github.io/storybook-prs/4923 to see this build running in a browser. |
7e493fa to
5e6270e
Compare
- Replace bare SASS tokens with CSS custom property var() calls - `bpk-line-day` → `var(--bpk-other-line-default, tokens.$bpk-line-day)` - `bpk-core-accent-day` / `bpk-private-slider-selected-day` split into: - knob: `var(--bpk-private-slider-bg-knob, tokens.$bpk-private-slider-selected-day)` - track: `var(--bpk-private-slider-bg-track, tokens.$bpk-private-slider-selected-day)` - Update themeAttributes.ts: expose `privateSliderBgKnob` and `privateSliderBgTrack` - Add dark mode story using BpkDarkExampleWrapper - Update themeAttributes-test.ts assertions Closes #4819 Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
5e6270e to
36ab934
Compare
|
Visit https://backpack.github.io/storybook-prs/4923 to see this build running in a browser. |
|
Visit https://backpack.github.io/storybook-prs/4923 to see this build running in a browser. |
Vincent Liu (xiaogliu)
left a comment
There was a problem hiding this comment.
--bpk-private-slider-bg-track and --bpk-private-slider-bg-knob are both wired to fall back to tokens.$bpk-private-slider-selected-day. But:
--bpk-private-slider-bg-track(light) =#0062e3--bpk-private-slider-bg-knob(light) =#0062e3$bpk-private-slider-selected-day=rgb(21, 70, 121)=#154679
The fallback value (#154679, a darker "pressed/active" blue) doesn't match the CSS var it's supposedly backing up (#0062e3, the normal accent blue). Before this PR, &__range and &__thumb used tokens.$bpk-core-accent-day (#0062e3 — which does match), and only the &:active (pressed) state used $bpk-private-slider-selected-day (#154679) for the darker pressed appearance.
This PR's migration collapsed all three (&__range, &__thumb, &__thumb:active) onto the same fallback token ($bpk-private-slider-selected-day), which means:
- The fallback (no-CSS-var-support) rendering now shows the darker "pressed" blue everywhere, not just on
:active— a visible colour regression for browsers without CSS custom property support. - More importantly, the SASS fallback no longer matches its own CSS var's value, breaking the "one CSS var, one accurate SASS fallback" invariant the migration is supposed to preserve.
Suggested fix: use tokens.$bpk-core-accent-day as the fallback for &__range and &__thumb (matching the pre-migration value and the CSS var), and keep $bpk-private-slider-selected-day only as the fallback for &:active.
CI is green and Percy shows no visual diff only because CSS var support masks the fallback mismatch in the test environment — this would only surface for actual fallback usage.
|
Waiting for 1 extra token. |
Summary
bpk-component-sliderSCSS to CSS custom properties for light/dark mode themingtokens.$bpk-line-daywithvar(--bpk-other-line-default, tokens.$bpk-line-day)on the track background$bpk-private-slider-selected-day/$bpk-core-accent-dayinto two semantic CSS vars:var(--bpk-private-slider-bg-knob, tokens.$bpk-private-slider-selected-day)var(--bpk-private-slider-bg-track, tokens.$bpk-private-slider-selected-day)themeAttributes.tsto exportprivateSliderBgKnobandprivateSliderBgTrack(replaces oldsliderBarColor)BpkDarkExampleWrapperthemeAttributes-test.tsassertions to match new keysCloses #4819
Test plan
pnpm run jest --testPathPatterns="bpk-component-slider"— all tests pass--bpk-private-slider-bg-*varsprivateSliderBgKnob/privateSliderBgTrackwork correctly🤖 Generated with Claude Code