Skip to content

default background and foreground for inline code in dark mode #13182

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gordonwoodhull
Copy link
Contributor

@gordonwoodhull gordonwoodhull commented Aug 4, 2025

This afternoon I wanted to see if Claude Code could help me navigate our intimidating mountain of SCSS in order to fix

Claude on this task

I fed it _bootstrap-rules.scss and _bootstrap-variables.scss and sass/brand.ts and told it how we currently can fix the color using brand.yml but we'd prefer to have a decent default.

Good ✅

  • Immediately found the correct place to make the change.
  • Always pleasant and enthusiastic.
  • Defensive SCSS code.

Bad ❌

  • The initial suggestions did not work.
  • It took many iterations and exploration to find the right change, and I still basically had to figure it out for myself.
  • Overly-defensive SCSS code?

Conclusions 📊

  • Claude was extremely helpful to get started.
  • I probably didn't save any time overall.
  • I probably learned slightly less!

(This comment was written entirely by human.)

Contents of this PR

Before After
image image

This minimal and defensive change changes inline code to use the same default background and foreground colors as the block code, when in dark mode.

Fixes #8568

It leaves the inline code foreground color defaulted to purple in light mode, which seems to be intentional. In dark mode, it uses #code-block-bg-color which exists in that mode.

I think the fix is correct and safe but it may be more convoluted than we want.

The problem is, $code-bg, which controls the inline code background color, has a bad default for dark mode of $gray-100 (in _bootstrap-variables.scss) but the way to calculate the correct color for dark mode is not known until _bootstrap-rules.scss.

I couldn't !default it, or set it outright, so Claude suggested this kludge of checking if $code-bg has its default setting. 😛

I have tested this manually

  • with light dark flatly/darkly and cosmo/solar
    • both with and without brand.typography.monospace-inline.background-color (which is the current workaround for the original bug).
  • with no theme
    • with and without brand
      No warnings.

Posting draft for CI; will look at Playwright tests next.

Visual design considerations

This is the minimal change, but

  • As shown in the after screenshot, visually the inline code background appears darker than the code block background, because it's smaller. So perhaps it should be lighter!
  • There is no reason not to choose a more interesting default color for the dark mode foreground color for inline code, especially as our default in light mode is purple. (Surfing git blame, it took a while to settle on this color.)

fixes #8568

this minimal and defensive change (found and iterated with Claude)
changes inline code to use the same default background and foreground colors
as the block code, when in dark mode.
@posit-snyk-bot
Copy link
Collaborator

posit-snyk-bot commented Aug 4, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dark mode fixed width font on 1.4.559 has difficult-to-read background color
2 participants