This commit is contained in:
Gokalp Sen 2024-12-08 17:31:28 +03:00
parent ab2ef8a002
commit 53116c5898
4 changed files with 42 additions and 10 deletions

View file

@ -8,6 +8,7 @@ document.addEventListener('DOMContentLoaded', () => {
if (savedTheme) {
body.classList.toggle('light-theme', savedTheme === 'light');
updateThemeIcon();
updateLogos(savedTheme);
}
themeToggle.addEventListener('click', () => {
@ -21,8 +22,30 @@ document.addEventListener('DOMContentLoaded', () => {
const icon = themeToggle.querySelector('i');
if (body.classList.contains('light-theme')) {
icon.className = 'fas fa-moon';
updateLogos('light');
} else {
icon.className = 'fas fa-sun';
updateLogos('dark');
}
}
function updateLogos(theme) {
const logos = document.querySelectorAll('.logo');
logos.forEach(logo => {
const logoImg = logo.querySelector('img');
if (theme === 'light') {
logoImg.src = logo.dataset.lightLogo;
} else {
logoImg.src = logo.dataset.darkLogo;
}
});
// Update favicon
const favicon = document.getElementById('favicon');
if (theme === 'light') {
favicon.href = favicon.dataset.lightHref;
} else {
favicon.href = favicon.dataset.darkHref;
}
}