diff --git a/_includes/layouts/base.njk b/_includes/layouts/base.njk index 235eb2d..a95c5de 100644 --- a/_includes/layouts/base.njk +++ b/_includes/layouts/base.njk @@ -212,6 +212,19 @@ Interactions + {# Mobile theme toggle #} + @@ -281,13 +294,20 @@ }); } - // Theme toggle functionality + // Theme toggle functionality (desktop and mobile) + function toggleTheme() { + const isDark = document.documentElement.classList.toggle('dark'); + localStorage.setItem('theme', isDark ? 'dark' : 'light'); + } + const themeToggle = document.getElementById('theme-toggle'); if (themeToggle) { - themeToggle.addEventListener('click', () => { - const isDark = document.documentElement.classList.toggle('dark'); - localStorage.setItem('theme', isDark ? 'dark' : 'light'); - }); + themeToggle.addEventListener('click', toggleTheme); + } + + const mobileThemeToggle = document.querySelector('.mobile-theme-toggle'); + if (mobileThemeToggle) { + mobileThemeToggle.addEventListener('click', toggleTheme); } // Link prefetching on mouseover/touchstart for faster navigation diff --git a/css/tailwind.css b/css/tailwind.css index 3505ecd..663aba0 100644 --- a/css/tailwind.css +++ b/css/tailwind.css @@ -150,6 +150,35 @@ @apply hidden; } + /* Mobile theme toggle */ + .mobile-theme-toggle { + @apply flex items-center justify-between w-full px-4 py-3 text-surface-600 dark:text-surface-400 hover:bg-surface-100 dark:hover:bg-surface-800 hover:text-primary-600 dark:hover:text-primary-400 transition-colors bg-transparent border-none text-base text-left cursor-pointer border-t border-surface-200 dark:border-surface-700; + } + + .mobile-theme-toggle .theme-label { + @apply font-normal; + } + + .mobile-theme-toggle .theme-icons { + @apply flex items-center; + } + + .mobile-theme-toggle .sun-icon { + @apply hidden; + } + + .mobile-theme-toggle .moon-icon { + @apply block; + } + + .dark .mobile-theme-toggle .sun-icon { + @apply block; + } + + .dark .mobile-theme-toggle .moon-icon { + @apply hidden; + } + /* Container */ .container { @apply max-w-5xl mx-auto px-4;