33import { useMemo } from 'react' ;
44import Link from 'next/link' ;
55import { problems } from '@/lib/problems' ;
6- import ThemeToggle from '@/components/ThemeToggle ' ;
6+ import { useProgress } from '@/components/ProgressProvider ' ;
77
88export default function Home ( ) {
9+ const { solvedCount } = useProgress ( ) ;
10+
911 // Memoize stats calculation to avoid recalculating on every render
1012 const stats = useMemo (
1113 ( ) => ( {
@@ -22,10 +24,7 @@ export default function Home() {
2224
2325 return (
2426 < div className = "min-h-screen bg-gradient-to-br from-blue-50 via-white to-purple-50 dark:from-gray-900 dark:via-gray-800 dark:to-gray-900" >
25- < div className = "max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-16" >
26- < div className = "flex justify-end mb-8" >
27- < ThemeToggle />
28- </ div >
27+ < div className = "max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12" >
2928 < div className = "text-center mb-16" >
3029 < h1 className = "text-5xl font-bold text-gray-900 dark:text-gray-100 mb-4" >
3130 JavaScript & TypeScript Tricks
@@ -42,30 +41,51 @@ export default function Home() {
4241 </ Link >
4342 </ div >
4443
45- < div className = "grid grid-cols-1 md:grid-cols-4 gap-6 mb-16" >
46- < div className = "bg-white dark:bg-gray-800 rounded-lg shadow-lg p-6 text-center" >
47- < div className = "text-3xl font-bold text-blue-600 dark:text-blue-400 mb-2" >
44+ { /* Progress Card */ }
45+ < div className = "bg-white dark:bg-gray-800 rounded-lg shadow-lg p-6 mb-8 max-w-md mx-auto" >
46+ < div className = "flex items-center justify-between mb-3" >
47+ < span className = "text-gray-600 dark:text-gray-400" > Your Progress</ span >
48+ < span className = "text-2xl font-bold text-green-600 dark:text-green-400" >
49+ { solvedCount } /{ stats . total }
50+ </ span >
51+ </ div >
52+ < div className = "w-full bg-gray-200 dark:bg-gray-700 rounded-full h-3" >
53+ < div
54+ className = "bg-green-500 h-3 rounded-full transition-all duration-500"
55+ style = { { width : `${ ( solvedCount / stats . total ) * 100 } %` } }
56+ />
57+ </ div >
58+ < p className = "text-sm text-gray-500 dark:text-gray-400 mt-2 text-center" >
59+ { solvedCount === 0
60+ ? 'Start solving problems to track your progress!'
61+ : `${ Math . round ( ( solvedCount / stats . total ) * 100 ) } % complete` }
62+ </ p >
63+ </ div >
64+
65+ < div className = "grid grid-cols-2 md:grid-cols-4 gap-4 mb-16" >
66+ < div className = "bg-white dark:bg-gray-800 rounded-lg shadow-lg p-5 text-center" >
67+ < div className = "text-2xl font-bold text-blue-600 dark:text-blue-400 mb-1" >
4868 { stats . total }
4969 </ div >
50- < div className = "text-gray-600 dark:text-gray-400" > Total Problems </ div >
70+ < div className = "text-sm text- gray-600 dark:text-gray-400" > Total</ div >
5171 </ div >
52- < div className = "bg-white dark:bg-gray-800 rounded-lg shadow-lg p-6 text-center" >
53- < div className = "text-3xl font-bold text-green-600 dark:text-green-400 mb-2 " >
72+ < div className = "bg-white dark:bg-gray-800 rounded-lg shadow-lg p-5 text-center" >
73+ < div className = "text-2xl font-bold text-green-600 dark:text-green-400 mb-1 " >
5474 { stats . easy }
5575 </ div >
56- < div className = "text-gray-600 dark:text-gray-400" > Easy</ div >
76+ < div className = "text-sm text- gray-600 dark:text-gray-400" > Easy</ div >
5777 </ div >
58- < div className = "bg-white dark:bg-gray-800 rounded-lg shadow-lg p-6 text-center" >
59- < div className = "text-3xl font-bold text-yellow-600 dark:text-yellow-400 mb-2 " >
78+ < div className = "bg-white dark:bg-gray-800 rounded-lg shadow-lg p-5 text-center" >
79+ < div className = "text-2xl font-bold text-yellow-600 dark:text-yellow-400 mb-1 " >
6080 { stats . medium }
6181 </ div >
62- < div className = "text-gray-600 dark:text-gray-400" > Medium</ div >
82+ < div className = "text-sm text- gray-600 dark:text-gray-400" > Medium</ div >
6383 </ div >
64- < div className = "bg-white dark:bg-gray-800 rounded-lg shadow-lg p-6 text-center" >
65- < div className = "text-3xl font-bold text-red-600 dark:text-red-400 mb-2 " >
84+ < div className = "bg-white dark:bg-gray-800 rounded-lg shadow-lg p-5 text-center" >
85+ < div className = "text-2xl font-bold text-red-600 dark:text-red-400 mb-1 " >
6686 { stats . hard }
6787 </ div >
68- < div className = "text-gray-600 dark:text-gray-400" > Hard</ div >
88+ < div className = "text-sm text- gray-600 dark:text-gray-400" > Hard</ div >
6989 </ div >
7090 </ div >
7191
0 commit comments