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

[NOJIRA][BpkPrice] Add onContrast variant - #4849

Merged
GC Zhu (gc-skyscanner) merged 22 commits into
mainfrom
feature/bpk-price-on-contrast
Jul 15, 2026
Merged

GC Zhu (gc-skyscanner) merged 22 commits into
mainfrom
feature/bpk-price-on-contrast

Conversation

@kerrie-wu

@kerrie-wu kerrie-wu commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

#4849

Adds an onContrast variant to BpkPrice so a price can be placed on a dark / contrast surface without consumers overriding the component's internal text colours (unblocks GlobalComponents, which currently has to override BpkPrice).

A new variant prop is introduced with default and onContrast values:

Element default onContrast
Price text-primary text-on-dark
Previous / strikethrough price text-error text-error (unchanged)
Leading / trailing text text-secondary text-secondary-on-contrast

Colour implementation

The Figma spec maps the leading/trailing text to the Text/Secondary On Contrast token (White Alpha 50 = rgba(255,255,255,0.5)). This PR introduces a new named colour TEXT_COLORS.textSecondaryOnContrast in BpkText, exposed as the CSS custom property --bpk-text-secondary-on-contrast (themeable). The default value is tokens.$bpk-text-disabled-on-dark-day, which is exactly rgba(255,255,255,0.5) — matching the Figma spec and achieving 5.03:1 contrast over surface-contrast.

Test plan

  • npx jest packages/backpack-web/src/bpk-component-price — unit tests cover the colour mapping for both variants
  • npx jest packages/backpack-web/src/bpk-component-text — unit test added for textSecondaryOnContrast
  • New Storybook stories: OnContrast, OnContrastRight, VisualTestOnContrast, Themed (rendered on a surfaceContrastDay background)

Remember to include the following changes:

  • Ensure the PR title includes the name of the component you are changing so it's clear in the release notes for consumers of the changes in the version e.g [Clover-123][BpkButton] Updating the colour
  • README.md (If you have created a new component) — N/A, existing component
  • Component README.md
  • Tests
  • Accessibility tests
    • The following checks were performed:
      • Ability to navigate using a keyboard only
      • Zoom functionality (Deque University explanation):
        • The page SHOULD be functional AND readable when only the text is magnified to 200% of its initial size
        • Pages must reflow as zoom increases up to 400% so that content continues to be presented in only one column i.e. Content MUST NOT require scrolling in two directions (both vertically and horizontally)
      • Ability to navigate using a screen reader only
    • Note: this variant is a colour-only change (no markup/behaviour change), verified for WCAG contrast (5.03:1). The manual a11y checks above have not been re-run as the DOM structure is unchanged.
  • Storybook examples created/updated
  • For breaking changes or deprecating components/properties, migration guides added to the description of the PR — N/A, additive & non-breaking (new optional prop defaulting to default)

Adds a `variant` prop with `default` and `onContrast` values so BpkPrice
can be placed on dark / contrast surfaces without consumers overriding the
internal text colours.

On contrast: price uses text-on-dark, previous price keeps text-error, and
leading/trailing text uses text-disabled-on-dark (rgba(255,255,255,0.5) —
the value of the Text/Secondary On Contrast design token, meeting WCAG at
5.03:1). This is interim until foundations ships a dedicated
text-secondary-on-contrast token.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 3, 2026 09:54
@kerrie-wu kerrie-wu added the minor Non breaking change label Jul 3, 2026
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@skyscanner-backpack-bot

skyscanner-backpack-bot Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor
Warnings
⚠️

Package source files (e.g. packages/package-name/src/Component.js) were updated, but snapshots weren't. Have you checked that the tests still pass?

Browser support

If this is a visual change, make sure you've tested it in multiple browsers.

Generated by 🚫 dangerJS against 7f0ca33

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 no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.

Adds an onContrast variant to BpkPrice so it can be used on dark/contrast surfaces while keeping internal colour tokens controlled by the component.

Changes:

  • Introduces VARIANTS (default, onContrast) and a new variant prop on BpkPrice with colour mapping for price/secondary text.
  • Adds Storybook stories and Figma Code Connect controls/examples for the new variant.
  • Exports VARIANTS, adds README usage guidance, and adds Jest coverage for the new variant colour mapping.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/backpack-web/src/bpk-component-price/src/common-types.ts Adds VARIANTS constant for BpkPrice variant options.
