Skip to content

[CLOV-CSS] Migrate bpk-component-switch to CSS custom properties#4941

Merged
Vincent Liu (xiaogliu) merged 3 commits into
mainfrom
migrate/css-vars-switch-4827
Jul 24, 2026
Merged

[CLOV-CSS] Migrate bpk-component-switch to CSS custom properties#4941
Vincent Liu (xiaogliu) merged 3 commits into
mainfrom
migrate/css-vars-switch-4827

Conversation

@gert-janvercauteren

Copy link
Copy Markdown
Contributor

Closes #4827

Changes

Migrates bpk-component-switch SCSS to CSS custom properties with SASS token fallbacks.

SCSS (BpkSwitch.module.scss)

  • tokens.$bpk-core-accent-dayvar(--bpk-core-accent, tokens.$bpk-core-accent-day) (checked track background)
  • tokens.$bpk-text-disabled-dayvar(--bpk-text-disabled, tokens.$bpk-text-disabled-day) (unchecked track background)
  • tokens.$bpk-text-on-dark-dayvar(--bpk-text-on-dark, tokens.$bpk-text-on-dark-day) (handle background)
  • Removes legacy bpk-themeable-property mixin call

themeAttributes.ts

  • Removes switchCheckedColor--bpk-core-accent is a global semantic var set at the theme level, not a per-component override

BpkSwitch.stories.tsx

  • Adds VisualTestDarkMode story using BpkDarkExampleWrapper

Copilot AI review requested due to automatic review settings July 22, 2026 08:21

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

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-switch theming from SCSS token values / legacy themeable mixins to CSS custom properties with token fallbacks, and updates Storybook coverage for dark mode scenarios.

Changes:

  • Removes switchCheckedColor as a per-component theme attribute and updates the corresponding test.
  • Updates BpkSwitch styles to use semantic CSS custom properties with SASS token fallbacks.
  • Adds dark mode Storybook stories (and includes additional grid-toggle styling/story updates).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/backpack-web/src/bpk-component-switch/src/themeAttributes.ts Removes per-component theme attribute export (now empty).
packages/backpack-web/src/bpk-component-switch/src/themeAttributes-test.tsx Updates expectations to match empty theme attributes.
packages/backpack-web/src/bpk-component-switch/src/BpkSwitch.stories.tsx Adds dark mode visual test story wrapper.
packages/backpack-web/src/bpk-component-switch/src/BpkSwitch.module.scss Replaces legacy themeable mixin usage with CSS custom properties + token fallbacks.
packages/backpack-web/src/bpk-component-grid-toggle/src/BpkGridToggle.stories.tsx Adds a dark mode story wrapper.
packages/backpack-web/src/bpk-component-grid-toggle/src/BpkGridToggle.module.scss Introduces CSS custom properties and color-mix() usage for gradient styling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

*/

export default ['switchCheckedColor'];
export default [];

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.

Outdated — themeAttributes.ts is no longer part of this PR's current diff (superseded by a later commit on this branch, which only touches BpkSwitch.module.scss now). No action needed.

Comment on lines +38 to +44
color-mix(
in srgb,
var(--bpk-status-danger-spot, tokens.$bpk-status-danger-spot-day)
30%,
transparent
)
0,

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.

Outdated — BpkGridToggle.module.scss is no longer part of this PR's current diff (superseded by a later commit on this branch, which only touches BpkSwitch.module.scss now). No action needed.

Comment on lines +54 to +60
export const DarkMode: Story = {
render: () => (
<BpkDarkExampleWrapper>
<DefaultExample />
</BpkDarkExampleWrapper>
),
};

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.

Outdated — the grid-toggle files this comment refers to are no longer part of this PR's current diff (scope is now consistent with the title/description, only BpkSwitch.module.scss). No action needed.

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

Visit https://backpack.github.io/storybook-prs/4941 to see this build running in a browser.

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

Visit https://backpack.github.io/storybook-prs/4941 to see this build running in a browser.

Closes #4811

- Replace rgba() with color-mix() to support CSS var for status-danger-spot
- Wrap bpk-spacing-sm() with var(--bpk-spacing-sm) for theme-responsive spacing
- Add DarkMode story using BpkDarkExampleWrapper
- bpk-one-pixel-rem kept as SASS token (no CSS var equivalent)

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
React19 TypeScript migration requires explicit suppression for untyped
bpk-storybook-utils imports.
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

Visit https://backpack.github.io/storybook-prs/4941 to see this build running in a browser.

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

Visit https://backpack.github.io/storybook-prs/4941 to see this build running in a browser.

@xiaogliu

Copy link
Copy Markdown
Contributor

Token value audit — verified every new CSS var against token-sync/css/theme-backpack-light.css / theme-backpack-dark.css and base.default.scss:

CSS var Old SASS fallback Light value Dark value Match
--bpk-core-accent $bpk-core-accent-day #0062e3 #84e9ff
--bpk-text-disabled $bpk-text-disabled-day rgba(0,0,0,0.2) rgba(255,255,255,0.2)
--bpk-text-on-dark $bpk-text-on-dark-day #ffffff #ffffff

All new/old values match — no visual regression risk from this migration.

@xiaogliu Vincent Liu (xiaogliu) 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.

LGTM

@xiaogliu
Vincent Liu (xiaogliu) merged commit ae4af5e into main Jul 24, 2026
15 checks passed
@xiaogliu
Vincent Liu (xiaogliu) deleted the migrate/css-vars-switch-4827 branch July 24, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate bpk-component-switch to CSS custom properties

3 participants