[CLOV-CSS] Migrate bpk-component-autosuggest to CSS custom properties - #4951
[CLOV-CSS] Migrate bpk-component-autosuggest to CSS custom properties#4951Gert-Jan Vercauteren (gert-janvercauteren) wants to merge 2 commits into
Conversation
|
Visit https://backpack.github.io/storybook-prs/4951 to see this build running in a browser. |
There was a problem hiding this comment.
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-autosuggest styling to CSS custom properties (with SASS fallbacks) and introduces component-scoped theme attributes + dark-mode visual coverage.
Changes:
- Introduce
autosuggestThemeAttributes+ unit test for private autosuggest theme tokens. - Replace SASS token usage with
var(--css-var, sass-fallback)across Autosuggest SCSS (legacy + V2). - Add a dark-mode visual Storybook story for Percy coverage.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/backpack-web/src/bpk-component-autosuggest/src/themeAttributes.tsx | Adds component-scoped theme attribute names for autosuggest private tokens. |
| packages/backpack-web/src/bpk-component-autosuggest/src/themeAttributes-test.tsx | Adds unit test asserting exported theme attribute list. |
| packages/backpack-web/src/bpk-component-autosuggest/src/BpkAutosuggestV2/BpkAutosuggest.stories.tsx | Adds dark visual test story using BpkDarkExampleWrapper. |
| packages/backpack-web/src/bpk-component-autosuggest/src/BpkAutosuggestV2/BpkAutosuggest.module.scss | Migrates V2 styles to CSS custom props with SASS fallbacks. |
| packages/backpack-web/src/bpk-component-autosuggest/src/BpkAutosuggest.module.scss | Migrates legacy styles to CSS custom props with SASS fallbacks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // @ts-expect-error -- bpk-storybook-utils has no type declarations | ||
| import { BpkDarkExampleWrapper } from 'bpk-storybook-utils'; |
| describe('autosuggest component themeAttributes', () => { | ||
| it('should export autosuggestThemeAttributes with all unique private autosuggest tokens', () => { | ||
| expect(autosuggestThemeAttributes).toEqual([ | ||
| 'privateAutosuggestColourBgDefault', | ||
| 'privateAutosuggestColourBgHover', | ||
| 'privateAutosuggestColourBorderDefault', | ||
| 'privateAutosuggestColourTextClose', | ||
| ]); | ||
| }); | ||
| }); |
| export const autosuggestThemeAttributes: string[] = [ | ||
| 'privateAutosuggestColourBgDefault', | ||
| 'privateAutosuggestColourBgHover', | ||
| 'privateAutosuggestColourBorderDefault', | ||
| 'privateAutosuggestColourTextClose', | ||
| ]; |
|
Visit https://backpack.github.io/storybook-prs/4951 to see this build running in a browser. |
|
Token value audit — verified every new CSS var against
Those are slightly difference, will confirm with contributor.
This is not a issue since Backpack doesn't support dark theme now, during Backpack support dark theme, we will do a full regression testing.
Highlight this in this comment #4951 (comment) |
| border-top: var(--bpk-border-1, tokens.$bpk-border-size-sm) solid | ||
| tokens.$bpk-line-day; |
There was a problem hiding this comment.
I think we need replace tokens.$bpk-line-day with --bpk-private-autosuggest-colour-border-default too, wdyt?
| border-top: var(--bpk-border-1, tokens.$bpk-border-size-sm) solid | |
| tokens.$bpk-line-day; | |
| border-top: var(--bpk-border-1, tokens.$bpk-border-size-sm) solid | |
| var(--bpk-private-autosuggest-colour-border-default, tokens.$bpk-line-day); |
| --bpk-private-autosuggest-colour-bg-hover, | ||
| tokens.$bpk-canvas-contrast-day |
There was a problem hiding this comment.
--bpk-private-autosuggest-colour-bg-hover resolves to #f5f7fa (light), but its SASS fallback $bpk-canvas-contrast-day is #eff3f8 — a visibly different (slightly warmer/lighter) shade of grey for the :active/--highlighted hover state, is this expected?
| --bpk-private-autosuggest-colour-border-default, | ||
| tokens.$bpk-surface-highlight-day |
There was a problem hiding this comment.
--bpk-private-autosuggest-colour-border-default resolves to #c1c7cf (light) — which is not same as $bpk-surface-highlight-day (#e0e4e9) as used in the fallback, is this expected?
| background-color: tokens.$bpk-canvas-contrast-day; | ||
| background-color: var( | ||
| --bpk-private-autosuggest-colour-bg-hover, | ||
| tokens.$bpk-canvas-contrast-day |
| background-color: tokens.$bpk-canvas-contrast-day; | ||
| background-color: var( | ||
| --bpk-private-autosuggest-colour-bg-hover, | ||
| tokens.$bpk-canvas-contrast-day |
Closes #4833
Migrates bpk-component-autosuggest to CSS custom properties with SASS fallbacks, and creates themeAttributes.tsx for component-scoped themeable vars.
Changes
var(--css-var, sass-fallback)pattern in both legacy and V2 SCSS files--bpk-private-autosuggest-*component-scoped CSS vars for bg-default, bg-hover, border-default, and text-close--bpk-surface-highlight,--bpk-surface-default,--bpk-text-secondary,--bpk-radius-sm,--bpk-border-1global semantic varsthemeAttributes.tsxwith camelCase keys for all 4 private autosuggest varsthemeAttributes-test.tsxwith unit testsVisualTestDarkstory usingBpkDarkExampleWrapperTokens kept as bare SASS (no CSS var equivalent)
$bpk-box-shadow-lg$bpk-one-pixel-rem$bpk-zindex-autosuggest$bpk-color-white(used as fallback only)$bpk-line-day(no--bpk-line-*semantic var found in theme files)