diff options
| author | 2025-07-23 09:36:44 +0300 | |
|---|---|---|
| committer | 2025-07-23 09:36:44 +0300 | |
| commit | 2920c1f66bb42d7f2acc2972bfffb496d6d73b73 (patch) | |
| tree | 06e0aa3d5e0c273bf007fec020ff47eb336ab496 | |
| parent | 6eb434c8aac7f2b35faeba4b96def30d257eaf04 (diff) | |
| download | web-0.2.4.tar.gz web-0.2.4.zip | |
fix: theme switching & saving0.2.4
| -rw-r--r-- | public/index.html | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/public/index.html b/public/index.html index 6559e1e..ba13e3b 100644 --- a/public/index.html +++ b/public/index.html @@ -413,10 +413,13 @@ <body data-theme="olive" class="font-spectral text-main-dark overflow-hidden bg-interlocked-hexagons bg-repeat bg-pattern-body h-screen flex"> <script> - function switchTheme() { - const currentTheme = document.body.getAttribute('data-theme') - document.body.setAttribute('data-theme', currentTheme == "olive" ? "lettuce" : "olive"); - localStorage.setItem('theme', currentTheme == "olive" ? "lettuce" : "olive"); + function switchTheme(theme) { + if (theme == "" || typeof theme == "undefined") { + const currentTheme = document.body.getAttribute('data-theme'); + theme = currentTheme == "olive" ? "lettuce" : "olive"; + } + localStorage.setItem('theme', theme); + document.body.setAttribute('data-theme', theme); } const savedTheme = localStorage.getItem('theme') || 'olive'; @@ -431,7 +434,7 @@ <i class="fas fa-home nav-icon-custom text-sidebar hover:bg-background-dark cursor-pointer transition-colors duration-300 flex justify-center items-center rounded-lg"></i> <i class="fas fa-search nav-icon-custom text-sidebar hover:bg-background-dark cursor-pointer transition-colors duration-300 flex justify-center items-center rounded-lg"></i> <i class="fas fa-images nav-icon-custom text-sidebar hover:bg-background-dark cursor-pointer transition-colors duration-300 flex justify-center items-center rounded-lg"></i> - <i onclick="switchTheme()" class="fas fa-swatchbook nav-icon-custom text-sidebar hover:bg-background-dark cursor-pointer transition-colors duration-300 flex justify-center items-center rounded-lg"></i> + <i onclick="switchTheme('')" class="fas fa-swatchbook nav-icon-custom text-sidebar hover:bg-background-dark cursor-pointer transition-colors duration-300 flex justify-center items-center rounded-lg"></i> </div> </div> @@ -488,7 +491,7 @@ <i class="fas fa-home nav-icon-custom text-sidebar hover:bg-background-dark cursor-pointer transition-colors duration-300 flex justify-center items-center rounded-lg"></i> <i class="fas fa-search nav-icon-custom text-sidebar hover:bg-background-dark cursor-pointer transition-colors duration-300 flex justify-center items-center rounded-lg"></i> <i class="fas fa-images nav-icon-custom text-sidebar hover:bg-background-dark cursor-pointer transition-colors duration-300 flex justify-center items-center rounded-lg"></i> - <i onclick="switchTheme()" class="fas fa-swatchbook nav-icon-custom text-sidebar hover:bg-background-dark cursor-pointer transition-colors duration-300 flex justify-center items-center rounded-lg"></i> + <i onclick="switchTheme('')" class="fas fa-swatchbook nav-icon-custom text-sidebar hover:bg-background-dark cursor-pointer transition-colors duration-300 flex justify-center items-center rounded-lg"></i> </div> <div class="logo-custom text-background-dark font-patua font-extrabold text-center relative grow z-20"> demo.saya.today |