Files
spearhead/_docs/js/site.js
T
dutchie031GitHubex61widutchie032 <dutchie032>
5db860a7a2 Docs rework (#21)
* wip

* docs reworked

* reworked docs

* updated docs and pipeline

---------

Co-authored-by: ex61wi <tim.rorije@ing.com>
Co-authored-by: dutchie032 <dutchie032>
2025-04-25 14:44:19 +02:00

22 lines
898 B
JavaScript

document.addEventListener('DOMContentLoaded', function() {
const themeToggle = document.getElementById('theme-toggle');
const sunIcon = document.getElementById('sun-icon');
const moonIcon = document.getElementById('moon-icon');
if (!themeToggle || !sunIcon || !moonIcon) return;
function setTheme(theme) {
document.documentElement.setAttribute('data-theme', theme);
localStorage.setItem('theme', theme);
sunIcon.style.display = theme === 'light' ? 'block' : 'none';
moonIcon.style.display = theme === 'light' ? 'none' : 'block';
}
themeToggle.addEventListener('click', function() {
const current = document.documentElement.getAttribute('data-theme') || 'dark';
setTheme(current === 'dark' ? 'light' : 'dark');
});
// Initialize
const saved = localStorage.getItem('theme') || 'dark';
setTheme(saved);
});