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

[CLOV-CSS] Migrate bpk-component-skip-link to CSS custom properties - #4926

Merged
Vincent Liu (xiaogliu) merged 3 commits into
mainfrom
migrate/css-vars-skip-link-4814
Jul 26, 2026
Merged

Vincent Liu (xiaogliu) merged 3 commits into
mainfrom
migrate/css-vars-skip-link-4814

Conversation

@gert-janvercauteren

Copy link
Copy Markdown
Contributor

Closes #4814

Changes

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

SCSS (BpkSkipLink.module.scss)

  • Removed @use '../../bpk-mixins/utils' (no longer needed)
  • Removed @include utils.bpk-themeable-property(...) legacy hook
  • tokens.$bpk-status-danger-spot-day → var(--bpk-status-danger-spot, tokens.$bpk-status-danger-spot-day)
  • tokens.$bpk-text-on-dark-day → var(--bpk-text-on-dark, tokens.$bpk-text-on-dark-day)
  • tokens.$bpk-border-radius-sm → var(--bpk-radius-sm, tokens.$bpk-border-radius-sm)
  • Gap tokens kept bare with comments: $bpk-duration-sm and $bpk-one-pixel-rem

themeAttributes

  • Cleared to [] — global semantic CSS vars (--bpk-status-danger-spot, --bpk-text-on-dark) are theme-level concerns and not exposed as per-component theme attributes

Stories (BpkSkipLink.stories.tsx)

  • Added DarkMode story using BpkDarkExampleWrapper

Copilot AI review requested due to automatic review settings July 22, 2026 07:53
@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 bpk-component-skip-link styling from legacy theme hooks to semantic CSS custom properties (with Sass fallbacks) and adds dark mode Storybook coverage, while also aligning inset banner styling with the same semantic variables.

Changes:

  • Replaced legacy themeable-property usage with semantic CSS custom properties + Sass fallbacks in BpkSkipLink.module.scss.
  • Removed per-component themeAttributes exposure for skip link and updated its unit test.
  • Added DarkMode stories (wrapper-based) and updated inset banner SCSS to use semantic CSS variables.

Reviewed changes

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

Show a summary per file
File Description
packages/backpack-web/src/bpk-component-skip-link/src/themeAttributes.ts Removes exported theme attributes for the component.
packages/backpack-web/src/bpk-component-skip-link/src/themeAttributes-test.js Updates expectation to match the empty theme attributes list.
packages/backpack-web/src/bpk-component-skip-link/src/BpkSkipLink.stories.tsx Adds a dark mode story using BpkDarkExampleWrapper.
packages/backpack-web/src/bpk-component-skip-link/src/BpkSkipLink.module.scss Switches skip-link styling to semantic CSS variables with Sass fallbacks.
packages/backpack-web/src/bpk-component-inset-banner/src/BpkInsetBannerV3/BpkInsetBannerV3.module.scss Uses semantic CSS vars for radius/text colors.
packages/backpack-web/src/bpk-component-inset-banner/src/BpkInsetBannerV2/BpkInsetBannerSponsored.module.scss Uses semantic CSS vars for radius/text colors; annotates gaps.
packages/backpack-web/src/bpk-component-inset-banner/src/BpkInsetBanner.stories.tsx Adds a dark mode story using BpkDarkExampleWrapper (with TS suppression).
packages/backpack-web/src/bpk-component-inset-banner/src/BpkInsetBanner.module.scss Uses semantic CSS vars for radius/text colors/background with fallbacks.

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

Comment on lines +19 to +20
import { ArgTypes, Markdown } from '@storybook/addon-docs/blocks';
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 — BpkSkipLink.stories.tsx is no longer part of this PR's current diff (superseded by a later commit, which only touches BpkSkipLink.module.scss now). No action needed.

Comment on lines +26 to +29
background-color: var(
--bpk-status-danger-spot,
tokens.$bpk-status-danger-spot-day
);

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.

