@@ -38,7 +38,8 @@ const getLevelPct = (xp) => ((xp % XP_PER_LEVEL) / XP_PER_LEVEL) * 100;
3838const XPBar = ( { xp, loginXp = 0 , challengeXp = 0 , loginCount = 0 } ) => {
3939 const ref = useRef ( null ) ;
4040 const inView = useInView ( ref , { once : true } ) ;
41- const pct = getLevelPct ( xp ) ;
41+ const currentLevelXp = xp % XP_PER_LEVEL ;
42+ const pct = ( currentLevelXp / XP_PER_LEVEL ) * 100 ;
4243 const lvl = getLevel ( xp ) ;
4344
4445 const loginRatio = xp > 0 ? loginXp / xp : 0 ;
@@ -48,17 +49,17 @@ const XPBar = ({ xp, loginXp = 0, challengeXp = 0, loginCount = 0 }) => {
4849 < div ref = { ref } className = "space-y-1.5 relative group" >
4950 < div className = "flex items-center justify-between text-[10px] font-black uppercase tracking-widest" >
5051 < span className = "text-tertiary" > Level { lvl } </ span >
51- < span style = { { color : "rgb(var(--accent-rgb))" } } > { xp } XP</ span >
52+ < span style = { { color : "rgb(var(--accent-rgb))" } } > { currentLevelXp } / { XP_PER_LEVEL } XP</ span >
5253 </ div >
5354
5455 { /* XP Breakdown Tooltip */ }
5556 < div className = "absolute bottom-full left-1/2 -translate-x-1/2 mb-2 w-max bg-black/90 dark:bg-white/90 text-white dark:text-black text-[10px] font-bold p-2 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity z-50 shadow-xl shadow-black/20 text-center flex flex-col gap-1 pointer-events-none" >
5657 < div className = "flex justify-between gap-4" >
57- < span className = "text-blue-400 dark:text-blue-600 " > Daily Login XP:</ span >
58+ < span className = "text-[#3b82f6] " > Daily Login XP:</ span >
5859 < span > { loginXp } XP ({ loginCount } days)</ span >
5960 </ div >
6061 < div className = "flex justify-between gap-4" >
61- < span className = "text-purple-400 dark:text-purple-600 " > Challenges XP:</ span >
62+ < span className = "text-[#ec4899] " > Challenges XP:</ span >
6263 < span > { challengeXp } XP</ span >
6364 </ div >
6465 < div className = "mt-1 pt-1 border-t border-white/20 dark:border-black/20 flex justify-between gap-4" >
@@ -71,29 +72,20 @@ const XPBar = ({ xp, loginXp = 0, challengeXp = 0, loginCount = 0 }) => {
7172
7273 < div className = "h-1.5 rounded-full bg-black/[0.06] dark:bg-white/[0.06] overflow-hidden flex" >
7374 < motion . div
74- className = "h-full"
75+ className = "h-full rounded-full "
7576 style = { {
76- background : " linear-gradient(90deg, rgba(59,130,246,0.9), rgba(99,102,241,0.9))" ,
77- boxShadow : " 0 0 10px rgba(59,130,246 ,0.5)" ,
77+ background : ` linear-gradient(90deg, #3b82f6 0%, #a855f7 ${ loginRatio * 100 } %, #ec4899 100%)` ,
78+ boxShadow : ` 0 0 10px rgba(168,85,247 ,0.5)`
7879 } }
7980 initial = { { width : 0 } }
80- animate = { { width : inView ? `${ pct * loginRatio } %` : 0 } }
81- transition = { { duration : 1.4 , ease : "easeOut" } }
82- />
83- < motion . div
84- className = "h-full rounded-r-full"
85- style = { {
86- background : "linear-gradient(90deg, rgba(168,85,247,0.9), rgba(236,72,153,0.9))" ,
87- boxShadow : "0 0 10px rgba(168,85,247,0.5)" ,
88- } }
89- initial = { { width : 0 } }
90- animate = { { width : inView ? `${ pct * challengeRatio } %` : 0 } }
81+ animate = { { width : inView ? `${ pct } %` : 0 } }
9182 transition = { { duration : 1.4 , ease : "easeOut" } }
9283 />
9384 </ div >
94- < p className = "text-[10px] text-tertiary" >
95- { XP_PER_LEVEL - ( xp % XP_PER_LEVEL ) } XP to Level { lvl + 1 }
96- </ p >
85+ < div className = "flex justify-between text-[10px] text-tertiary" >
86+ < span > { XP_PER_LEVEL - currentLevelXp } XP to Level { lvl + 1 } </ span >
87+ < span className = "font-semibold text-secondary" > Total: { xp } XP</ span >
88+ </ div >
9789 </ div >
9890 ) ;
9991} ;
0 commit comments