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

[CLOV-CSS] Migrate bpk-component-datatable to CSS custom properties - #4936

Merged
Vincent Liu (xiaogliu) merged 4 commits into
mainfrom
migrate/css-vars-datatable-4822
Jul 24, 2026
Merged

Vincent Liu (xiaogliu) merged 4 commits into
mainfrom
migrate/css-vars-datatable-4822

Conversation

@gert-janvercauteren

Copy link
Copy Markdown
Contributor

Summary

  • Migrates bpk-component-datatable SCSS files to use CSS custom properties (var()) with SASS token fallbacks, enabling light/dark mode support
  • All 7 applicable token mappings applied per issue spec
  • 2 gap tokens ($bpk-line-height-xs, $bpk-one-pixel-rem) documented with comments as having no CSS var equivalent
  • Adds VisualTestDark story using BpkDarkExampleWrapper for Percy dark mode snapshots

Token migrations:

SASS token CSS var
$bpk-border-size-sm var(--bpk-border-1)
$bpk-border-size-xl var(--bpk-border-3) via calc() (doubled for accent border)
$bpk-canvas-contrast-day var(--bpk-canvas-contrast)
$bpk-core-accent-day var(--bpk-core-accent)
$bpk-line-day var(--bpk-other-line-default)
$bpk-status-warning-fill-day var(--bpk-surface-warning-fill)
$bpk-text-primary-day var(--bpk-text-primary)

Closes #4822

Test plan

  • All existing tests pass (22/22, 3 suites)
  • SCSS lints cleanly via stylelint
  • CSS compiled output contains var() declarations with SASS fallbacks
  • Dark mode story added for Percy visual regression

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 22, 2026 08:05
@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 component styling toward CSS custom properties with SASS token fallbacks to improve themeability (incl. dark mode), and adds/expands Storybook dark-mode visual coverage.

Changes:

  • Updated SCSS in datatable (and some related components) to use var(--bpk-*) with SASS fallbacks.
  • Added new dark-mode visual regression stories/wrappers for Percy/Storybook.
  • Introduced expanded radio theme attribute exports (including a legacy deprecated key).

Reviewed changes

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

Show a summary per file
File Description
packages/backpack-web/src/bpk-component-tooltip/src/BpkTooltip.stories.tsx Adds a dark-mode visual test story using BpkDarkExampleWrapper.
packages/backpack-web/src/bpk-component-tooltip/src/BpkTooltip.module.scss Migrates tooltip colors to CSS custom properties with SASS fallbacks; documents token gaps.
packages/backpack-web/src/bpk-component-select/src/BpkSelect.stories.tsx Adds a dark-mode visual test story and imports BpkDarkExampleWrapper.
packages/backpack-web/src/bpk-component-select/src/BpkSelect.module.scss Documents token gaps for non-migratable dimension/hairline tokens.
packages/backpack-web/src/bpk-component-radio/src/themeAttributes.tsx Replaces legacy theme attributes export with a new combined list + deprecation notes.
packages/backpack-web/src/bpk-component-radio/src/themeAttributes.ts Removes the previous legacy-only theme attributes file.
packages/backpack-web/src/bpk-component-radio/src/themeAttributes-test.ts Updates tests to cover both legacy and new radio theme attribute exports.
packages/backpack-web/src/bpk-component-radio/src/BpkRadio.stories.tsx Adds a dark-mode story for radio group example.
packages/backpack-web/src/bpk-component-radio/src/BpkRadio.module.scss Migrates radio colors to CSS custom properties and updates checked indicator styling.
packages/backpack-web/src/bpk-component-datatable/src/BpkDataTableHeader.module.scss Migrates sort icon colors to CSS custom properties; documents line-height token gap.
packages/backpack-web/src/bpk-component-datatable/src/BpkDataTable.stories.tsx Adds a dark-mode visual test story using BpkDarkExampleWrapper.
packages/backpack-web/src/bpk-component-datatable/src/BpkDataTable.module.scss Migrates datatable borders/colors to CSS custom properties and replaces accent border mixins with inset box-shadow.

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


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 — this comment refers to a file/section that's no longer part of the current diff (superseded by a later commit on this branch). No action needed here.

