feat: add theme change button - #119
Open
kingazm wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📄 Pull Request Description
🧩 What was changed?
Added a light/dark theme toggle button to the top bar, placed directly to the left of the existing contrast slider button.
💡 Why was it changed?
Previously, dark mode was controlled entirely by the OS/browser prefers-color-scheme setting with
no way to override it from within the app. Users who want dark mode on a light-mode system (or
vice versa) had no way to switch. This brings the theme control in-app, consistent with how the
contrast and language settings already work. In addition, this was also project's supervisor suggestion.
⚙️ How was it implemented?
window.matchMedia('(prefers-color-scheme: dark)') so first-time visitors get the theme
automatically.
on every change.
applying the dark class from storage before React hydrates. No flash of wrong theme on hard
reload.
the default @media (prefers-color-scheme) variant to a class-based one, so the button actually
controls all dark: utility classes.
Moon icon in light mode and Sun icon in dark mode (lucide-react, already a project dependency).
the OS media query. On first load, the inline script mirrors the system preference, so existing
users will see no change, but if localStorage ever has a stale value it will override the system
setting.
that relied on automatic OS-driven dark mode will now only switch when the user explicitly
toggles or when the inline script fires on load. This is intentional but is a global behaviour
change.
✅ Checklist