Skip to content

Conversation

Supremeyh
Copy link
Contributor

@Supremeyh Supremeyh commented Aug 4, 2025

Context

BpkText’s lack of default or token-based color support leads to widespread manual style overrides (average 14.88% per major page), undermining VDL consistency and reducing design system reliability and maintainability across Skyscanner products.

We have added color prop so that consumer can change BpkText color by config but not override before, and want to constraint for BpkText color prop only allowed BPK text color tokens.

Changes

  • Add BpkText color prop with leverage css classname, replaces inline style-based color prop with CSS class-based approach using predefined tokens
  • Exports TEXT_COLORS constants and TextColor type for consumer use
  • Updates tests and documentation to reflect the new color prop implementation

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)
  • 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
  • Storybook examples created/updated
  • For breaking changes or deprecating components/properties, migration guides added to the description of the PR. If the guide has large changes, consider creating a new Markdown page inside the component's docs folder and link it here

@Supremeyh Supremeyh added the minor Non breaking change label Aug 4, 2025
@Supremeyh Supremeyh self-assigned this Aug 4, 2025
@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3900 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

skyscanner-backpack-bot bot commented Aug 4, 2025

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 cbe7bc0

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3900 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3900 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3900 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3900 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3900 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3900 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3900 to see this build running in a browser.

Comment on lines 30 to 33
'text-primary-dark': tokens.$bpk-text-primary-dark-color,
'text-primary-light': tokens.$bpk-text-primary-light-color,
'text-secondary-dark': tokens.$bpk-text-secondary-dark-color,
'text-secondary-light': tokens.$bpk-text-secondary-light-color,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to check these.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3900 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3900 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3900 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3900 to see this build running in a browser.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3900 to see this build running in a browser.

@Supremeyh Supremeyh marked this pull request as ready for review August 5, 2025 06:49
@Copilot Copilot AI review requested due to automatic review settings August 5, 2025 06:49
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a color prop to the BpkText component that constrains color values to predefined design system tokens instead of allowing arbitrary color strings. This change improves VDL consistency by preventing manual style overrides and ensures color values align with the design system.

Key changes:

  • Replaces inline style-based color prop with CSS class-based approach using predefined tokens
  • Exports TEXT_COLORS constants and TextColor type for consumer use
  • Updates tests and documentation to reflect the new color prop implementation

Reviewed Changes

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

Show a summary per file
File Description
BpkText.tsx Adds TEXT_COLORS constant, updates color prop type, and switches from inline styles to CSS classes
BpkText.module.scss Defines SCSS map for text colors and generates CSS classes for each color token
BpkText-test.tsx Updates tests to validate new color prop behavior with CSS classes instead of inline styles
index.ts Exports TEXT_COLORS constant for external use
README.md Updates documentation to show usage with TEXT_COLORS tokens
examples.module.scss Adds example styles for demonstrating color inheritance
examples.js Updates examples to use new TEXT_COLORS API
Comments suppressed due to low confidence (2)

packages/bpk-component-text/src/BpkText-test.tsx:115

  • The test for invalid color value should verify that no color class is applied when an invalid value is passed, but it only checks the base classes. Consider adding an assertion that no color-related CSS class is present.
      const { getByText } = render(<BpkText color="invalid">{text}</BpkText>);

packages/bpk-component-text/src/BpkText-test.tsx:140

  • Using window.getComputedStyle in tests can be unreliable in test environments. Consider using a more explicit assertion or mocking the computed styles to ensure consistent test behavior across different environments.
      expect(window.getComputedStyle(getByText(text)).color).toBe(

Comment on lines 163 to 166
@each $color-name, $color-value in $text-colors {
&--#{$color-name} {
color: $color-value;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Sass loops - Sass: @each to generate the classnames

@@ -58,6 +58,21 @@ export const TEXT_STYLES = {
editorial3: 'editorial-3',
} as const;

export const TEXT_COLORS = {
Copy link
Contributor Author

@Supremeyh Supremeyh Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TEXT_COLORS is maintained for color prop tokens list we support with minimum set VDL consistency.

@skyscanner-backpack-bot
Copy link

Visit https://backpack.github.io/storybook-prs/3900 to see this build running in a browser.

@Supremeyh Supremeyh merged commit 525d7bf into main Aug 6, 2025
10 checks passed
@Supremeyh Supremeyh deleted the ez/clover-532_backpacktext_color branch August 6, 2025 07:37
gert-janvercauteren added a commit that referenced this pull request Aug 26, 2025
* main:
  Bump actions/download-artifact in the artifacts-actions group (#3907)
  Bump actions/checkout from 4 to 5 (#3913)
  Fix closeText style of BpkModal in dark mode (#3919)
  Bump the babel group across 1 directory with 5 updates (#3917)
  Bump @babel/runtime in the npm_and_yarn group across 1 directory (#3884)
  Bump actions/cache from 4.2.3 to 4.2.4 (#3905)
  Bump webpack from 5.99.8 to 5.101.2 (#3916)
  QUAR-1046 Fix CTA Button Alignment, Logo Sizing, and Logo Vertical Alignment in Inset Banner (#3912)
  chore: removed duplicate aria-label (#3911)
  [CAPY-1594][BpkNavigationTabGroup/BpkBubble] Create and integrate 'new' bubble tooltip in navigation tab bar (#3909)
  [CLOV-381][BpkBreakpoint] update bpk breakpoint readme (#3910)
  [CYB-3904][BpkGraphicPromo] Render wrapper as semantic anchor tag to improve SEO (#3904)
  [CLOVER-532][BpkText] Add BpkText color prop with leverage css classname (#3900)
  fix: A11y and icon issue for inset banner sponsored (#3901)

# Conflicts:
#	packages/bpk-component-text/README.md
#	packages/bpk-component-text/src/BpkText-test.tsx
#	packages/bpk-component-text/src/BpkText.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Non breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants