Skip to content
This repository was archived by the owner on Aug 5, 2026. It is now read-only.

[CLOV-CSS] Migrate bpk-component-rating to CSS custom properties - #4944

Merged
Vincent Liu (xiaogliu) merged 2 commits into
mainfrom
migrate/css-vars-rating-4810
Jul 23, 2026
Merged

Vincent Liu (xiaogliu) merged 2 commits into
mainfrom
migrate/css-vars-rating-4810

Conversation

@gert-janvercauteren

Copy link
Copy Markdown
Contributor

Closes #4810

Summary

Migrates bpk-component-rating SCSS to CSS custom properties with SASS fallbacks, enabling dark mode support.

Changes

BpkRating.module.scss

  • $bpk-text-secondary-day → var(--bpk-text-secondary, tokens.$bpk-text-secondary-day) on __scale and __subtitle
  • $bpk-one-pixel-rem → var(--bpk-spacing-xxs, ...) on __text-wrapper--large padding-top
  • Replaced padding-right + bpk-rtl mixin with padding-inline-end (CSS logical property, handles RTL natively)
  • Removed now-unused @use '../../bpk-mixins/utils' import

BpkRating.stories.tsx

  • Added DarkExample component using BpkDarkExampleWrapper
  • Added VisualTestDark export with bpkTheme: 'dark' parameter
  • Added tags: ['dark-mode-compatible'] to meta

Copilot AI review requested due to automatic review settings July 22, 2026 08:26
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

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 several Backpack web components away from legacy themeable SCSS mixins toward CSS custom properties (with token fallbacks) and adds dark-mode Storybook examples/visual tests.

Changes:

  • Replace utils.bpk-themeable-property usage with var(--token, sass-fallback) in Switch/StarRating/Rating styles.
  • Remove component-specific themeAttributes exports for Switch and Star Rating (and update tests).
  • Add dark-mode Storybook stories/wrappers across multiple components for visual coverage.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/backpack-web/src/bpk-component-switch/src/themeAttributes.ts Removes exported theme attributes for Switch.
packages/backpack-web/src/bpk-component-switch/src/themeAttributes-test.tsx Updates Switch themeAttributes test expectation.
packages/backpack-web/src/bpk-component-switch/src/BpkSwitch.stories.tsx Adds dark-mode visual test story.
packages/backpack-web/src/bpk-component-switch/src/BpkSwitch.module.scss Switch styling now uses CSS custom properties (token vars).
packages/backpack-web/src/bpk-component-star-rating/src/themeAttributes.ts Removes exported theme attributes for Star Rating.
packages/backpack-web/src/bpk-component-star-rating/src/themeAttributes-test.ts Updates Star Rating themeAttributes test expectation.
packages/backpack-web/src/bpk-component-star-rating/src/BpkStarRating.stories.tsx Adds dark-mode visual test story.
packages/backpack-web/src/bpk-component-star-rating/src/BpkStar.module.scss Star fill/position updated to token CSS variables + logical properties.
packages/backpack-web/src/bpk-component-star-rating/src/BpkInteractiveStar.module.scss Adds TODO note; no functional change.
packages/backpack-web/src/bpk-component-rating/src/BpkRating.stories.tsx Adds dark-mode Storybook example + tags/params.
packages/backpack-web/src/bpk-component-rating/src/BpkRating.module.scss Rating styles migrated to CSS custom properties + logical properties.
packages/backpack-web/src/bpk-component-page-indicator/src/BpkPageIndicator.stories.tsx Adds dark-mode story and some formatting cleanups.
packages/backpack-web/src/bpk-component-horizontal-nav/src/BpkHorizontalNav.stories.js Adds dark-mode visual test story.
packages/backpack-web/src/bpk-component-grid-toggle/src/BpkGridToggle.stories.tsx Adds dark-mode story.
packages/backpack-web/src/bpk-component-grid-toggle/src/BpkGridToggle.module.scss Uses color-mix() with CSS custom properties for gradient.

💡 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 — this comment refers to a file/section that's no longer part of the current diff (superseded by a later commit on this branch). No action needed here.

*/

export default ['starRatingFilledColor'];
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 — this comment refers to a file/section that's no longer part of the current diff (superseded by a later commit on this branch). No action needed here.

Comment on lines +36 to +49
background: linear-gradient(
to bottom,
rgba(tokens.$bpk-status-danger-spot-day, 0.3) 0,
color-mix(
in srgb,
var(--bpk-status-danger-spot, tokens.$bpk-status-danger-spot-day)
30%,
transparent
)
0,
transparent tokens.$bpk-one-pixel-rem
)
repeat left 0;
background-size: tokens.bpk-spacing-sm() tokens.bpk-spacing-sm();
background-size: var(--bpk-spacing-sm, tokens.bpk-spacing-sm())
var(--bpk-spacing-sm, tokens.bpk-spacing-sm());

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 — this comment refers to a file/section that's no longer part of the current diff (superseded by a later commit on this branch). No action needed here.

Comment on lines +133 to +139
export const VisualTestDarkMode = {
render: () => (
<BpkDarkExampleWrapper>
<MixedExample />
</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 — this comment refers to a file/section that's no longer part of the current diff (superseded by a later commit on this branch). No action needed here.

@@ -17,7 +17,6 @@
*/

@use '../../bpk-mixins/tokens';

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 — this comment refers to the PR's earlier broader scope (switch/star-rating/grid-toggle were part of an earlier commit). The current diff only touches BpkRating.module.scss, so scope is now consistent with the title/description. No action needed.

Replaces bare SASS tokens in BpkRating.module.scss with
var(--css-var, sass-fallback) so colours respond to dark mode.

- color: tokens.$bpk-text-secondary-day → var(--bpk-text-secondary, ...)
  for both __scale and __subtitle
- padding-top: tokens.$bpk-one-pixel-rem → var(--bpk-spacing-xxs, ...)
  for __text-wrapper--large
- Replaced padding-right + bpk-rtl mixin with padding-inline-end
  (CSS logical property, handles RTL natively)
- Removed now-unused @use '../../bpk-mixins/utils' import

Adds VisualTestDark story and tags meta with dark-mode-compatible.
Closes #4810

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@xiaogliu

Copy link
Copy Markdown
Contributor

Token value audit — verified every new CSS var introduced in this PR against token-sync/css/theme-backpack-light.css / theme-backpack-dark.css and the original SASS token source (base.default.scss):

CSS var Old SASS fallback Light value Dark value Match
--bpk-spacing-xxs $bpk-one-pixel-rem 0.0625rem (no dark override — rem/radius values are theme-agnostic) ✅
--bpk-text-secondary $bpk-text-secondary-day #626971 #bdc4cb ✅

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 98f523d into main Jul 23, 2026
15 checks passed
@xiaogliu
Vincent Liu (xiaogliu) deleted the migrate/css-vars-rating-4810 branch July 23, 2026 08:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate bpk-component-rating to CSS custom properties

3 participants