fix: make resource type code blocks theme-aware in dark mode - #377
Conversation
Code samples and the surrounding detail page were painted with fixed light-mode colors, so under the dark theme they rendered near-white text on a near-white background and became unreadable. Resolve every color on the page through a getThemeColors() token set keyed off palette.type, covering code blocks, inline code, the copy button and its clipboard icon, tables, links, and muted text. Light mode keeps its existing values; dark mode uses the matching GitHub dark palette. Fixes #340 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: nicolejms <nicolej@microsoft.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
nithyatsu
left a comment
There was a problem hiding this comment.
Approving — the fix is correct and well-scoped. The <pre> now sets both background and foreground (with <code> inheriting on a transparent background), light-mode values are unchanged so it's a true no-op for the existing theme, and every hardcoded hex in the file now routes through the single getThemeColors token set. Nice catch threading the icon fill through clipboardIconUrl(fill) — the url-encoded SVG would otherwise have stayed dark-gray on dark.
Three non-blocking suggestions inline: hardcoded GitHub hexes vs. Backstage theme tokens, some dead code that could be deleted rather than refactored, and a gap in what the new tests cover. None need to block the merge.
Use semantic Backstage tokens for non-code surfaces so branded and dark themes retain their own paper, text, link, and divider colors. Keep the GitHub palette scoped to code samples and their copy control, and remove the unused code snippet style block. Extend regression coverage to property-description code, copy controls, and custom semantic theme tokens. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Signed-off-by: nicolejms <nicolej@microsoft.com>
Signed-off-by: nicolejms <nicolej@microsoft.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Signed-off-by: nicolejms <nicolej@microsoft.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
b8f5dd1
nithyatsu
left a comment
There was a problem hiding this comment.
Thanks for the follow-up — all three earlier suggestions are addressed. The page now takes its non-code colors from the Backstage theme, the GitHub palette is limited to code blocks and the copy button, the unused style block is gone, and RT-31–34 cover the copy button, code blocks inside property descriptions, and a custom theme. LGTM.
Fixes #340
Problem
On a resource type detail page (for example,
Radius.Core/environments), code samples used a fixed light background but inherited their foreground color from the active theme. In dark mode this produced near-white text on a near-white background.The page also used fixed GitHub colors for surrounding tables, links, borders, and status text, which did not adapt to Backstage branded themes and could provide insufficient contrast on Material-UI
Papersurfaces.Fix
codeSnippetContainerstyle block was removed.Tests
The
ResourceTypeDetailPagesuite now has 34 passing tests, including regression coverage that:Validation completed with
yarn tsc,yarn lint:all,yarn format:check, the focused 34-test suite, and the Impeccable UI detector.