fix: Make target background of references accessible in dark mode#5165
fix: Make target background of references accessible in dark mode#5165TimvdLippe wants to merge 2 commits intospeced:mainfrom
Conversation
Reported in our documents that the light blueish background for targeted references is not accessible: Logius-standaarden/publicatie#57 Instead, we can use the same styling as we have for `var(--borderedblock-bg)` (which are used for examples), except make its opacity higher (5% to 30%).
There was a problem hiding this comment.
Pull request overview
Updates the ReSpec stylesheet to improve the visibility/accessibility of the “targeted reference” highlight in dark mode (per Logius-standaarden/publicatie#57).
Changes:
- Add a
prefers-color-scheme: darkoverride for#references :targetbackground styling.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/styles/respec.css.js
Outdated
|
|
||
| @media (prefers-color-scheme: dark) { | ||
| #references :target { | ||
| background: rgb(255 255 255 / 30%); |
There was a problem hiding this comment.
This introduces a hard-coded dark-mode highlight color (rgb(255 255 255 / 30%)), while the PR description indicates the intent is to reuse the same styling as var(--borderedblock-bg) with a higher opacity. To keep theme consistency if the underlying ReSpec variables change, consider basing this highlight on the existing variable (or updating the PR description to match the implementation).
| background: rgb(255 255 255 / 30%); | |
| background: color-mix( | |
| in srgb, | |
| var(--borderedblock-bg) 70%, | |
| transparent | |
| ); |
There was a problem hiding this comment.
I have never used color-mix myself, so I don't know if this is the right syntax.
There was a problem hiding this comment.
@marcoscaceres I don't think your suggestion worked: https://github.com/speced/respec/actions/runs/24139474102/job/70436612808#step:7:21
There was a problem hiding this comment.
I’ll take a look and see if I can get something rough working locally
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
The bug being fixed is real — The problem with the current approach ReSpec defaults to So for any spec using the default Suggested fix Remove the if (colorScheme.content.includes("dark")) {
const darkModeStyleUrl = getStyleUrl("dark.css");
document.head.appendChild(
html`<link
rel="stylesheet"
href="${darkModeStyleUrl.href}"
media="(prefers-color-scheme: dark)"
/>`
);
document.head.appendChild(
html`<style media="(prefers-color-scheme: dark)">
#references :target { background: rgb(255 255 255 / 30%); }
</style>`
);
sub("beforesave", styleMover(darkModeStyleUrl));
}This keeps the fix scoped to specs where dark mode is actually active, avoiding the regression for the default case. |

Reported in our documents that the light blueish background for targeted references is not accessible:
Logius-standaarden/publicatie#57
Instead, we can use the same styling as we have for
var(--borderedblock-bg)(which are used for examples), except make its opacity higher (5% to 30%).