GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Implement theme management improvements and enhance UI transitions · aidrivencoder/master-git-github@2ab7607

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • app
      • globals.css
      • tutorials
        • page.tsx
    • components
      • theme
        • ThemeProvider.tsx
        • ThemeToggle.tsx
      • tutorials
        • TutorialCard.tsx
    • lib
      • firebase
        • config.ts
        • services
          • tutorials.ts
      • tutorials
        • git-basics.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/app/globals.css‎

Copy file name to clipboardExpand all lines: src/app/globals.css
+27-1Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,33 @@
22
@tailwind components;
33
@tailwind utilities;
44

5+
@layer base {
6+
* {
7+
@apply transition-colors duration-300 ease-in-out;
8+
}
9+
}
10+
511
html {
612
height: 100%;
713
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

‎src/app/tutorials/page.tsx‎

Copy file name to clipboardExpand all lines: src/app/tutorials/page.tsx
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ export default function TutorialsPage() {
7676
</div>
7777
</div>
7878
)
79-
}
79+
}
Collapse file

‎src/components/theme/ThemeProvider.tsx‎

Copy file name to clipboardExpand all lines: src/components/theme/ThemeProvider.tsx
+47-7Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,62 @@ const ThemeContext = createContext<ThemeContextType>({
1414
toggleTheme: () => {}
1515
})
1616

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+
1735
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)
1938

39+
// Handle initial theme setup
2040
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+
}
2556
}
57+
58+
mediaQuery.addEventListener('change', handleChange)
59+
return () => mediaQuery.removeEventListener('change', handleChange)
2660
}, [])
2761

2862
const toggleTheme = () => {
2963
const newTheme = theme === 'light' ? 'dark' : 'light'
3064
setTheme(newTheme)
3165
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
3373
}
3474

3575
return (
@@ -39,4 +79,4 @@ export function ThemeProvider({ children }: { children: React.ReactNode }) {
3979
)
4080
}
4181

42-
export const useTheme = () => useContext(ThemeContext)
82+
export const useTheme = () => useContext(ThemeContext)
Collapse file

‎src/components/theme/ThemeToggle.tsx‎

Copy file name to clipboardExpand all lines: src/components/theme/ThemeToggle.tsx
+10-7Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@ export function ThemeToggle() {
99
return (
1010
<button
1111
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"
1313
aria-label="Toggle theme"
1414
>
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>
2023
</button>
2124
)
22-
}
25+
}
Collapse file

‎src/components/tutorials/TutorialCard.tsx‎

Copy file name to clipboardExpand all lines: src/components/tutorials/TutorialCard.tsx
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ export function TutorialCard({ tutorial }: TutorialCardProps) {
4040
</div>
4141
</Link>
4242
)
43-
}
43+
}
Collapse file

‎src/lib/firebase/config.ts‎

Copy file name to clipboardExpand all lines: src/lib/firebase/config.ts
+2-7Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { initializeApp, getApps } from 'firebase/app'
44
import { getAuth, connectAuthEmulator } from 'firebase/auth'
55
import { getFirestore, connectFirestoreEmulator } from 'firebase/firestore'
6-
import { Logger } from '@/lib/utils/logger'
6+
import { Logger } from '../utils/logger'
77

88
const firebaseConfig = {
99
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
@@ -25,12 +25,7 @@ function initializeFirebase() {
2525
const auth = getAuth(app)
2626
const db = getFirestore(app)
2727

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
3429

3530
Logger.info('Firebase initialized successfully', 'Firebase')
3631
return { app, auth, db }
Collapse file

‎src/lib/firebase/services/tutorials.ts‎

Copy file name to clipboardExpand all lines: src/lib/firebase/services/tutorials.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,4 @@ export async function getTutorialById(id: string): Promise<Tutorial | null> {
9999
Logger.error('Failed to fetch tutorial', 'TutorialService', error)
100100
return null
101101
}
102-
}
102+
}
Collapse file

‎src/lib/tutorials/git-basics.ts‎

Copy file name to clipboardExpand all lines: src/lib/tutorials/git-basics.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,4 @@ git add . # Stage all changes
100100
}
101101
}
102102
]
103-
}
103+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.