Skip to content

Add dark mode with theme toggle and persisted preference - #8

Open
GodPuffin wants to merge 1 commit into
mainfrom
cursor/add-dark-mode-6931
Open

Add dark mode with theme toggle and persisted preference#8
GodPuffin wants to merge 1 commit into
mainfrom
cursor/add-dark-mode-6931

Conversation

@GodPuffin

Copy link
Copy Markdown
Owner

Introduce a header toggle that switches between light and dark themes, respects the system color-scheme preference on first visit, and saves the choice in localStorage. Dark styles are applied via CSS overrides so all existing templates are covered without per-page edits.

Introduce a header toggle that switches between light and dark themes,
respects the system color-scheme preference on first visit, and saves
the choice in localStorage. Dark styles are applied via CSS overrides
so all existing templates are covered without per-page edits.

Co-authored-by: Marcus Lee <GodPuffin@users.noreply.github.com>
@haunt-sh

haunt-sh Bot commented Jun 17, 2026

Copy link
Copy Markdown

Haunt checked this pull request.

Check Status Details Updated (UTC)
Code review 🟡 1 finding Review · 4/5 Looks good Aug 26, 2026 4:50am
User test ✅ 5 of 6 passed Report · ▶ Demo Aug 25, 2026 5:21pm

The change has one confirmed minor issue in src/internal/assets/templates/layout.html:7: selecting light mode does not force a light color scheme, so native controls may remain dark. This is a limited visual consistency bug rather than a critical functional problem, so the change is generally safe to merge after a quick review or minor fix.

Code-review findings digest
Severity Location Finding
🟡 minor src/internal/assets/templates/layout.html:7 The light preference does not force a light color scheme, so native controls can remain dark after selecting light mode
6 scenarios checked
ID Scenario Result Notes
DM-01 Toggle dark mode on home page ✅ pass Clicked the header theme button; the live page switched to dark styling with light text and the moon icon visible.
DM-02 Dark mode persists after reload ✅ pass Reloaded after enabling dark mode; the page remained dark and local theme state remained dark.
DM-03 System dark preference respected on first visit ✅ pass Cleared stored theme, emulated a dark system preference, and reloaded; the page automatically loaded dark with the moon icon visible.
DM-04 Toggle back to light and persist ✅ pass Switched from dark to light and reloaded; the page remained light with the sun icon visible.
DM-05 Dark mode styling on forms and tables ⏭️ skip The public registration form was reached and its inputs showed dark backgrounds with light text. No authenticated table/list data was available in the reachable session, so table borders and badges could not be verified.
DM-06 Toggle icon reflects current theme ✅ pass Verified the sun icon is visible in light mode and the moon icon is visible after switching to dark mode, with the opposite icon hidden each time.

e78a70f

Comment thread src/internal/assets/templates/layout.html
setTheme(root.classList.contains("dark") ? "light" : "dark");
});
})();
</script>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 setTheme() calls syncIcons() with no null check on sunIcon/moonIcon either.

minor · correctness

var prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
if (stored === "dark" || (!stored && prefersDark)) {
document.documentElement.classList.add("dark");
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Inline <script> reads localStorage before any DOM/body paint but writes to <html> only; the FOUC brief flash remains benign but the script lacks a try/catch around localStorage.

minor · correctness

background-color: #1f2937 !important;
}

.dark .bg-gray-50 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 bg-gray-50 and bg-gray-100 map to the same dark color, and so do bg-gray-200/bg-gray-300 and hover:bg-gray-200/hover:bg-gray-400 — duplication that should be merged.

minor · simplification

color: #d1d5db !important;
}

.dark .text-gray-500 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ .dark .text-gray-500 and .dark .text-gray-400 collapse to identical #9ca3af — the -400 rule is dead/duplicate.

nit · simplification

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="color-scheme" content="light dark" />

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 The light preference does not force a light color scheme, so native controls can remain dark after selecting light mode

minor · correctness

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.

2 participants