|
58 | 58 | </svg> |
59 | 59 | Search |
60 | 60 | </button> |
| 61 | + <button id="mobile-theme-toggle" class="flex items-center gap-2 text-theme-text-secondary dark:text-[#b4b4b4] hover:text-theme-text dark:hover:text-[#ececec] transition-colors py-2 text-left"> |
| 62 | + <!-- Sun icon (visible in dark mode) --> |
| 63 | + <svg class="w-4 h-4 hidden dark:block" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 64 | + <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"></path> |
| 65 | + </svg> |
| 66 | + <!-- Moon icon (visible in light mode) --> |
| 67 | + <svg class="w-4 h-4 block dark:hidden" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 68 | + <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"></path> |
| 69 | + </svg> |
| 70 | + <span class="dark:hidden">Dark Mode</span> |
| 71 | + <span class="hidden dark:inline">Light Mode</span> |
| 72 | + </button> |
61 | 73 | <a href="/getting-started" class="text-theme-text-secondary dark:text-[#b4b4b4] hover:text-theme-text dark:hover:text-[#ececec] transition-colors py-2">Getting Started</a> |
62 | 74 | <a href="/commands" class="text-theme-text-secondary dark:text-[#b4b4b4] hover:text-theme-text dark:hover:text-[#ececec] transition-colors py-2">Commands</a> |
63 | 75 | <a href="/blog" class="text-theme-text-secondary dark:text-[#b4b4b4] hover:text-theme-text dark:hover:text-[#ececec] transition-colors py-2">Blog</a> |
|
78 | 90 | menu?.classList.toggle('hidden'); |
79 | 91 | }); |
80 | 92 |
|
81 | | - // Theme toggle button handler |
| 93 | + // Theme toggle function (shared between desktop and mobile) |
| 94 | + function toggleTheme() { |
| 95 | + const html = document.documentElement; |
| 96 | + if (html.classList.contains('dark')) { |
| 97 | + html.classList.remove('dark'); |
| 98 | + localStorage.setItem('theme', 'light'); |
| 99 | + } else { |
| 100 | + html.classList.add('dark'); |
| 101 | + localStorage.setItem('theme', 'dark'); |
| 102 | + } |
| 103 | + } |
| 104 | + |
| 105 | + // Desktop theme toggle button handler |
82 | 106 | const themeToggle = document.getElementById('theme-toggle'); |
83 | 107 | if (themeToggle) { |
84 | | - themeToggle.addEventListener('click', function() { |
85 | | - const html = document.documentElement; |
86 | | - if (html.classList.contains('dark')) { |
87 | | - html.classList.remove('dark'); |
88 | | - localStorage.setItem('theme', 'light'); |
89 | | - } else { |
90 | | - html.classList.add('dark'); |
91 | | - localStorage.setItem('theme', 'dark'); |
92 | | - } |
93 | | - }); |
| 108 | + themeToggle.addEventListener('click', toggleTheme); |
| 109 | + } |
| 110 | + |
| 111 | + // Mobile theme toggle button handler |
| 112 | + const mobileThemeToggle = document.getElementById('mobile-theme-toggle'); |
| 113 | + if (mobileThemeToggle) { |
| 114 | + mobileThemeToggle.addEventListener('click', toggleTheme); |
94 | 115 | } |
95 | 116 | </script> |
0 commit comments