@@ -16,9 +16,22 @@ const Skills = ({
1616 xp,
1717 levelInfo
1818} : SkillProps ) => {
19- const currentLevel = ( xp > levelInfo . val ) ? levelInfo . id : levelInfo . id - 1 ;
20- const xpToNextLevel = ( xp > 15000 ) ? 0 : ( levelInfo . val - xp ) ;
21- const xpToMax = ( xp > 15000 ) ? "Maxed" : 15000 - xp ;
19+ const currentLevel = ( xp >= levelInfo . val ) ? levelInfo . id : levelInfo . id - 1 ;
20+ const xpToNextLevel = ( xp >= 15000 ) ? 0 : ( levelInfo . val - xp ) ;
21+ const xpToMax = ( xp >= 15000 ) ? "Maxed" : 15000 - xp ;
22+
23+ // Calculate progress within current level
24+ const currentLevelXpRequirement = levelInfo . id > 1 ? Math . floor ( levelInfo . val * 0.85 ) : 0 ;
25+ const nextLevelXpRequirement = levelInfo . val ;
26+ const xpInCurrentLevel = Math . max ( 0 , xp - currentLevelXpRequirement ) ;
27+ const xpNeededForLevel = nextLevelXpRequirement - currentLevelXpRequirement ;
28+
29+ let progressPercentage = 0 ;
30+ if ( xp >= 15000 ) {
31+ progressPercentage = 100 ; // Max level
32+ } else if ( xpNeededForLevel > 0 ) {
33+ progressPercentage = Math . min ( 100 , ( xpInCurrentLevel / xpNeededForLevel ) * 100 ) ;
34+ }
2235
2336 return (
2437 < div className = "skill-container" >
@@ -27,13 +40,16 @@ const Skills = ({
2740 </ p >
2841 < div className = "skill-container__stats" >
2942 < div className = "skill-container__stats-line" >
30- Current XP: { xp }
31- </ div >
32- < div className = "skill-container__stats-line" >
33- Level Up in: { xpToNextLevel }
34- </ div >
35- < div className = "skill-container__stats-line" >
36- Max level in: { xpToMax }
43+ < div className = "skill-container__progress-bar" >
44+ < div
45+ className = "skill-container__progress-fill"
46+ style = { {
47+ width : `${ progressPercentage } %`
48+ } }
49+ > </ div >
50+ </ div >
51+ { xpToNextLevel > 0 ? `XP to next level: ${ xpToNextLevel } ` : "Max Level Reached" }
52+ { /* {xp} / {levelInfo.val} */ }
3753 </ div >
3854 </ div >
3955 < img
0 commit comments