Primer branding: use color tokens in dark theme instead of hardcoded hex - #277
Merged
Merged
Conversation
- Route every dark-mode CSS custom property through the same Primer CSS variable (--color-*) used in light mode, keeping the hardcoded hex as a fallback value only. primer_brand_review flagged hardcoded-hex as an off-brand pattern; light mode already did this correctly, dark mode did not. - Update the a11y contrast test regex to extract the hex fallback from var(--token, #hex) as well as bare hex values, since dark-theme vars now read var(--color-fg-default, #e6edf3) instead of #e6edf3. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pelikhan
marked this pull request as ready for review
September 12, 2026 16:02
pelikhan
deleted the
primer-branding-dark-mode-tokens-da08c57a6d01faff
branch
September 12, 2026 16:02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Color
[data-color-mode="dark"]) CSS custom properties insrc/styles/style.csswere hardcoded hex values (e.g.--text-primary: #e6edf3;), while the equivalent light-theme properties correctly resolved through Primer CSS variables (e.g.--text-primary: var(--color-fg-default, #24292f);). Every dark-mode token now routes through the matching--color-*Primer variable, with the original hex kept only as the fallback value, so both themes stay in sync with Primer's token system instead of drifting independently.Deliberately not changed
primer_brand_reviewalso flagged hardcoded pixel sizes (e.g.3px,24px) andborder-radius: 50%circular shapes (avatars, step dots, spinners). These are small circular UI affordances, not pill-shaped buttons/CTAs — the "pill-button" brand rule targets marketing CTAs, and reworking every icon/dot radius and spacing constant into brand size tokens would be a much larger, riskier change than this PR's scope. Left as a known follow-up.@primer/react-brandpage), so left untouched per the "presentational only, don't restructure" instruction.Brand guidance cited (from the
primer-brandMCP server)primer_brand_reviewonsrc/styles/style.css:hardcoded-hex: Hardcoded hex colors found (#ffffff, #f6f8fa, #24292f, #57606a). Use Primer Brand color tokens.primer_brand_tokensconfirmed the canonical Primer color-token pattern (--brand-color-canvas-default,--brand-color-text-default, etc.) of resolving through a semantic variable rather than a raw hex.Testing
test/a11y.test.js'sdarkVar()helper regex to extract the hex fallback fromvar(--token, #hex)in addition to bare#hex, since the dark-theme block now emits token-wrapped values.npm test— all 327 tests pass.npm run build— succeeds (verified the Vite build itself compiles cleanly; theprebuildvendor-fetch step requires npm registry access, which isn't available in this sandbox — confirmed this failure is pre-existing and unrelated to these changes by reproducing it onmainbefore my edits).Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
registry.npmjs.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.