Comment on lines +27 to +34
export const allRadioThemeAttributes = [
'privateRadioBgDefaultDisabled',
'privateRadioBgDefaultOn',
'privateRadioBgOnContrastOff',
'privateRadioBgOnContrastOn',
'privateRadioBorder',
'privateRadioBorderDefaultOff',
];

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 file/section that's no longer part of the current diff (superseded by a later commit on this branch). No action needed here.

--bpk-radio-checked-color,
tokens.$bpk-text-link-day
);
background: var(--bpk-text-deprecated-link, tokens.$bpk-text-link-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.

Outdated — this comment refers to a file/section that's no longer part of the current diff (superseded by a later commit on this branch). No action needed here.

Comment on lines +28 to +31
// Datatable accent border = $bpk-border-size-xl * 2 = 6px
box-shadow:
calc(var(--bpk-border-3, tokens.$bpk-border-size-xl) * 2) 0 0 0
var(--bpk-core-accent, tokens.$bpk-core-accent-day) inset;

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.

Not a new risk — the previous borders.bpk-border-left/bpk-border-right mixin (_borders.scss) already implemented these as box-shadow: $offset-x 0 0 0 $color inset; internally. This PR inlines the same box-shadow approach directly (since the shared mixin doesn't support CSS var colors) rather than introducing box-shadow where there wasn't one before. No other box-shadow is used on this element, so there's no clobbering risk beyond what already existed pre-migration.

Comment on lines +207 to +208
const VisualTestDarkExample = () => (
<BpkDarkExampleWrapper>

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 file/section that's no longer part of the current diff (superseded by a later commit on this branch). No action needed here.

@gert-janvercauteren
Gert-Jan Vercauteren (gert-janvercauteren) force-pushed the migrate/css-vars-datatable-4822 branch 2 times, most recently from e630f79 to 69eea60 Compare July 22, 2026 08:32
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@gert-janvercauteren
Gert-Jan Vercauteren (gert-janvercauteren) force-pushed the migrate/css-vars-datatable-4822 branch 2 times, most recently from e630f79 to 907c756 Compare July 22, 2026 08:58
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

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

Token migrations:
- bpk-border-size-sm -> var(--bpk-border-1)
- bpk-border-size-xl -> var(--bpk-border-3) via calc() for doubled accent border
- bpk-canvas-contrast-day -> var(--bpk-canvas-contrast)
- bpk-core-accent-day -> var(--bpk-core-accent)
- bpk-line-day -> var(--bpk-other-line-default)
- bpk-status-warning-fill-day -> var(--bpk-surface-warning-fill)
- bpk-text-primary-day -> var(--bpk-text-primary)

Gap tokens (no CSS var equivalent, documented with comments):
- bpk-line-height-xs: typography line-height
- bpk-one-pixel-rem: hairline border utility

Adds VisualTestDark story using BpkDarkExampleWrapper.

Closes #4822

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-border-3 $bpk-border-size-xl 0.1875rem (no dark override — rem/radius values are theme-agnostic) ✅
--bpk-core-accent $bpk-core-accent-day #0062e3 #84e9ff ✅
--bpk-border-1 $bpk-border-size-sm 0.0625rem (no dark override — rem/radius values are theme-agnostic) ✅
--bpk-other-line-default $bpk-line-day #c1c7cf rgba(255, 255, 255, 0.2) ✅
--bpk-text-primary $bpk-text-primary-day #161616 #ffffff ✅
--bpk-canvas-contrast $bpk-canvas-contrast-day #eff3f8 #010913 ✅
--bpk-surface-warning-fill $bpk-status-warning-fill-day #fff7cf #fbf1bb ✅

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

Was failing the scss/dollar-variable-empty-line-before lint rule in CI.
@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 0ef84f7 into main Jul 24, 2026
15 checks passed
@xiaogliu
Vincent Liu (xiaogliu) deleted the migrate/css-vars-datatable-4822 branch July 24, 2026 09:27
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-datatable to CSS custom properties

3 participants