diff options
| author | Danilo M. <danix@danix.xyz> | 2026-04-22 12:43:22 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-04-22 12:43:22 +0200 |
| commit | 5b476f8905f411768e23cb01d577a60e5a5fd725 (patch) | |
| tree | 0a08cc83d809dbea714f52826e822501ee7c0165 /themes/danix-xyz-hacker/assets/js/theme-toggle.js | |
| parent | 082e9246ffe453031894d32d3cee9d5d1bf2b67a (diff) | |
| download | danixxyz-5b476f8905f411768e23cb01d577a60e5a5fd725.tar.gz danixxyz-5b476f8905f411768e23cb01d577a60e5a5fd725.zip | |
chore: extract theme into git submodule (danix2-hugo-theme)
Diffstat (limited to 'themes/danix-xyz-hacker/assets/js/theme-toggle.js')
| -rw-r--r-- | themes/danix-xyz-hacker/assets/js/theme-toggle.js | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/themes/danix-xyz-hacker/assets/js/theme-toggle.js b/themes/danix-xyz-hacker/assets/js/theme-toggle.js deleted file mode 100644 index bb95b2a..0000000 --- a/themes/danix-xyz-hacker/assets/js/theme-toggle.js +++ /dev/null @@ -1,53 +0,0 @@ -document.addEventListener('DOMContentLoaded', function() { - const themeToggle = document.getElementById('theme-toggle'); - const sunIcon = document.getElementById('theme-icon-sun'); - const moonIcon = document.getElementById('theme-icon-moon'); - - function updateThemeIcon() { - const isDark = document.documentElement.classList.contains('theme-dark'); - if (sunIcon && moonIcon) { - if (isDark) { - sunIcon.style.display = 'block'; - moonIcon.style.display = 'none'; - } else { - sunIcon.style.display = 'none'; - moonIcon.style.display = 'block'; - } - } - } - - // Update icon on initial load - if (sunIcon && moonIcon) { - updateThemeIcon(); - } - - if (!themeToggle) { - return; - } - - themeToggle.addEventListener('click', function(e) { - e.preventDefault(); - - // Get current theme from html element - const htmlElement = document.documentElement; - const isDark = htmlElement.classList.contains('theme-dark'); - const newTheme = isDark ? 'light' : 'dark'; - - // Remove both theme classes - htmlElement.classList.remove('theme-light', 'theme-dark'); - - // Add the new theme class - htmlElement.classList.add(`theme-${newTheme}`); - - // Persist to localStorage - localStorage.setItem('theme', newTheme); - - // Update icon display - updateThemeIcon(); - - // Update Feather Icons if available - if (window.feather) { - window.feather.replace(); - } - }); -}); |
