|
4 | 4 | * Auto-hide on scroll, transparent background, no underlines |
5 | 5 | */ |
6 | 6 | import Logo from '~/components/Logo.astro'; |
7 | | -import ToggleTheme from '~/components/common/ToggleTheme.astro'; |
8 | 7 | import { getHomePermalink, trimSlash } from '~/utils/permalinks'; |
9 | 8 | import { Icon } from 'astro-icon/components'; |
10 | 9 |
|
@@ -155,7 +154,14 @@ const slug = Astro.url.pathname; |
155 | 154 | </ul> |
156 | 155 | </nav> |
157 | 156 | <div class="box-row box-row-btn" style="display: flex; gap: 1rem; align-items: center;"> |
158 | | - <ToggleTheme iconClass="w-6 h-6" class="theme-toggle-btn" /> |
| 157 | + <button |
| 158 | + type="button" |
| 159 | + class="theme-toggle-btn" |
| 160 | + aria-label="Toggle between Dark and Light mode" |
| 161 | + onclick="document.documentElement.classList.toggle('dark'); localStorage.theme = document.documentElement.classList.contains('dark') ? 'dark' : 'light';" |
| 162 | + > |
| 163 | + <Icon name="tabler:sun" class="w-6 h-6" /> |
| 164 | + </button> |
159 | 165 | <div class="link lang-switcher"> |
160 | 166 | <a href={langSwitchLink}> |
161 | 167 | <span>{langSwitchText}</span> |
@@ -253,7 +259,14 @@ const slug = Astro.url.pathname; |
253 | 259 | </nav> |
254 | 260 |
|
255 | 261 | <div class="header-right"> |
256 | | - <ToggleTheme iconClass="w-5 h-5" class="theme-toggle-btn" /> |
| 262 | + <button |
| 263 | + type="button" |
| 264 | + class="theme-toggle-btn" |
| 265 | + aria-label="Toggle between Dark and Light mode" |
| 266 | + onclick="document.documentElement.classList.toggle('dark'); localStorage.theme = document.documentElement.classList.contains('dark') ? 'dark' : 'light';" |
| 267 | + > |
| 268 | + <Icon name="tabler:sun" class="w-5 h-5" /> |
| 269 | + </button> |
257 | 270 | <div class="link lang-switcher"> |
258 | 271 | <a href={langSwitchLink}> |
259 | 272 | <span>{langSwitchText}</span> |
@@ -312,6 +325,8 @@ const slug = Astro.url.pathname; |
312 | 325 | justify-content: space-between; |
313 | 326 | max-width: 1400px; |
314 | 327 | margin: 0 auto; |
| 328 | + position: relative; |
| 329 | + z-index: 1; |
315 | 330 | } |
316 | 331 |
|
317 | 332 | .main-nav-bar .border-bottom { |
@@ -963,23 +978,4 @@ const slug = Astro.url.pathname; |
963 | 978 |
|
964 | 979 | // Initial check |
965 | 980 | updateScrollState(); |
966 | | - |
967 | | - // Theme toggle |
968 | | - const themeToggles = document.querySelectorAll('[data-aw-toggle-color-scheme]'); |
969 | | - themeToggles.forEach(btn => { |
970 | | - btn.addEventListener('click', () => { |
971 | | - const isDark = document.documentElement.classList.toggle('dark'); |
972 | | - localStorage.theme = isDark ? 'dark' : 'light'; |
973 | | - |
974 | | - // Update icon for all theme toggle buttons |
975 | | - const allToggles = document.querySelectorAll('[data-aw-toggle-color-scheme]'); |
976 | | - allToggles.forEach(toggle => { |
977 | | - const icon = toggle.querySelector('svg'); |
978 | | - if (icon) { |
979 | | - // Toggle between sun and moon icons by swapping the icon |
980 | | - // This is a simple approach - the icon will update on next page load |
981 | | - } |
982 | | - }); |
983 | | - }); |
984 | | - }); |
985 | 981 | </script> |
0 commit comments