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

[CLOV-CSS] Migrate bpk-component-price-range to CSS custom properties - #4931

Merged
Vincent Liu (xiaogliu) merged 3 commits into
mainfrom
migrate/css-vars-price-range-4818
Jul 23, 2026
Merged

Vincent Liu (xiaogliu) merged 3 commits into
mainfrom
migrate/css-vars-price-range-4818

Conversation

@gert-janvercauteren

Copy link
Copy Markdown
Contributor

Closes #4818

Summary

Migrates bpk-component-price-range SCSS to CSS custom properties with SASS fallbacks for light/dark mode support.

Changes

BpkPriceRange.module.scss — 12 CSS var replacements:

  • $bpk-status-success-spot-day → var(--bpk-status-success-spot, ...)
  • $bpk-core-primary-day → var(--bpk-core-primary, ...)
  • $bpk-status-danger-spot-day → var(--bpk-status-danger-spot, ...)
  • $bpk-text-primary-inverse-day → var(--bpk-text-inverse, ...)
  • $bpk-border-radius-sm/md → var(--bpk-radius-sm/md, ...)

BpkPriceMarker.module.scss — 6 CSS var replacements:

  • $bpk-border-radius-xs → var(--bpk-radius-xs, ...)
  • $bpk-text-primary-inverse-day → var(--bpk-text-inverse, ...)
  • $bpk-status-success-spot-day → var(--bpk-status-success-spot, ...)
  • $bpk-core-primary-day → var(--bpk-core-primary, ...)
  • $bpk-status-danger-spot-day → var(--bpk-status-danger-spot, ...)
  • $bpk-box-shadow-sm kept as bare SASS token (no CSS var equivalent)

BpkPriceRange.stories.tsx — Adds VisualTestDark story using BpkDarkExampleWrapper.

No themeAttributes.tsx needed — the component has none.

Test plan

  • 19 existing tests pass
  • Dark mode story renders correct colours under dark theme

Copilot AI review requested due to automatic review settings July 22, 2026 07:56

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-price-range styling toward CSS custom properties (with Sass token fallbacks) and adds a dark-mode visual regression Storybook entry.

Changes:

  • Replaced multiple SCSS design tokens with var(--*, token-fallback) in BpkPriceRange and BpkPriceMarker styles for themeability.
  • Added a VisualTestDark story using BpkDarkExampleWrapper to validate dark mode rendering.
  • Also updates BpkTooltip.module.scss to use CSS custom properties for a few colors.

Reviewed changes

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

File Description
packages/backpack-web/src/bpk-component-tooltip/src/BpkTooltip.module.scss Switches select tooltip colors to CSS custom properties with token fallbacks.
packages/backpack-web/src/bpk-component-price-range/src/BpkPriceRange.stories.tsx Adds a dark-mode Percy/visual test story wrapper.
packages/backpack-web/src/bpk-component-price-range/src/BpkPriceRange.module.scss Migrates key colors/radii to CSS vars with Sass fallbacks.
packages/backpack-web/src/bpk-component-price-range/src/BpkPriceMarker.module.scss Migrates marker colors/radii to CSS vars with Sass fallbacks; documents shadow gap.

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

Comment on lines +25 to +31
$dark-background-color: var(
--bpk-surface-contrast,
tokens.$bpk-surface-contrast-day
);

.bpk-tooltip--container {
z-index: tokens.$bpk-zindex-tooltip;
z-index: tokens.$bpk-zindex-tooltip; /* gap: z-index, not in token-sync */

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 tooltip file is no longer part of this PR's diff (removed in a later commit), so scope is now consistent with the title/description. No action needed.

Comment on lines +57 to +74
border-end-start-radius: var(
--bpk-radius-sm,
tokens.$bpk-border-radius-sm
);
border-start-start-radius: var(
--bpk-radius-sm,
tokens.$bpk-border-radius-sm
);

&Large {
border-end-start-radius: tokens.$bpk-border-radius-md;
border-start-start-radius: tokens.$bpk-border-radius-md;
border-end-start-radius: var(
--bpk-radius-md,
tokens.$bpk-border-radius-md
);
border-start-start-radius: var(
--bpk-radius-md,
tokens.$bpk-border-radius-md
);

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.

Pre-existing pattern, not introduced by this PR — the repeated $bpk-border-radius-sm/-md values already existed on main before this migration (border-end-start-radius / border-start-start-radius pairs). This PR migrated each occurrence to var() in place to keep the diff minimal and preserve existing behavior; extracting a shared local variable would be a good follow-up but is out of scope for this token-value migration.

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.

We will remove the fallback variable in the future, no need extract the expression.

Comment on lines +253 to +266
const DarkExample = () => (
<BpkDarkExampleWrapper>
<MixedExample />
</BpkDarkExampleWrapper>
);

export const VisualTestDark = {
render: () => <DarkExample />,
parameters: {
percy: {
waitForTimeout: 10000,
},
},
};

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 DarkExample story this comment refers to is no longer present in the current diff (removed/reworked in a later commit). No action needed.

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

Replaces bare SASS tokens with var()/fallback pairs:
- $bpk-border-radius-xs/sm/md → var(--bpk-radius-xs/sm/md)
- $bpk-core-primary-day → var(--bpk-core-primary)
- $bpk-status-danger-spot-day → var(--bpk-status-danger-spot)
- $bpk-status-success-spot-day → var(--bpk-status-success-spot)
- $bpk-text-primary-inverse-day → var(--bpk-text-inverse)
- $bpk-box-shadow-sm kept bare (no CSS var available)

Adds VisualTestDark story using BpkDarkExampleWrapper.

Closes #4818

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
@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-radius-xs $bpk-border-radius-xs 0.25rem (no dark override — rem/radius values are theme-agnostic) ✅
--bpk-text-inverse $bpk-text-primary-inverse-day #ffffff #010913 ✅
--bpk-status-success-spot $bpk-status-success-spot-day #0c838a #62f1c6 ✅
--bpk-core-primary $bpk-core-primary-day #05203c #054184 ✅
--bpk-status-danger-spot $bpk-status-danger-spot-day #e70866 #ff649c ✅
--bpk-radius-sm $bpk-border-radius-sm 0.5rem (no dark override — rem/radius values are theme-agnostic) ✅
--bpk-radius-md $bpk-border-radius-md 0.75rem (no dark override — rem/radius values are theme-agnostic) ✅

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 88b59db into main Jul 23, 2026
20 of 21 checks passed
@xiaogliu
Vincent Liu (xiaogliu) deleted the migrate/css-vars-price-range-4818 branch July 23, 2026 08:54
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-price-range to CSS custom properties

3 participants