Confirmed — this is a real, intentional API change flagged for design/PR-owner sign-off, not a code bug. The value itself is correct (verified in the token-value audit comment on this PR: --bpk-status-danger-spot matches $bpk-status-danger-spot-day exactly, light #e70866 / dark #ff649c). The tradeoff is real: any consumer currently overriding --bpk-skip-link-background-color via BpkThemeProvider will silently lose that override, since the component-scoped hook is being replaced by a global semantic var rather than kept as a legacy fallback. This same pattern recurs across the whole CSS-vars migration series (switch, radio, star-rating, progress, horizontal-nav, label) — worth a one-time design-system-owner decision on whether legacy hooks should be preserved as fallbacks, rather than resolving PR-by-PR.

Comment on lines +169 to +170
linkText: 'More information',
link: 'www.skyscanner.net',

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.

This story content (the relative link string) pre-existed on main before this PR — not introduced by this migration. Out of scope for a CSS-vars migration PR; worth a separate cleanup PR if desired.

Comment on lines +27 to +31
border-radius: var(--bpk-radius-sm, tokens.$bpk-border-radius-sm);

&--with-body {
border-radius: tokens.$bpk-border-radius-sm tokens.$bpk-border-radius-sm 0 0;
border-radius: var(--bpk-radius-sm, tokens.$bpk-border-radius-sm)
var(--bpk-radius-sm, tokens.$bpk-border-radius-sm) 0 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.

Pre-existing pattern, not introduced by this PR — the repeated $bpk-border-radius-sm already existed on main before this migration. 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.

Comment on lines +100 to +101
border-radius: 0 0 var(--bpk-radius-sm, tokens.$bpk-border-radius-sm)
var(--bpk-radius-sm, tokens.$bpk-border-radius-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.

Same as the earlier comment on this pattern — pre-existing duplication, not introduced by this PR.

Replaces static SASS tokens with CSS var() calls and SASS fallbacks to
enable light/dark theme switching. Removes legacy bpk-themeable-property
hook and clears themeAttributes since global semantic vars are used.
Adds dark mode Storybook story.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
@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.

⚠️ Found a theming regression — needs a fix before merge.

This PR removes @include utils.bpk-themeable-property(background-color, --bpk-skip-link-background-color, tokens.$bpk-status-danger-spot-day) and replaces it with background-color: var(--bpk-status-danger-spot, tokens.$bpk-status-danger-spot-day).

Problem: packages/backpack-web/src/bpk-component-skip-link/src/themeAttributes.ts still exports ['skipLinkBackgroundColor'], and theming.ts still declares a default for it. BpkThemeProvider will keep injecting an inline --bpk-skip-link-background-color CSS var, but nothing in the SCSS references that var name anymore — the theming hook is now silently dead. themeAttributes-test.js still asserts toEqual(['skipLinkBackgroundColor']) so this ships green with no test failure.

Either:

  1. Keep both — reference --bpk-skip-link-background-color with the new --bpk-status-danger-spot as its fallback (nested var), or
  2. Remove skipLinkBackgroundColor from themeAttributes.ts/theming.ts/the test if the intent is to fully replace the component-scoped hook with the global semantic var — but that's a deliberate API change that should probably be called out in the PR description, since it removes a public theming key.

Other changes verified correct: --bpk-radius-sm (0.5rem, matches $bpk-border-radius-sm) and --bpk-text-on-dark (#ffffff in both light/dark themes, matches $bpk-text-on-dark-day) are both real vars with matching values.

@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, primitives.css, and base.default.scss:

CSS var Old SASS fallback Light value Dark value Match
--bpk-radius-sm $bpk-border-radius-sm 0.5rem (theme-agnostic) ✅
--bpk-status-danger-spot $bpk-status-danger-spot-day #e70866 #ff649c ✅
--bpk-text-on-dark $bpk-text-on-dark-day #ffffff #ffffff ✅

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

@xiaogliu

Copy link
Copy Markdown
Contributor

GitHub-wide usage search for the removed theming hook (--bpk-skip-link-background-color / camelCase skipLinkBackgroundColor):

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
  • Skyscanner/ain-bkpk-ark — one hit in a design-spec markdown doc (specs/010-component-requirements/navigation/skip-link.md) describing a token mapping table, not an actual code override

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

Conclusion: safe to merge.

@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 0e260a0 into main Jul 26, 2026
20 of 21 checks passed
@xiaogliu
Vincent Liu (xiaogliu) deleted the migrate/css-vars-skip-link-4814 branch July 26, 2026 16:12
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-skip-link to CSS custom properties

3 participants