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

[CLOV-CSS] Migrate bpk-component-label to CSS custom properties - #4921

Merged
Vincent Liu (xiaogliu) merged 4 commits into
mainfrom
migrate/css-vars-label-4846
Jul 27, 2026
Merged

Vincent Liu (xiaogliu) merged 4 commits into
mainfrom
migrate/css-vars-label-4846

Conversation

@gert-janvercauteren

Copy link
Copy Markdown
Contributor

Closes #4846

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

Changes

  • BpkLabel.module.scss: Replace bare tokens.$bpk-text-disabled-on-dark-day with var(--bpk-text-disabled-on-dark, tokens.$bpk-text-disabled-on-dark-day) to support automatic dark/light mode theming
  • Gap token: $bpk-form-validation-color (used for the required asterisk colour) has no CSS var equivalent yet — kept as bare SASS token with a /* gap: ... */ comment
  • Removed bpk-themeable-property mixin call for the asterisk colour (replaced with plain CSS)
  • Removed unused @use utils import
  • BpkLabel.stories.tsx: Added DarkMode story showing white/disabled/invalid label variants wrapped in BpkDarkExampleWrapper

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

Copy link
Copy Markdown
Contributor

- Replace bare `tokens.$bpk-text-disabled-on-dark-day` with
  `var(--bpk-text-disabled-on-dark, tokens.$bpk-text-disabled-on-dark-day)`
- Remove `bpk-themeable-property` mixin call for `$bpk-form-validation-color`
  (no CSS var exists yet); add gap comment and keep bare SASS token
- Remove unused `@use utils` import
- Add `DarkMode` story showing white/disabled/invalid label variants on dark bg

Closes #4846

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

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.

Updates several Backpack Web components to better support dark mode by introducing CSS custom property fallbacks (and adding dark-mode Storybook examples), while keeping a few SASS token “gaps” where no semantic CSS vars exist yet.

Changes:

  • Add dark-mode Storybook stories/wrappers for Overlay, Label, and Floating Notification.
  • Replace several hard-coded “day” color usages with CSS custom properties + SASS fallbacks.
  • Adjust SCSS for overlays/notifications (notably switching from rgba() to color-mix() for CSS-var compatibility).

Reviewed changes

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

Show a summary per file
File Description
packages/backpack-web/src/bpk-component-overlay/src/BpkOverlay.stories.tsx Adds a dark-mode Storybook example wrapper around MixedExample.
packages/backpack-web/src/bpk-component-overlay/src/BpkOverlay.module.scss Migrates overlay opacity colors to color-mix() with CSS var fallbacks.
packages/backpack-web/src/bpk-component-label/src/BpkLabel.stories.tsx Adds a dark-mode story showcasing white/invalid/disabled label states.
packages/backpack-web/src/bpk-component-label/src/BpkLabel.module.scss Uses CSS custom properties for disabled-on-dark label color; changes asterisk styling.
packages/backpack-web/src/bpk-component-floating-notification/src/BpkFloatingNotification.stories.tsx Adds dark-mode stories and a dark-mode-compatible tag.
packages/backpack-web/src/bpk-component-floating-notification/src/BpkFloatingNotification.module.scss Switches to CSS var fallbacks for key colors/radius and adjusts critical variant tokens.

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

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

xiaogliu

This comment was marked as duplicate.

@xiaogliu

This comment was marked as duplicate.

@xiaogliu

Vincent Liu (xiaogliu) commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

GitHub-wide usage search for the removed theming hook (--bpk-form-validation-text-color / camelCase formValidationTextColor):

Searched github.com (via gh search code, covering public + private repos this account has access to) for both the raw CSS var name and the camelCase themeAttributes key.

Results — no real consumer usage found. Hits are limited to:

  • Skyscanner/backpack itself (source of the hook/type definitions)
  • Skyscanner/ain-backpack — private test-drive clone, not a production consumer

No product repo anywhere in the org overrides formValidationTextColor via BpkThemeProvider.

Conclusion: This is not an issue.


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-text-disabled-on-dark $bpk-text-disabled-on-dark-day rgba(255,255,255,0.5) rgba(255,255,255,0.5) ✅

⚠️ Real gap found on the second declaration (&__asterisk): the old code used bpk-themeable-property(color, --bpk-form-validation-text-color, tokens.$bpk-form-validation-color), which set the colour and wired up a CSS var. The new code drops this to a bare SASS token:

color: tokens.$bpk-form-validation-color;

No var() wrapper at all — this asterisk colour will not respond to dark mode or any future theme override, unlike every other colour declaration in this PR series.

This looks like a missed migration line, not an intentional gap: $bpk-form-validation-color = rgb(231,8,102) = #e70866, which is exactly the value of the existing global var --bpk-status-danger-spot (#e70866 light / #ff649c dark) — so a suitable CSS var already exists and this line should be:

color: var(--bpk-status-danger-spot, tokens.$bpk-form-validation-color);

(Separately — the hook-removal usage search I posted earlier on this PR still holds: no real consumer uses formValidationTextColor, so removing the old hook itself is safe. This comment is about the replacement being incomplete, not about the hook removal being risky.)

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@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 0bcfafb into main Jul 27, 2026
15 checks passed
@xiaogliu
Vincent Liu (xiaogliu) deleted the migrate/css-vars-label-4846 branch July 27, 2026 05:34
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-label to CSS custom properties

3 participants