Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,17 @@ <h2 class="h3 mb-3">Contribute to this Project</h2>
html.dataset.bsTheme = theme;
localStorage.setItem('theme', theme);
const isLight = theme === 'light';
lightIcon.classList.toggle('d-none', !isLight);
darkIcon.classList.toggle('d-none', isLight);
// Show the icon for the theme that will be applied when the button is clicked.
// If the current theme is light, show the dark (moon) icon and vice-versa.
lightIcon.classList.toggle('d-none', isLight); // hide sun when currently light
darkIcon.classList.toggle('d-none', !isLight); // hide moon when currently dark
// Logos should reflect the current theme (no change)
lightLogo.classList.toggle('d-none', !isLight);
darkLogo.classList.toggle('d-none', isLight);
// Update accessible title/label to indicate the action (the next theme)
const nextTheme = isLight ? 'dark' : 'light';
themeSwitcher.title = `Switch to ${nextTheme.charAt(0).toUpperCase()}${nextTheme.slice(1)} theme`;
themeSwitcher.setAttribute('aria-label', themeSwitcher.title);
}
themeSwitcher.addEventListener('click', () => {
const newTheme = html.dataset.bsTheme === 'dark' ? 'light' : 'dark';
Expand Down