Skip to content

feat: wire up light/dark mode toggle end-to-end (darkMode class, them…#1090

Open
shravanithouta108 wants to merge 2 commits into
utksh1:mainfrom
shravanithouta108:fix/theme-toggle-v2
Open

feat: wire up light/dark mode toggle end-to-end (darkMode class, them…#1090
shravanithouta108 wants to merge 2 commits into
utksh1:mainfrom
shravanithouta108:fix/theme-toggle-v2

Conversation

@shravanithouta108

Copy link
Copy Markdown
Contributor

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:

  1. tailwind.config.js was missing darkMode: 'class' — Tailwind was ignoring the dark class added to the HTML element by ThemeContext
  2. .theme-light CSS variable overrides were missing from index.css — switching to light mode had no visual effect
  3. bg-secondary, bg-primary, bg-tertiary color classes used throughout the app were not mapped to the CSS variable tokens in the Tailwind config

After 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:

Dark mode Light mode
dark theme-light

Closes #954

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

  1. Started backend (python -m backend.secuscan.main) and frontend (npm run dev) locally
  2. Opened the dashboard and clicked the theme toggle button in the sidebar
  3. Confirmed visually that the entire UI (background, text, sidebar) switches between dark and light themes
  4. Confirmed the toggle icon updates from sun to moon and the tooltip text updates ("Switch to light mode" ↔ "Switch to dark mode")
  5. Verified in browser DevTools console that getComputedStyle(document.documentElement).getPropertyValue('--bg-primary') returns the correct value for each theme
  6. Refreshed the page and confirmed the selected theme persists (read from localStorage)

Checklist

  • My code follows the code style of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.

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.

@utksh1 utksh1 added level:intermediate 35 pts difficulty label for moderate contributor PRs type:feature Feature work category bonus label area:frontend Frontend React/UI work labels Jun 20, 2026

@utksh1 utksh1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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.

@shravanithouta108

Copy link
Copy Markdown
Contributor Author

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."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:frontend Frontend React/UI work level:intermediate 35 pts difficulty label for moderate contributor PRs type:feature Feature work category bonus label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Fix light/dark mode button

2 participants