feat: wire up light/dark mode toggle end-to-end (darkMode class, them…#1090
feat: wire up light/dark mode toggle end-to-end (darkMode class, them…#1090shravanithouta108 wants to merge 2 commits into
Conversation
…e-light vars, color token mapping)
utksh1
left a comment
There was a problem hiding this comment.
Requesting changes. This only adds theme CSS/Tailwind tokens; it does not wire the actual toggle behavior end-to-end or add tests proving the theme class is set/persisted. Please implement the full toggle flow or narrow the title/scope to token preparation.
|
Hi @utksh1 — added explicit test coverage proving the end-to-end toggle behavior: applies the dark class to document root and removes theme-light and applies the theme-light class to document root and removes dark directly assert on document.documentElement.classList, which is exactly what was broken before this fix (the class was toggling correctly in the DOM, but Tailwind/CSS weren't responding to it — now fixed and verified). All 10 tests in ThemeToggle.test.tsx pass. This closes the gap between "button click logic works" and "visual theme actually changes." |
Description
Wired the light/dark mode toggle end-to-end. The toggle button,
ThemeContext, and localStorage persistence logic were already implemented, but the visual theme switch never actually took effect because:tailwind.config.jswas missingdarkMode: 'class'— Tailwind was ignoring thedarkclass added to the HTML element byThemeContext.theme-lightCSS variable overrides were missing fromindex.css— switching to light mode had no visual effectbg-secondary,bg-primary,bg-tertiarycolor classes used throughout the app were not mapped to the CSS variable tokens in the Tailwind configAfter these fixes, clicking the toggle now switches the entire dashboard (sidebar, main content, header, text) between dark and light themes, the icon updates correctly (sun ↔ moon), and the selection persists across page refresh via localStorage.
Before / After:
Closes #954
Type of Change
How Has This Been Tested?
python -m backend.secuscan.main) and frontend (npm run dev) locallygetComputedStyle(document.documentElement).getPropertyValue('--bg-primary')returns the correct value for each themeChecklist
Drag and drop your two screenshots (dark mode and light mode) directly into the GitHub PR description box where you see
paste-image-link-here— GitHub will upload them and auto-insert the correct image markdown.