diff --git a/index.html b/index.html index 6d2862a7..70b26a2d 100644 --- a/index.html +++ b/index.html @@ -16,6 +16,19 @@ } })(); +
diff --git a/src/App.tsx b/src/App.tsx index 51b9d660..0781ec6f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -4,8 +4,14 @@ import router from '@/routes'; const App = () => { useEffect(() => { - const unsubscribe = router.subscribe(() => { - window.scrollTo(0, 0); + let lastPathname = window.location.pathname; + + const unsubscribe = router.subscribe((state) => { + // Only scroll to top on pathname changes, not on query/hash changes + if (state.location.pathname !== lastPathname) { + window.scrollTo(0, 0); + lastPathname = state.location.pathname; + } }); const handleRedirect = () => { const redirectPath = sessionStorage.getItem('gh_redirect'); diff --git a/src/components/DeveloperTestimonials.tsx b/src/components/DeveloperTestimonials.tsx index 9d8c1cab..256d3621 100644 --- a/src/components/DeveloperTestimonials.tsx +++ b/src/components/DeveloperTestimonials.tsx @@ -49,12 +49,12 @@ const ReviewCard = ({ /> {/* Feedback Text */} - - {body} - +

{body}

+ {/* User Info */}
diff --git a/src/components/shared/DarkModeToggle.tsx b/src/components/shared/DarkModeToggle.tsx index 9d7d4f22..657f45ee 100644 --- a/src/components/shared/DarkModeToggle.tsx +++ b/src/components/shared/DarkModeToggle.tsx @@ -1,19 +1,37 @@ -import { useState } from 'react'; +import { useState, useEffect } from 'react'; import { Moon, Sun } from 'lucide-react'; const DarkModeToggle = () => { + // Initialize from the class that was already set in index.html const [isDarkMode, setIsDarkMode] = useState(() => { - const theme = localStorage.getItem('theme'); - const isDark = theme === 'dark'; - if (isDark) { - document.documentElement.classList.add('dark'); - } else { - document.documentElement.classList.remove('dark'); - } - return isDark; + const storedTheme = localStorage.getItem('theme'); + const prefersDark = window.matchMedia( + '(prefers-color-scheme: dark)', + ).matches; + return storedTheme === 'dark' || (!storedTheme && prefersDark); }); const [isHovered, setIsHovered] = useState(false); + useEffect(() => { + // Listen for system theme changes (only if no manual preference is set) + const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)'); + const handleThemeChange = (e: MediaQueryListEvent) => { + // Only update if user hasn't set a manual preference + if (!localStorage.getItem('theme')) { + const shouldBeDark = e.matches; + if (shouldBeDark) { + document.documentElement.classList.add('dark'); + } else { + document.documentElement.classList.remove('dark'); + } + setIsDarkMode(shouldBeDark); + } + }; + + mediaQuery.addEventListener('change', handleThemeChange); + return () => mediaQuery.removeEventListener('change', handleThemeChange); + }, []); + const toggleDarkMode = () => { if (isDarkMode) { document.documentElement.classList.remove('dark'); @@ -32,115 +50,117 @@ const DarkModeToggle = () => { const translateX = isDarkMode ? trackWidth - thumbWidth - padding : padding; return ( - + + + + + + + + +
); }; diff --git a/src/pages/News/NewsPage.tsx b/src/pages/News/NewsPage.tsx index eeb6179d..40679cd6 100644 --- a/src/pages/News/NewsPage.tsx +++ b/src/pages/News/NewsPage.tsx @@ -272,15 +272,17 @@ const NewsPage: React.FC = () => { >
-

+

NEWS

@@ -400,11 +402,15 @@ const NewsPage: React.FC = () => { whileTap={{ scale: 0.95 }} > {cat} - {activeCategory === cat && ( - - {(postsByCategory[cat] || []).length} - - )} + + {(postsByCategory[cat] || []).length} + ))}