5db860a7a2
* wip * docs reworked * reworked docs * updated docs and pipeline --------- Co-authored-by: ex61wi <tim.rorije@ing.com> Co-authored-by: dutchie032 <dutchie032>
22 lines
898 B
JavaScript
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);
|
|
}); |