some progress

This commit is contained in:
2025-08-07 23:01:58 +03:00
parent e8d7e6a1c4
commit e351803db2
14 changed files with 971 additions and 226 deletions
+38
View File
@@ -0,0 +1,38 @@
document.addEventListener('DOMContentLoaded', function() {
const themeSwitcher = document.getElementById('themeSwitcher');
const themeIcon = themeSwitcher.querySelector('.iconify');
const themeText = themeSwitcher.querySelector('.theme-text');
// Check for saved theme preference or use system preference
const savedTheme = localStorage.getItem('theme');
const systemPrefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
if (savedTheme === 'dark' || (!savedTheme && systemPrefersDark)) {
document.body.classList.add('dark-mode');
themeIcon.setAttribute('data-icon', 'mdi-weather-night');
themeText.textContent = 'Dark Mode';
} else {
document.body.classList.add('light-mode');
themeIcon.setAttribute('data-icon', 'mdi-weather-sunny');
themeText.textContent = 'Light Mode';
}
// Theme switcher click handler
themeSwitcher.addEventListener('click', function() {
if (document.body.classList.contains('dark-mode')) {
// Switch to light mode
document.body.classList.remove('dark-mode');
document.body.classList.add('light-mode');
themeIcon.setAttribute('data-icon', 'mdi-weather-sunny');
themeText.textContent = 'Light Mode';
localStorage.setItem('theme', 'light');
} else {
// Switch to dark mode
document.body.classList.remove('light-mode');
document.body.classList.add('dark-mode');
themeIcon.setAttribute('data-icon', 'mdi-weather-night');
themeText.textContent = 'Dark Mode';
localStorage.setItem('theme', 'dark');
}
});
});