Skip to content

[CLOV-CSS] Migrate bpk-component-overlay to CSS custom properties - #4927

Draft
Gert-Jan Vercauteren (gert-janvercauteren) wants to merge 3 commits into
mainfrom
migrate/css-vars-overlay-4843
Draft

[CLOV-CSS] Migrate bpk-component-overlay to CSS custom properties#4927
Gert-Jan Vercauteren (gert-janvercauteren) wants to merge 3 commits into
mainfrom
migrate/css-vars-overlay-4843

Conversation

@gert-janvercauteren

Copy link
Copy Markdown
Contributor

Closes #4843

What

Migrates bpk-component-overlay SCSS to use CSS custom properties with SASS fallbacks.

Changes

  • BpkOverlay.module.scss: Replaces all rgba(tokens.$bpk-text-primary-day, N) calls with color-mix(in srgb, var(--bpk-text-primary, tokens.$bpk-text-primary-day) N%, transparent). This is required because CSS rgba() cannot accept custom properties as the colour argument, but color-mix can.
  • BpkOverlay.stories.tsx: Adds a DarkMode story using BpkDarkExampleWrapper to demonstrate theme-aware overlay rendering.

Token mapping

Token CSS var Note
$bpk-text-primary-day --bpk-text-primary All solid/gradient/vignette/heavy overlays
$bpk-color-sky-blue-shade-03 Gap: raw primitive, no semantic CSS var mapping

Test

All 24 existing tests pass unchanged.

Replaces rgba(tokens.\$bpk-text-primary-day, N) with
color-mix(in srgb, var(--bpk-text-primary, tokens.\$bpk-text-primary-day) N%, transparent)
so overlays adapt automatically between light and dark themes.

Gap token \$bpk-color-sky-blue-shade-03 (tint variant) kept as bare SASS
with a comment — no semantic CSS var mapping exists.

Adds a DarkMode story using BpkDarkExampleWrapper.

Closes #4843

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 22, 2026 07:54

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-overlay styling from SCSS rgba() usage to CSS custom properties via color-mix(), and adds a Storybook example to validate rendering in dark mode.

Changes:

  • Replaced overlay rgba(tokens.$bpk-text-primary-day, …) values with color-mix(in srgb, var(--bpk-text-primary, …) …%, transparent) variants.
  • Added a Dark Mode Storybook story using BpkDarkExampleWrapper.

Reviewed changes

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

File Description
packages/backpack-web/src/bpk-component-overlay/src/BpkOverlay.module.scss Switches overlay colors/gradients/vignette to use themeable CSS custom properties via color-mix().
packages/backpack-web/src/bpk-component-overlay/src/BpkOverlay.stories.tsx Adds a dark-mode Storybook story and imports the dark wrapper utility.

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

Comment on lines +21 to +22
// @ts-expect-error Untyped import
import { BpkDarkExampleWrapper } from 'bpk-storybook-utils';

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 @ts-expect-error suppression that's no longer present in the current diff (superseded by a later commit on this branch). No action needed.

Comment on lines +50 to +54
background: color-mix(
in srgb,
var(--bpk-text-primary, tokens.$bpk-text-primary-day) 15%,
transparent
);
Comment on lines 76 to 85
background: linear-gradient(
180deg,
rgba(tokens.$bpk-text-primary-day, 0.15) 0%,
rgba(tokens.$bpk-text-primary-day, 0) 100%
color-mix(
in srgb,
var(--bpk-text-primary, tokens.$bpk-text-primary-day) 15%,
transparent
)
0%,
transparent 100%
);
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

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

@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.

Reviewed ✅ — no issues found.

  • --bpk-text-primary (light #161616 / dark #ffffff) confirmed to match $bpk-text-primary-day exactly.
  • Using color-mix(in srgb, var(--bpk-text-primary, ...) X%, transparent) in place of rgba(tokens.$bpk-text-primary-day, X) is the right approach here — rgba() can't accept a CSS custom property as its color argument, so color-mix() is necessary to let the opacity overlay respond to the color var. All opacity percentages carried over correctly (15/30/40/45/12/90% etc. all match their pre-migration rgba() alpha values).
  • Percy shows zero visual diff, which cross-confirms the color-mix() math renders identically to the original rgba() at every opacity level used.

Solid migration of a trickier case (color mixed with alpha, not a flat property value).

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-overlay to CSS custom properties

3 participants