packages/backpack-web/src/bpk-component-price/src/BpkPrice.tsx Adds variant prop and maps colours based on default vs onContrast.
packages/backpack-web/src/bpk-component-price/src/BpkPrice.stories.tsx Adds dark-surface stories for onContrast rendering and visual regression coverage.
packages/backpack-web/src/bpk-component-price/src/BpkPrice.figma.tsx Exposes variant via Figma Code Connect enum and passes it into example.
packages/backpack-web/src/bpk-component-price/src/BpkPrice-test.tsx Adds unit tests asserting classnames for both variants and elements.
packages/backpack-web/src/bpk-component-price/index.ts Re-exports VARIANTS for consumers.
packages/backpack-web/src/bpk-component-price/README.md Documents how to use the new onContrast variant.

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

Comment on lines +40 to +43
variant: figma.enum("Style", {
Default: VARIANTS.default,
onContrast: VARIANTS.onContrast,
}),

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.

🤖: Fixed — changed to OnContrast to match the casing pattern of Default.

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.

🤖: Fixed — changed to OnContrast to match the casing pattern of Default.

Comment on lines +370 to +401
const OnContrastExample = () => (
<BpkDarkExampleWrapper
padded
style={{ backgroundColor: surfaceContrastDay }}
>
<BpkPrice
size={SIZES.large}
previousPrice="£2,033"
leadingText="App only deal"
price="£1,830"
trailingText="per day"
variant={VARIANTS.onContrast}
/>
</BpkDarkExampleWrapper>
);

const OnContrastRightExample = () => (
<BpkDarkExampleWrapper
padded
style={{ backgroundColor: surfaceContrastDay }}
>
<BpkPrice
size={SIZES.large}
previousPrice="£2,033"
leadingText="App only deal"
price="£1,830"
trailingText="per day"
align={ALIGNS.right}
variant={VARIANTS.onContrast}
/>
</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.

🤖: Each story is intentionally self-contained — keeping the wrapper inline makes stories independently readable in Storybook without needing to trace a helper. The duplication is minimal (3 occurrences, same file) and these are unlikely to drift independently. Happy to revisit if the pattern grows.

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

…changed files

- Pin npx to @figma/[email protected] (last known stable, main succeeded 2026-05-19)
  Versions 1.4.6+ contain a regression causing TypeError: Cannot read properties
  of undefined (reading 'split') when processing BpkIcon.figma.tsx
- On PR runs, compute changed .figma.tsx files via git diff and pass them via
  --file flags, avoiding pre-existing broken files (BpkTicket, BpkCode, etc.)
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

…nent set

Old node 10885:8553 was a variant, not a top-level component set.
Updated to 19850:20116 which is the correct component set node.
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

- Add clarifying comment on textDisabledOnDark usage for secondary on-contrast text
- Fix onContrast → OnContrast casing in Figma enum to match Default convention

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

…icket

BpkCode and BpkCodeBlock are utility components with no Figma equivalent.
BpkTicket is deprecated in Figma and superseded by BpkCard.

Confirmed with designer Adam Wilson 2026-07-14.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

Introduces a new TEXT_COLORS.textSecondaryOnContrast that maps to
--bpk-text-secondary-on-contrast with textDisabledOnDark as fallback.
No dedicated token exists in bpk-foundations-web; this approach keeps
the semantic intent clear while allowing CSS custom property override.

Uses the new color in BpkPrice for secondary text on contrast surfaces,
replacing the previous textDisabledOnDark workaround.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

…se pattern

Replace inline-style <p> labels with BpkText headings, extract ThemedExample
component, and rename export from ThemeVerification to Themed.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

…rast class

The onContrast leading/trailing text now uses the textSecondaryOnContrast
token (rendered as bpk-text--text-secondary-on-contrast), but the test still
asserted the old bpk-text--text-disabled-on-dark class — the real cause of the
CI test failure.

Also revert the BpkSegmentedControlV2 test change: the act() warning is only
stderr noise and does not fail jest 30 on its own, so main's existing afterEach
suppression is sufficient and our console.error mock was unnecessary.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@skyscanner-backpack-bot

Copy link
Copy Markdown
Contributor

… compat

React 19 resolves types for bpk-storybook-utils and bpk-theming imports,
making @ts-expect-error directives unused (TS2578). Switch to @ts-ignore
which is silently skipped when no error exists.

Co-Authored-By: Claude Sonnet 4.6 <[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.

LGTM

@gc-skyscanner

Copy link
Copy Markdown
Contributor

approved the percy since it is what we changed in this PR

@gc-skyscanner
GC Zhu (gc-skyscanner) merged commit 5818ccb into main Jul 15, 2026
16 checks passed
@gc-skyscanner
GC Zhu (gc-skyscanner) deleted the feature/bpk-price-on-contrast branch July 15, 2026 09:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

minor Non breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants