Repository navigation
[NOJIRA][BpkPrice] Add onContrast variant - #4849
Conversation
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]>
|
Visit https://backpack.github.io/storybook-prs/4849 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 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 newvariantprop onBpkPricewith 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.
| variant: figma.enum("Style", { | ||
| Default: VARIANTS.default, | ||
| onContrast: VARIANTS.onContrast, | ||
| }), |
There was a problem hiding this comment.
🤖: Fixed — changed to OnContrast to match the casing pattern of Default.
There was a problem hiding this comment.
🤖: Fixed — changed to OnContrast to match the casing pattern of Default.
| 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> | ||
| ); |
There was a problem hiding this comment.
🤖: 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.
|
Visit https://backpack.github.io/storybook-prs/4849 to see this build running in a browser. |
…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.)
…tion to changed files" This reverts commit a561d75.
|
Visit https://backpack.github.io/storybook-prs/4849 to see this build running in a browser. |
…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.
|
Visit https://backpack.github.io/storybook-prs/4849 to see this build running in a browser. |
|
Visit https://backpack.github.io/storybook-prs/4849 to see this build running in a browser. |
- 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]>
|
Visit https://backpack.github.io/storybook-prs/4849 to see this build running in a browser. |
…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]>
|
Visit https://backpack.github.io/storybook-prs/4849 to see this build running in a browser. |
|
Visit https://backpack.github.io/storybook-prs/4849 to see this build running in a browser. |
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]>
|
Visit https://backpack.github.io/storybook-prs/4849 to see this build running in a browser. |
…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]>
|
Visit https://backpack.github.io/storybook-prs/4849 to see this build running in a browser. |
|
Visit https://backpack.github.io/storybook-prs/4849 to see this build running in a browser. |
|
Visit https://backpack.github.io/storybook-prs/4849 to see this build running in a browser. |
|
Visit https://backpack.github.io/storybook-prs/4849 to see this build running in a browser. |
|
Visit https://backpack.github.io/storybook-prs/4849 to see this build running in a browser. |
|
Visit https://backpack.github.io/storybook-prs/4849 to see this build running in a browser. |
…jest 30" This reverts commit 997c8b9.
|
Visit https://backpack.github.io/storybook-prs/4849 to see this build running in a browser. |
|
Visit https://backpack.github.io/storybook-prs/4849 to see this build running in a browser. |
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
Visit https://backpack.github.io/storybook-prs/4849 to see this build running in a browser. |
…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]>
|
Visit https://backpack.github.io/storybook-prs/4849 to see this build running in a browser. |
… 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]>
|
Visit https://backpack.github.io/storybook-prs/4849 to see this build running in a browser. |
|
approved the percy since it is what we changed in this PR |
Summary
#4849
Adds an
onContrastvariant toBpkPriceso 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 overrideBpkPrice).A new
variantprop is introduced withdefaultandonContrastvalues:defaultonContrasttext-primarytext-on-darktext-errortext-error(unchanged)text-secondarytext-secondary-on-contrastColour implementation
The Figma spec maps the leading/trailing text to the
Text/Secondary On Contrasttoken (White Alpha 50=rgba(255,255,255,0.5)). This PR introduces a new named colourTEXT_COLORS.textSecondaryOnContrastinBpkText, exposed as the CSS custom property--bpk-text-secondary-on-contrast(themeable). The default value istokens.$bpk-text-disabled-on-dark-day, which is exactlyrgba(255,255,255,0.5)— matching the Figma spec and achieving 5.03:1 contrast oversurface-contrast.Test plan
npx jest packages/backpack-web/src/bpk-component-price— unit tests cover the colour mapping for both variantsnpx jest packages/backpack-web/src/bpk-component-text— unit test added fortextSecondaryOnContrastOnContrast,OnContrastRight,VisualTestOnContrast,Themed(rendered on asurfaceContrastDaybackground)Remember to include the following changes:
[Clover-123][BpkButton] Updating the colourREADME.md(If you have created a new component) — N/A, existing componentREADME.mddefault)