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

[CLOV-CSS] Migrate bpk-component-horizontal-nav to CSS custom properties - #4947

Merged
Vincent Liu (xiaogliu) merged 2 commits into
mainfrom
migrate/css-vars-horizontal-nav-4823
Jul 26, 2026
Merged

Vincent Liu (xiaogliu) merged 2 commits into
mainfrom
migrate/css-vars-horizontal-nav-4823

Conversation

@gert-janvercauteren

Copy link
Copy Markdown
Contributor

Closes #4823

Migrates bpk-component-horizontal-nav SCSS modules to CSS custom properties with SASS fallbacks for light/dark mode support.

Changes

BpkHorizontalNav.module.scss

  • Underline borders: tokens.$bpk-line-day → var(--bpk-other-line-default, ...)

BpkHorizontalNavItem.module.scss

  • Default link text: tokens.$bpk-text-secondary-day → var(--bpk-text-secondary, ...)
  • Hover border: tokens.$bpk-surface-highlight-day → var(--bpk-surface-highlight, ...)
  • Active border: tokens.$bpk-line-day → var(--bpk-other-line-default, ...)
  • Disabled text: tokens.$bpk-text-disabled-day → var(--bpk-text-disabled, ...)
  • Selected border + text: old --bpk-horizontal-nav-bar-selected-color hook → var(--bpk-text-deprecated-link, ...)
  • Light variant text + border: tokens.$bpk-text-on-dark-day → var(--bpk-text-on-dark, ...)
  • Removes all bpk-themeable-property mixin usage in favour of plain var()

BpkHorizontalNav.stories.module.scss

  • Custom scroll color: tokens.$bpk-status-success-fill-day → var(--bpk-surface-success-fill, ...)

BpkHorizontalNav.stories.js

  • Adds VisualTestDark story using BpkDarkExampleWrapper tagged dark-mode-compatible

- Replace static SASS tokens with CSS var() + SASS fallbacks in SCSS modules
- BpkHorizontalNav.module.scss: underline borders use --bpk-other-line-default
- BpkHorizontalNavItem.module.scss:
  - default link: color uses --bpk-text-secondary
  - hover border uses --bpk-surface-highlight
  - active border uses --bpk-other-line-default
  - disabled color uses --bpk-text-disabled
  - selected border and color use --bpk-text-deprecated-link
  - light link: color and border use --bpk-text-on-dark
  - light disabled: --bpk-text-disabled
  - Removes bpk-themeable-property mixin usage
- BpkHorizontalNav.stories.module.scss: custom-color uses --bpk-surface-success-fill
- Add VisualTestDark story using BpkDarkExampleWrapper

Closes #4823

Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 22, 2026 08:30
@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-horizontal-nav styling from SCSS theme mixins to CSS custom properties (with SASS token fallbacks) and adds a dark-mode visual regression story.

Changes:

  • Replaces bpk-themeable-property usage with var(--token, sassFallback) across horizontal nav styles.
  • Updates underline/link/border colors to new CSS custom property tokens, including light variant and disabled/selected states.
  • Adds VisualTestDark Storybook story wrapped in BpkDarkExampleWrapper and tagged dark-mode-compatible.

Reviewed changes

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

File Description
packages/backpack-web/src/bpk-component-horizontal-nav/src/BpkHorizontalNavItem.module.scss Switches nav item colors/borders to CSS custom properties with token fallbacks; removes previous themeable-property hooks.
packages/backpack-web/src/bpk-component-horizontal-nav/src/BpkHorizontalNav.module.scss Updates underline border color to use CSS custom property --bpk-other-line-default with fallback.
packages/backpack-web/src/bpk-component-horizontal-nav/src/BpkHorizontalNav.stories.module.scss Migrates custom scroll indicator color to CSS custom property with fallback.
packages/backpack-web/src/bpk-component-horizontal-nav/src/BpkHorizontalNav.stories.js Adds a new dark visual test story and associated Storybook parameters/tags.

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

Comment on lines +51 to 67
color: var(--bpk-text-secondary, tokens.$bpk-text-secondary-day);

