feat: add dark theme and project attribution

This commit is contained in:
2026-12-05 14:52:21 +03:00
parent 7300f13195
commit 3a625c28a5
5 changed files with 187 additions and 5 deletions
+36
View File
@@ -4,6 +4,42 @@
*/
document.addEventListener('DOMContentLoaded', function () {
// Переключение светлой и тёмной темы
const themeToggle = document.getElementById('theme-toggle');
const themeIcon = themeToggle?.querySelector('.theme-icon');
function applyTheme(theme) {
document.documentElement.dataset.theme = theme;
if (themeIcon) {
themeIcon.textContent = theme === 'dark' ? '☀' : '☾';
}
if (themeToggle) {
const label = theme === 'dark'
? 'Переключить на светлую тему'
: 'Переключить на тёмную тему';
themeToggle.setAttribute('aria-label', label);
themeToggle.setAttribute('title', label);
}
}
applyTheme(document.documentElement.dataset.theme || 'light');
themeToggle?.addEventListener('click', function () {
const nextTheme =
document.documentElement.dataset.theme === 'dark' ? 'light' : 'dark';
applyTheme(nextTheme);
try {
localStorage.setItem('phone-store-theme', nextTheme);
} catch (error) {
// Тема останется активной до перезагрузки страницы.
}
});
// Автоматическое скрытие flash-сообщений через 4 секунды
const flashes = document.querySelectorAll('.flash');
flashes.forEach(function (flash) {