GeezerVison is showing github.com — Implement theme management improvements and enhance UI transitions · aidrivencoder/master-git-github@2ab7607
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/app/globals.css +27-1Lines changed: 27 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 | @tailwind components; | 3 | 3 | @tailwind utilities; | 4 | 4 |
| | 5 | +@layer base { | | 6 | + * { | | 7 | + @apply transition-colors duration-300 ease-in-out; | | 8 | + } | | 9 | +} | | 10 | + | 5 | 11 | html { | 6 | 12 | height: 100%; | 7 | 13 | box-sizing: border-box; | 8 | | -} | | 14 | +} | | 15 | + | | 16 | +/* Ensure smooth transitions for theme changes */ | | 17 | +body, | | 18 | +button, | | 19 | +input, | | 20 | +textarea, | | 21 | +select, | | 22 | +div, | | 23 | +span, | | 24 | +p, | | 25 | +h1, | | 26 | +h2, | | 27 | +h3, | | 28 | +h4, | | 29 | +h5, | | 30 | +h6 { | | 31 | + transition-property: color, background-color, border-color, text-decoration-color, fill, stroke; | | 32 | + transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); | | 33 | + transition-duration: 300ms; | | 34 | +} |
Collapse file Copy file name to clipboardExpand all lines: src/app/tutorials/page.tsx +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -76,4 +76,4 @@ export default function TutorialsPage() { | 76 | 76 | </div> | 77 | 77 | </div> | 78 | 78 | ) | 79 | | -} | | 79 | +} |
Collapse file Copy file name to clipboardExpand all lines: src/components/theme/ThemeProvider.tsx +47-7Lines changed: 47 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -14,22 +14,62 @@ const ThemeContext = createContext<ThemeContextType>({ | 14 | 14 | toggleTheme: () => {} | 15 | 15 | }) | 16 | 16 |
| | 17 | +function getInitialTheme(): Theme { | | 18 | + // Check if we're in the browser | | 19 | + if (typeof window !== 'undefined') { | | 20 | + // First try to get theme from localStorage | | 21 | + const savedTheme = localStorage.getItem('theme') as Theme | | 22 | + if (savedTheme && ['dark', 'light'].includes(savedTheme)) { | | 23 | + return savedTheme | | 24 | + } | | 25 | + | | 26 | + // If no saved theme, check system preference | | 27 | + if (window.matchMedia('(prefers-color-scheme: dark)').matches) { | | 28 | + return 'dark' | | 29 | + } | | 30 | + } | | 31 | + | | 32 | + return 'light' | | 33 | +} | | 34 | + | 17 | 35 | export function ThemeProvider({ children }: { children: React.ReactNode }) { | 18 | | - const [theme, setTheme] = useState<Theme>('light') | | 36 | + const [theme, setTheme] = useState<Theme>(getInitialTheme) | | 37 | + const [mounted, setMounted] = useState(false) | 19 | 38 |
| | 39 | + // Handle initial theme setup | 20 | 40 | useEffect(() => { | 21 | | - const savedTheme = localStorage.getItem('theme') as Theme | 22 | | - if (savedTheme) { | 23 | | - setTheme(savedTheme) | 24 | | - document.documentElement.classList.toggle('dark', savedTheme === 'dark') | | 41 | + setMounted(true) | | 42 | + const initialTheme = getInitialTheme() | | 43 | + setTheme(initialTheme) | | 44 | + document.documentElement.classList.toggle('dark', initialTheme === 'dark') | | 45 | + }, []) | | 46 | + | | 47 | + // Handle system theme changes | | 48 | + useEffect(() => { | | 49 | + const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)') | | 50 | + const handleChange = (e: MediaQueryListEvent) => { | | 51 | + if (!localStorage.getItem('theme')) { | | 52 | + const newTheme = e.matches ? 'dark' : 'light' | | 53 | + setTheme(newTheme) | | 54 | + document.documentElement.classList.toggle('dark', e.matches) | | 55 | + } | 25 | 56 | } | | 57 | + | | 58 | + mediaQuery.addEventListener('change', handleChange) | | 59 | + return () => mediaQuery.removeEventListener('change', handleChange) | 26 | 60 | }, []) | 27 | 61 |
| 28 | 62 | const toggleTheme = () => { | 29 | 63 | const newTheme = theme === 'light' ? 'dark' : 'light' | 30 | 64 | setTheme(newTheme) | 31 | 65 | localStorage.setItem('theme', newTheme) | 32 | | - document.documentElement.classList.toggle('dark') | | 66 | + document.documentElement.classList.remove(theme) | | 67 | + document.documentElement.classList.add(newTheme) | | 68 | + } | | 69 | + | | 70 | + // Prevent flash of incorrect theme | | 71 | + if (!mounted) { | | 72 | + return null | 33 | 73 | } | 34 | 74 |
| 35 | 75 | return ( | @@ -39,4 +79,4 @@ export function ThemeProvider({ children }: { children: React.ReactNode }) { | 39 | 79 | ) | 40 | 80 | } | 41 | 81 |
| 42 | | -export const useTheme = () => useContext(ThemeContext) | | 82 | +export const useTheme = () => useContext(ThemeContext) |
Collapse file Copy file name to clipboardExpand all lines: src/components/theme/ThemeToggle.tsx +10-7Lines changed: 10 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -9,14 +9,17 @@ export function ThemeToggle() { | 9 | 9 | return ( | 10 | 10 | <button | 11 | 11 | onClick={toggleTheme} | 12 | | - className="p-2 rounded-lg bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors" | | 12 | + className="p-2 rounded-lg bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 transition-all duration-300 ease-in-out transform hover:scale-105" | 13 | 13 | aria-label="Toggle theme" | 14 | 14 | > | 15 | | - {theme === 'light' ? ( | 16 | | - <MoonIcon className="w-5 h-5 text-gray-800 dark:text-gray-200" /> | 17 | | - ) : ( | 18 | | - <SunIcon className="w-5 h-5 text-gray-800 dark:text-gray-200" /> | 19 | | - )} | | 15 | + <div className="relative w-5 h-5"> | | 16 | + <div className={`absolute inset-0 transform transition-transform duration-300 ${theme === 'light' ? 'rotate-0 opacity-100' : '-rotate-90 opacity-0'}`}> | | 17 | + <MoonIcon className="w-5 h-5 text-indigo-600 dark:text-indigo-400" /> | | 18 | + </div> | | 19 | + <div className={`absolute inset-0 transform transition-transform duration-300 ${theme === 'dark' ? 'rotate-0 opacity-100' : 'rotate-90 opacity-0'}`}> | | 20 | + <SunIcon className="w-5 h-5 text-amber-500 dark:text-amber-400" /> | | 21 | + </div> | | 22 | + </div> | 20 | 23 | </button> | 21 | 24 | ) | 22 | | -} | | 25 | +} |
Collapse file Copy file name to clipboardExpand all lines: src/components/tutorials/TutorialCard.tsx +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -40,4 +40,4 @@ export function TutorialCard({ tutorial }: TutorialCardProps) { | 40 | 40 | </div> | 41 | 41 | </Link> | 42 | 42 | ) | 43 | | -} | | 43 | +} |
Collapse file Copy file name to clipboardExpand all lines: src/lib/firebase/config.ts +2-7Lines changed: 2 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | import { initializeApp, getApps } from 'firebase/app' | 4 | 4 | import { getAuth, connectAuthEmulator } from 'firebase/auth' | 5 | 5 | import { getFirestore, connectFirestoreEmulator } from 'firebase/firestore' | 6 | | -import { Logger } from '@/lib/utils/logger' | | 6 | +import { Logger } from '../utils/logger' | 7 | 7 |
| 8 | 8 | const firebaseConfig = { | 9 | 9 | apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY, | @@ -25,12 +25,7 @@ function initializeFirebase() { | 25 | 25 | const auth = getAuth(app) | 26 | 26 | const db = getFirestore(app) | 27 | 27 |
| 28 | | - if (process.env.NODE_ENV === 'development') { | 29 | | - if (typeof window !== 'undefined' && window.location.hostname === 'localhost') { | 30 | | - connectAuthEmulator(auth, 'http://localhost:9099') | 31 | | - connectFirestoreEmulator(db, 'localhost', 8080) | 32 | | - } | 33 | | - } | | 28 | + // Removed emulator connections since they're not set up | 34 | 29 |
| 35 | 30 | Logger.info('Firebase initialized successfully', 'Firebase') | 36 | 31 | return { app, auth, db } | |
Collapse file Copy file name to clipboardExpand all lines: src/lib/firebase/services/tutorials.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -99,4 +99,4 @@ export async function getTutorialById(id: string): Promise<Tutorial | null> { | 99 | 99 | Logger.error('Failed to fetch tutorial', 'TutorialService', error) | 100 | 100 | return null | 101 | 101 | } | 102 | | -} | | 102 | +} |
Collapse file Copy file name to clipboardExpand all lines: src/lib/tutorials/git-basics.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -100,4 +100,4 @@ git add . # Stage all changes | 100 | 100 | } | 101 | 101 | } | 102 | 102 | ] | 103 | | -} | | 103 | +} |
|