feat: add reset to system theme control#394
Open
annacodervibe 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.
Adds a way to go back to your OS theme after you've manually switched light/dark mode. Right now once you click the toggle there's no way back except clearing localStorage yourself, so this fixes that.
What I did:
Added a small button next to the existing theme toggle in SiteHeader that only shows up if you've actually overridden the system theme. Click it and it calls resetToSystem, then the button disappears again since there's nothing left to reset.
Didn't touch the existing toggle at all, it works exactly like before.
Added 5 tests for the new button — checking it shows/hides correctly, that it actually calls resetToSystem, and that it doesn't break the old toggle.
Also fixed a localStorage polyfill in the vitest setup file, tests were failing on Node 26 before this, not related to the feature itself but needed it to get a clean run.
Testing:
SiteHeader tests: 29/29 passing
Lint: no new errors
Heads up, npm run build is currently broken on main because of an unrelated isAbortError export issue in useAsync.ts, not something this PR touches
Closes #240