Skip to content

Commit 7fd5379

Browse files
authored
Fix progres level bar (#252)
1 parent 9e920bf commit 7fd5379

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

src/assets/css/style.css

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,11 +459,20 @@ body[data-level="6"]::after {
459459
--glow-color: #ef4444; /* Sith Red */
460460
}
461461

462-
/* Override the Tailwind duration-1000 for a better feel */
463-
#level-progress {
464-
transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
462+
/* Ensure the parent container has a background so you can see the 'empty' part */
463+
#game-stats .bg-black\/10 {
464+
background-color: rgba(0, 0, 0, 0.1) !important;
465+
min-width: 80px; /* Ensure it hasn't collapsed to 0 width */
466+
height: 6px;
465467
}
466468

469+
/* Ensure the progress bar itself has a height and a visible color */
470+
#level-progress {
471+
height: 100%;
472+
background-color: var(--accent); /* This is the level color */
473+
transition: width 0.3s ease-in-out !important; /* Make it smooth */
474+
display: block !important;
475+
}
467476

468477
/* Force Glow for the Badge */
469478
@keyframes force-pulse {

src/assets/js/script.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -853,11 +853,19 @@ document.addEventListener('DOMContentLoaded', () => {
853853
*/
854854
function renderXP(value) {
855855
const pb = document.getElementById('level-progress');
856-
if (pb) {
857-
// Ensure we don't exceed 100%
858-
const percent = Math.min((value / XP_PER_LEVEL) * 100, 100);
859-
pb.style.width = `${percent}%`;
860-
}
856+
if (!pb) return;
857+
858+
// 1. Ensure 'value' is a clean number
859+
const currentXPNum = Number(value) || 0;
860+
861+
// 2. Calculate percentage (current / 45 * 100)
862+
const percentage = Math.min((currentXPNum / 45) * 100, 100);
863+
864+
// 3. Apply to style
865+
pb.style.width = `${percentage}%`;
866+
867+
// Debugging: uncomment this to see the math in your console
868+
// console.log(`XP: ${currentXPNum}, Percent: ${percentage}%`);
861869
}
862870

863871

0 commit comments

Comments
 (0)