@include utils.bpk-hover {
color: var(--bpk-text-secondary, tokens.$bpk-text-secondary-day);

@include borders.bpk-border-bottom-xl(
tokens.$bpk-surface-highlight-day
);
@include utils.bpk-themeable-property(
color,
--bpk-horizontal-nav-link-hover-color,
tokens.$bpk-text-secondary-day
var(--bpk-surface-highlight, tokens.$bpk-surface-highlight-day)
);
}

&:active {
@include borders.bpk-border-bottom-xl(tokens.$bpk-line-day);
@include utils.bpk-themeable-property(
color,
--bpk-horizontal-nav-link-active-color,
tokens.$bpk-text-secondary-day
color: var(--bpk-text-secondary, tokens.$bpk-text-secondary-day);

@include borders.bpk-border-bottom-xl(
var(--bpk-other-line-default, tokens.$bpk-line-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 values themselves are correct (verified in the token-value audit comment on this PR: --bpk-text-secondary matches $bpk-text-secondary-day, --bpk-surface-highlight matches $bpk-surface-highlight-day exactly, light and dark). The tradeoff is real though: any consumer currently overriding --bpk-horizontal-nav-link-color/-hover-color/-active-color via BpkThemeProvider will silently lose that override, since these component-scoped hooks are being replaced by global semantic vars rather than kept as legacy fallbacks. This same pattern recurs across the whole CSS-vars migration series (switch, radio, star-rating, progress, skip-link, 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 +80 to 87
color: var(--bpk-text-deprecated-link, tokens.$bpk-text-link-day);

@include borders.bpk-border-bottom-xl(
var(
--bpk-horizontal-nav-bar-selected-color,
--bpk-text-deprecated-link,
tokens.$bpk-horizontal-nav-bar-selected-color
)
);

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 above — this is the same intentional pattern (component hook -> global var), not a value bug. --bpk-text-deprecated-link is confirmed to resolve to the same colour (#0062e3 light / #84e9ff dark) as both the old $bpk-text-link-day and $bpk-horizontal-nav-bar-selected-color tokens, so there's no visual regression — but consumers overriding --bpk-horizontal-nav-bar-selected-color directly will lose that override. Flagging for design-system-owner sign-off alongside the other comment on this file.

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

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

CSS var Old SASS fallback Light value Dark value Match
--bpk-other-line-default $bpk-line-day #c1c7cf rgba(255,255,255,0.2) ✅
--bpk-surface-success-fill $bpk-status-success-fill-day #d4fff2 #b1ffe7 ✅
--bpk-text-secondary $bpk-text-secondary-day #626971 #bdc4cb ✅
--bpk-surface-highlight $bpk-surface-highlight-day #e0e4e9 #243346 ✅
--bpk-text-disabled $bpk-text-disabled-day rgba(0,0,0,0.2) rgba(255,255,255,0.2) ✅
--bpk-text-deprecated-link $bpk-text-link-day / $bpk-horizontal-nav-bar-selected-color #0062e3 #84e9ff ✅ (both old tokens resolve to the same rgb(0,98,227))
--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 hooks (--bpk-horizontal-nav-link-color, -hover-color, -active-color, -selected-color, --bpk-horizontal-nav-bar-selected-color / camelCase horizontalNavLinkColor etc.):

Searched github.com (via gh search code, which covers public + private repos this account has access to) for both the raw CSS var names and the camelCase themeAttributes keys consumers would pass to BpkThemeProvider.

Results — no real consumer usage found. All hits are within:

  • Skyscanner/backpack itself (the source of the hook/type definitions)
  • Skyscanner/ain-backpack — a private "Harness engineering test drive" clone of Backpack, not a production consumer
  • Skyscanner/backpack-cli — hit was a token-documentation generator file (horizontal-nav.doc.ts), not a theming override

No product repo anywhere in the org (or public GitHub) uses these specific theme attribute keys via BpkThemeProvider.

Conclusion: safe to merge. This is a breaking API change in theory, but zero real consumers rely on it today.

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

3 participants