Skip to content

Implement responsive dark mode theme controller with localStorage persistence (#437)#454

Open
Aryan0819 wants to merge 4 commits into
Eswaramuthu:mainfrom
Aryan0819:main
Open

Implement responsive dark mode theme controller with localStorage persistence (#437)#454
Aryan0819 wants to merge 4 commits into
Eswaramuthu:mainfrom
Aryan0819:main

Conversation

@Aryan0819
Copy link
Copy Markdown

Which issue does this PR close?

Rationale for this change

The student achievements dashboard currently only supports a bright, light-themed user interface. This can cause eye strain during extended nighttime viewing sessions. Additionally, the existing "#mode-toggle" button is present in the HTML markup but lacks the backend or frontend logic to actively modify system theme parameters. Implementing a client-side theme controller solves this by offering a persistent theme preference without breaking existing layout code.

What changes are included in this PR?

  • styles.css: Added base CSS variable mapping configurations under :root for the default dark theme parameters and explicit class variable overrides under body.light-mode. Introduced a global smooth transition rule for background-color, color, and border-color fields to prevent harsh snapping flashes when themes toggle.
  • script.js: Implemented a client-side theme manager utilizing an IIFE execution flow to eliminate layout screen-flash on DOM startup. Added accessibility support via ARIA attributes and active cross-tab theme state syncing using the Window storage event listener.

Are these changes tested?

Yes, manually verified locally across multiple browser environments:

  1. Persistence Test: Verified that selecting a theme preference accurately binds to the HTML5 localStorage state repository and holds its exact parameters across manual hard page-reloads.
  2. System Preference Test: Verified that clearing local cache data successfully triggers fallback listeners to seamlessly match the operating system level color rules (prefers-color-scheme).
  3. Cross-Tab Synchronization Test: Confirmed that opening up multiple dashboard tabs simultaneously and changing the theme state in one instantly updates all alternative tab environments via window storage observers.

Are there any user-facing changes?

Yes. Users will now see a fully interactive theme control button in the top corner layout. Clicking this button dynamically adjusts the entire interface theme spectrum fluidly between light and dark visual aesthetics.

Aryan0819 added 3 commits May 23, 2026 18:25
Add dark mode styles and smooth transition effects.
Added CSS variables for dark and light themes.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 23, 2026

@Aryan0819 is attempting to deploy a commit to the 007's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown

Thanks for creating a PR for your Issue! ☺️

We'll review it as soon as possible.
In the meantime, please double-check the file changes and ensure that all commits are accurate.

If there are any unresolved review comments, feel free to resolve them. 🙌🏼

Comment thread static/styles.css
Comment thread static/styles.css
@entelligence-ai-pr-reviews
Copy link
Copy Markdown
Contributor


Confidence Score: 2/5 - Changes Needed

Not safe to merge — this PR introduces duplicate :root and body.light-mode CSS blocks in static/styles.css that silently overwrite the existing dark-theme and light-theme variable definitions with conflicting values, which will cause unpredictable theming behavior at runtime. The PR's goal of implementing a responsive dark mode controller with localStorage persistence is a worthwhile feature, but the CSS conflicts mean the theme variables that the controller reads and applies will be unreliable depending on cascade order. Both duplicate blocks must be merged into their respective existing declarations before this is safe to ship.

Key Findings:

  • The duplicate :root block in static/styles.css redefines the same four CSS custom properties (likely --bg-color, --text-color, etc.) already declared at line 3, with different values — whichever block appears last in the file wins, meaning the original intended dark-theme defaults are silently discarded.
  • The duplicate body.light-mode block overwrites the same variables already defined at lines 14–23 with conflicting values, so the light-mode theme applied by the JavaScript controller will not match the intended design — this is a functional bug, not a cosmetic one.
  • Because the theme controller uses localStorage persistence, users who have already saved a theme preference will see the wrong colors on page load until the CSS is corrected and they clear their stored value, making this a potential regression for returning users.
Files requiring special attention
  • static/styles.css

Changed allowTaint option to false for html2canvas.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 23, 2026

Deployment failed with the following error:

The provided GitHub repository does not contain the requested branch or commit reference. Please ensure the repository is not empty.

@entelligence-ai-pr-reviews
Copy link
Copy Markdown
Contributor

EntelligenceAI PR Summary

This PR enforces strict cross-origin image handling in the AchievementExporter class by explicitly disabling the allowTaint option in both html2canvas calls.

  • Set allowTaint: false in both html2canvas invocations in static/js/achievement-export.js
  • Aligns allowTaint behavior with the existing useCORS: true configuration
  • Prevents cross-origin images from tainting the canvas context

Confidence Score: 5/5 - Safe to Merge

Safe to merge — this PR makes a targeted, low-risk hardening change to achievement-export.js by explicitly setting allowTaint: false in both html2canvas invocations, aligning the configuration with the existing useCORS: true option. The change is purely defensive: allowTaint defaults to false in html2canvas, so this is a clarifying explicit declaration rather than a behavioral change, meaning no regression risk is introduced. No review comments were generated and full file coverage was achieved, giving high confidence in the correctness of this minimal diff.

Key Findings:

  • Setting allowTaint: false alongside useCORS: true is the correct and recommended html2canvas configuration for handling cross-origin images securely — these two options are complementary and the PR correctly applies them consistently across both canvas render calls.
  • Because allowTaint defaults to false in html2canvas, this change is idempotent in behavior but improves code clarity and guards against any future library version that might change the default — a net positive with zero downside risk.
  • The PR title/summary mismatch (title references 'dark mode theme controller' while the actual change is about CORS/canvas) is a documentation oddity worth noting, but it does not affect the code correctness or safety of the diff itself.
Files requiring special attention
  • static/js/achievement-export.js

@Aryan0819
Copy link
Copy Markdown
Author

Please review this

@Aryan0819
Copy link
Copy Markdown
Author

@pratyushjha06 @mahi-8758 please review it

@mahi-8758
Copy link
Copy Markdown
Contributor

@Aryan0819 okk

Copy link
Copy Markdown
Contributor

@mahi-8758 mahi-8758 left a comment

Choose a reason for hiding this comment

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

This PR is reviewed and has no conflicts.

@Aryan0819
Copy link
Copy Markdown
Author

@mahi-8758 can you please merge this pr and add required lables so that i got my gssoc points

@Aryan0819
Copy link
Copy Markdown
Author

Aryan0819 commented May 31, 2026

@anika-p @devmdave please merge this pr and add the required lables

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.

Adding a Dark Mode Toggle to Student Dashboard

2 participants