Skip to content

Fix diff2html colors being unreadable in dark mode - #1153

Open
agreen wants to merge 1 commit into
nautobot:developfrom
agreen:fix/diff2html-dark-mode
Open

Fix diff2html colors being unreadable in dark mode#1153
agreen wants to merge 1 commit into
nautobot:developfrom
agreen:fix/diff2html-dark-mode

Conversation

@agreen

@agreen agreen commented Sep 3, 2026

Copy link
Copy Markdown

What's happening

nautobot_golden_config/static/nautobot_golden_config/diff2html-3.4.43/diff2html.min.css ships a single hardcoded light-mode palette (white/pastel-pink/pastel-green table cells, near-black low-opacity text) with no dark variant and no media query. Nautobot itself is fully dark-themed via Bootstrap 5's data-bs-theme="dark" attribute on <html>, but this vendored stylesheet never accounted for that, making the Config Compliance and Config Plan diff views essentially unreadable in dark mode.

Unchanged/context rows happen to look fine only by accident — .d2h-cntx isn't styled by diff2html.min.css at all, so it falls through to Nautobot's own dark table default. Every cell diff2html does style explicitly (deletions, insertions, line-number gutters, the file header bar) overrides that dark default with hardcoded light colors.

Before (Nautobot dark mode, unpatched):

before

After (this PR):

after

What this PR does

Adds a new, separate stylesheet (diff2html-dark-overrides.css) rather than editing the vendored diff2html.min.css directly, so future diff2html version bumps stay clean. Every rule is scoped under Nautobot's existing [data-bs-theme="dark"] attribute selector, so light-mode users are completely unaffected — nothing changes for them. The one shared template that loads diff2html's assets (goldenconfig_detailsmodal.html, used by both the Config Compliance detail view and Config Plan diff rendering) now also loads the new stylesheet.

Testing

Verified live against a real Config Compliance diff on Nautobot 3.2.4 / golden-config 3.0.7, and reproduced standalone in the two screenshots above using the actual vendored diff2html.min.js/.css assets and a real (secret-redacted) config diff.

Fixes #1152

🤖 Generated with Claude Code

nautobot-golden-config vendors diff2html 3.4.43, which ships a single
hardcoded light-mode palette (white/pastel-pink/pastel-green table
cells, near-black low-opacity text) with no dark variant and no media
query. Nautobot itself is fully dark-themed via Bootstrap 5's
data-bs-theme="dark" attribute, but this vendored stylesheet never
accounted for it, making the Config Compliance and Config Plan diff
views essentially unreadable in dark mode.

Adds a new, separate stylesheet (diff2html-dark-overrides.css) rather
than editing the vendored diff2html.min.css directly, so future
diff2html version bumps stay clean. Every rule is scoped under
Nautobot's existing [data-bs-theme="dark"] attribute selector, so
light-mode users are completely unaffected.

Fixes nautobot#1152
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.

Config Compliance/Config Plan diff view (diff2html) is unreadable in dark mode

1 participant