@@ -4,6 +4,7 @@ import { useTranslations } from 'next-intl';
44import { Link } from '@/i18n/routing' ;
55import { Badge } from '@/components/ui/badge' ;
66import { FileText , Clock } from 'lucide-react' ;
7+ import { categoryTabStyles } from '@/data/categoryStyles' ;
78
89interface QuizCardProps {
910 quiz : {
@@ -14,6 +15,7 @@ interface QuizCardProps {
1415 questionsCount : number ;
1516 timeLimitSeconds : number | null ;
1617 categoryName : string | null ;
18+ categorySlug : string | null ;
1719 } ;
1820 userProgress ?: {
1921 bestScore : number ;
@@ -24,16 +26,33 @@ interface QuizCardProps {
2426
2527export function QuizCard ( { quiz, userProgress } : QuizCardProps ) {
2628 const t = useTranslations ( 'quiz.card' ) ;
29+ const slug = quiz . categorySlug as keyof typeof categoryTabStyles | null ;
30+ const style = slug && categoryTabStyles [ slug ] ? categoryTabStyles [ slug ] : null ;
31+ const accentColor = style ?. accent ?? '#3B82F6' ; // fallback blue
32+
2733 const percentage =
2834 userProgress && userProgress . totalQuestions > 0
2935 ? Math . round ( ( userProgress . bestScore / userProgress . totalQuestions ) * 100 )
3036 : 0 ;
3137
3238 return (
33- < div className = "flex flex-col rounded-xl border border-gray-200 dark:border-neutral-800 bg-white dark:bg-neutral-900 p-5 shadow-sm hover:shadow-md transition-shadow" >
39+ < div
40+ className = "group/card relative flex flex-col rounded-xl border border-black/10 dark:border-white/10 hover:!border-[var(--accent)] bg-white dark:bg-neutral-900 p-5 shadow-sm overflow-hidden transition-all duration-300 hover:-translate-y-1 hover:shadow-xl"
41+ style = { { '--accent' : `${ accentColor } 60` } as React . CSSProperties }
42+ >
43+ < span
44+ className = "pointer-events-none absolute -top-6 -right-6 w-24 h-24 rounded-full blur-[40px] opacity-0 group-hover/card:opacity-20 transition-opacity duration-500"
45+ style = { { backgroundColor : accentColor } }
46+ />
3447 < div className = "flex-grow" >
3548 < div className = "flex gap-2 mb-3" >
36- < Badge variant = "blue" >
49+ < Badge
50+ variant = "default"
51+ style = { {
52+ backgroundColor : `${ accentColor } 20` ,
53+ color : accentColor ,
54+ } }
55+ >
3756 { quiz . categoryName ?? t ( 'uncategorized' ) }
3857 </ Badge >
3958 { userProgress && < Badge variant = "success" > { t ( 'completed' ) } </ Badge > }
@@ -48,11 +67,11 @@ export function QuizCard({ quiz, userProgress }: QuizCardProps) {
4867 ) }
4968 < div className = "flex gap-3 text-xs text-gray-500 mb-3" >
5069 < span className = "flex items-center gap-1" >
51- < FileText className = "w-3.5 h-3.5 text-blue-500 dark:text-blue-400" />
70+ < FileText className = "w-3.5 h-3.5" style = { { color : accentColor } } />
5271 { quiz . questionsCount } { t ( 'questions' ) }
5372 </ span >
5473 < span className = "flex items-center gap-1" >
55- < Clock className = "w-3.5 h-3.5 text-blue-500 dark:text-blue-400" />
74+ < Clock className = "w-3.5 h-3.5" style = { { color : accentColor } } />
5675 { Math . floor (
5776 ( quiz . timeLimitSeconds ?? quiz . questionsCount * 30 ) / 60
5877 ) } { ' ' }
@@ -76,17 +95,26 @@ export function QuizCard({ quiz, userProgress }: QuizCardProps) {
7695 </ div >
7796 < div className = "h-1.5 bg-gray-200 dark:bg-neutral-800 rounded-full overflow-hidden" >
7897 < div
79- className = "h-full bg-blue-600 rounded-full transition-all"
80- style = { { width : `${ percentage } %` } }
98+ className = "h-full rounded-full transition-all"
99+ style = { { width : `${ percentage } %` , backgroundColor : accentColor } }
81100 />
82101 </ div >
83102 </ div >
84103 ) }
85104 < Link
86105 href = { `/quiz/${ quiz . slug } ` }
87- className = "btn block w-full text-center rounded-lg text-white px-4 py-2.5 text-sm font-medium transition-colors"
106+ className = "group relative block w-full overflow-hidden text-center rounded-xl border px-4 py-2.5 text-sm font-semibold transition-all duration-300"
107+ style = { {
108+ borderColor : `${ accentColor } 50` ,
109+ backgroundColor : `${ accentColor } 15` ,
110+ color : accentColor ,
111+ } }
88112 >
89113 { userProgress ? t ( 'retake' ) : t ( 'start' ) }
114+ < span
115+ className = "pointer-events-none absolute left-1/2 top-1/2 h-[150%] w-[80%] -translate-x-1/2 -translate-y-1/2 rounded-full blur-[20px] opacity-0 transition-opacity duration-300 group-hover:opacity-30"
116+ style = { { backgroundColor : accentColor } }
117+ />
90118 </ Link >
91119 </ div >
92120 ) ;
0 commit comments