add night theme

This commit is contained in:
2024-12-04 20:14:02 +03:00
parent 67459900f0
commit 5895c700db
3 changed files with 40 additions and 28 deletions

View File

@@ -317,12 +317,18 @@ window.onload = function () {
});
};
// Кнопка и иконка
const themeToggle = document.getElementById('theme-toggle');
const themeIcon = document.getElementById('theme-icon');
themeToggle.addEventListener('click', () => {
document.body.classList.toggle('dark-theme');
});
const buttons = document.querySelectorAll('.btn');
// editExisted.addEventListener('click', (e) => {
// textRUEl.innerHTML = `<span onClick="copyToClipboard('${e.target.value}')" class="btn btn-light" id="template-ru-text">RU</span>`
// })
// Обработчик клика
themeToggle.addEventListener('click', () => {
document.body.classList.toggle('dark-theme'); // Переключаем класс для темы
// Меняем иконку
if (document.body.classList.contains('dark-theme')) {
themeIcon.classList.replace('fa-sun', 'fa-moon');
} else {
themeIcon.classList.replace('fa-moon', 'fa-sun');
}
});