Skip to content

Add support for high contrast themes to ProgressBar #6431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Aug 14, 2025

Conversation

langermank
Copy link
Contributor

@langermank langermank commented Aug 1, 2025

Closes https://github.com/github/primer/issues/5587

Note: this isn't a foolproof solution but I think covers most contrast issues. Unfortunately the existing API is very open-ended, meaning you can really pass in any color you want for the item. I tried to find a solution that only touches the track bg/border as to not manipulate item colors, but again, not foolproof.

Changelog

New

  • Adds a border and background color to the ProgressBar track to try and add contrast for high contrast themes (default themes are unchanged)
  • Removes old snapshot tests
  • Adds new color VRT tests + general tests to replace snapshots
  • Attempts to correct the insanely open-ended bg prop to always find an emphasis color

Changed

Removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

Copy link

changeset-bot bot commented Aug 1, 2025

🦋 Changeset detected

Latest commit: ebd9480

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Aug 1, 2025
Copy link
Contributor

github-actions bot commented Aug 1, 2025

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

Copy link
Contributor

github-actions bot commented Aug 1, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 90.28 KB (+0.15% 🔺)
packages/react/dist/browser.umd.js 90.44 KB (+0.11% 🔺)

@github-actions github-actions bot requested a deployment to storybook-preview-6431 August 1, 2025 17:49 Abandoned
@github-actions github-actions bot temporarily deployed to storybook-preview-6431 August 1, 2025 18:03 Inactive
@github-actions github-actions bot added integration-tests: failing Changes in this PR cause breaking changes in gh/gh integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm integration-tests: failing Changes in this PR cause breaking changes in gh/gh integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh labels Aug 1, 2025
Copy link
Contributor

👋 Hi, there are new commits since the last successful integration test. We recommend running the integration workflow once more, unless you are sure the new changes do not affect github/github. Thanks!

@github-actions github-actions bot added integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Aug 12, 2025
Copy link
Contributor

👋 Hi, there are new commits since the last successful integration test. We recommend running the integration workflow once more, unless you are sure the new changes do not affect github/github. Thanks!

@primer-integration
Copy link

👋 Hi from github/github! Your integration PR is ready: https://github.com/github/github/pull/396331

@primer-integration
Copy link

🟢 golden-jobs completed with status success.

@langermank langermank marked this pull request as ready for review August 13, 2025 21:57
@Copilot Copilot AI review requested due to automatic review settings August 13, 2025 21:57
@langermank langermank requested review from a team as code owners August 13, 2025 21:57
@langermank langermank requested a review from mperrotti August 13, 2025 21:57
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 support for high contrast themes to the ProgressBar component by implementing better color tokens and improving the existing color API. The main focus is on increasing visual contrast for accessibility without breaking existing functionality.

Key changes:

  • Introduces new CSS tokens for track background and border colors to support high contrast themes
  • Improves the bg prop handling to automatically default to 'emphasis' variants when not specified
  • Replaces snapshot tests with more comprehensive color-focused unit tests and visual regression tests

Reviewed Changes

Copilot reviewed 10 out of 44 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
ProgressBar.module.css Updates CSS to use new color tokens with border outline for high contrast support
ProgressBar.tsx Enhances bg prop logic to default to 'emphasis' variant and fixes prop passing
ProgressBar.test.tsx Removes snapshot test and adds comprehensive bg prop testing
ProgressBar.stories.tsx Updates styling approach from sx to style prop
ProgressBar.features.stories.tsx Replaces single color story with comprehensive AllColors story and updates prop usage
ProgressBar.dev.stories.tsx Removes dev stories file entirely
e2e/components/ProgressBar.test.ts Updates test references to match new story names
.changeset/lovely-vans-burn.md Documents the patch release changes

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@@ -33,6 +33,7 @@ export const Item = forwardRef<HTMLSpanElement, ProgressBarItems>(
'aria-valuetext': ariaValueText,
className,
style,
bg,
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

The bg prop is being destructured and passed to the Box component, but it's also being used in the logic below via rest.bg. This creates a conflict where rest.bg will be undefined since bg was already extracted from rest. Either use bg consistently throughout or don't destructure it from the props.

Suggested change
bg,
bg, // Note: bg is used only for local style computation and is not passed down

Copilot uses AI. Check for mistakes.

<ProgressBar.Item progress={15} aria-label="Application Usage" bg="danger.emphasis" />
<ProgressBar.Item progress={12} aria-label="Music Usage" bg="severe.emphasis" />
<ProgressBar.Item progress={11} aria-label="Music Usage" bg="done.emphasis" />
<ProgressBar.Item progress={8} aria-label="Music Usage" bg="sponsors.emphasis" />
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

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

The bg prop value should be 'sponsor.emphasis' not 'sponsors.emphasis' based on the pattern used in other color variants.

Suggested change
<ProgressBar.Item progress={8} aria-label="Music Usage" bg="sponsors.emphasis" />
<ProgressBar.Item progress={8} aria-label="Music Usage" bg="sponsor.emphasis" />

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@pksjce pksjce left a comment

Choose a reason for hiding this comment

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

Does the bg prop need to be documented?

@langermank
Copy link
Contributor Author

@pksjce that prop is already documented in our docs if that's what you're referring to! I didn't add it here, I just fixed it slightly.

@langermank langermank added this pull request to the merge queue Aug 14, 2025
Merged via the queue into main with commit 0c21301 Aug 14, 2025
43 checks passed
@langermank langermank deleted the progressbar-high-contrast branch August 14, 2025 21:22
@primer primer bot mentioned this pull request Aug 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants