Spaces:
Sleeping
Sleeping
profile to show the max number at proper place in bar (#50)
Browse files- profile to show the max number at proper place in bar (a556baa1e7b4bc084164752e37acd1ed32b0860d)
Co-authored-by: Aanya Choudhary <TheFrogGod@users.noreply.huggingface.co>
- web/profile.html +24 -9
web/profile.html
CHANGED
|
@@ -409,15 +409,30 @@
|
|
| 409 |
|
| 410 |
barContainer.appendChild(bar);
|
| 411 |
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
|
| 416 |
-
|
| 417 |
-
|
| 418 |
-
|
| 419 |
-
|
| 420 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 421 |
|
| 422 |
card.appendChild(barContainer);
|
| 423 |
container.appendChild(card);
|
|
|
|
| 409 |
|
| 410 |
barContainer.appendChild(bar);
|
| 411 |
|
| 412 |
+
const minMaxDiv = document.createElement("div");
|
| 413 |
+
minMaxDiv.className = "min-max-labels relative w-full";
|
| 414 |
+
|
| 415 |
+
const minLabel = document.createElement("span");
|
| 416 |
+
minLabel.textContent = "Min: " + m.min;
|
| 417 |
+
minLabel.style.position = "absolute";
|
| 418 |
+
minLabel.style.left = "0";
|
| 419 |
+
|
| 420 |
+
const maxLabel = document.createElement("span");
|
| 421 |
+
maxLabel.textContent = "Max: " + m.max;
|
| 422 |
+
maxLabel.style.position = "absolute";
|
| 423 |
+
|
| 424 |
+
// put the max label at the end of the green section
|
| 425 |
+
let maxPercent = 100;
|
| 426 |
+
if (m.value > m.max) {
|
| 427 |
+
maxPercent = ((m.max - m.min) / (m.value - m.min)) * 100;
|
| 428 |
+
}
|
| 429 |
+
maxLabel.style.left = maxPercent + "%";
|
| 430 |
+
maxLabel.style.transform = "translateX(-100%)"; // anchor it properly
|
| 431 |
+
|
| 432 |
+
minMaxDiv.appendChild(minLabel);
|
| 433 |
+
minMaxDiv.appendChild(maxLabel);
|
| 434 |
+
barContainer.appendChild(minMaxDiv);
|
| 435 |
+
|
| 436 |
|
| 437 |
card.appendChild(barContainer);
|
| 438 |
container.appendChild(card);
|