Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 12, 2025

The theme toggle implementation was duplicated across index.html (lines 79-100) and books.html (lines 51-65, 188-191), violating DRY principles.

Changes

  • Created js/theme.js: Extracted theme initialization, toggle function, and icon state management into shared module
  • Updated both HTML files: Removed inline theme code, added <script src="js/theme.js"></script> reference

Result

Net -17 lines across codebase. Theme logic now lives in single source of truth, simplifying future maintenance.

// js/theme.js - now powers both pages
function toggleTheme() {
    const theme = document.documentElement.getAttribute('data-theme');
    const newTheme = theme === 'light' ? 'dark' : 'light';
    document.documentElement.setAttribute('data-theme', newTheme);
    localStorage.setItem('theme', newTheme);
    // Update icon...
}

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Nov 12, 2025
Co-authored-by: arjun7965 <15646612+arjun7965@users.noreply.github.com>
Copilot AI changed the title [WIP] Update dark mode and menu enhancements based on feedback Consolidate duplicate theme toggle code into shared JS module Nov 12, 2025
Copilot AI requested a review from arjun7965 November 12, 2025 05:01
@arjun7965 arjun7965 marked this pull request as ready for review November 12, 2025 05:03
@arjun7965 arjun7965 merged commit 56f0f74 into basic_html Nov 12, 2025
@arjun7965 arjun7965 deleted the copilot/sub-pr-1-another-one branch November 14, 2025 05:59
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.

2 participants