Skip to content

feat: add reset to system theme control#394

Open
annacodervibe wants to merge 1 commit into
AnchorNet-Org:mainfrom
annacodervibe:feat/reset-to-system-theme
Open

feat: add reset to system theme control#394
annacodervibe wants to merge 1 commit into
AnchorNet-Org:mainfrom
annacodervibe:feat/reset-to-system-theme

Conversation

@annacodervibe

Copy link
Copy Markdown

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

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.

Expose a "Reset to system theme" control in the UI for ThemeProvider's unused resetToSystem action

1 participant