Spaces:
Sleeping
Sleeping
Commit ·
630a171
1
Parent(s): 8d484eb
Fix stat box overflow: compact number formatting and responsive font sizing
Browse files- static/css/style.css +6 -2
- static/js/app.js +8 -2
static/css/style.css
CHANGED
|
@@ -529,7 +529,7 @@ input:focus, select:focus, textarea:focus {
|
|
| 529 |
/* ---- Result stats ---- */
|
| 530 |
.result-stats {
|
| 531 |
display: grid;
|
| 532 |
-
grid-template-columns: repeat(auto-fill, minmax(
|
| 533 |
gap: 0.75rem;
|
| 534 |
margin-bottom: 1.25rem;
|
| 535 |
}
|
|
@@ -543,13 +543,17 @@ input:focus, select:focus, textarea:focus {
|
|
| 543 |
}
|
| 544 |
.stat-box:hover { border-color: var(--border-hover); }
|
| 545 |
.stat-box .value {
|
| 546 |
-
font-size: 1.35rem;
|
| 547 |
font-weight: 700;
|
| 548 |
background: var(--gradient-h);
|
| 549 |
-webkit-background-clip: text;
|
| 550 |
-webkit-text-fill-color: transparent;
|
| 551 |
background-clip: text;
|
| 552 |
font-family: var(--font-mono);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 553 |
}
|
| 554 |
.stat-box .label {
|
| 555 |
font-size: 0.7rem;
|
|
|
|
| 529 |
/* ---- Result stats ---- */
|
| 530 |
.result-stats {
|
| 531 |
display: grid;
|
| 532 |
+
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
|
| 533 |
gap: 0.75rem;
|
| 534 |
margin-bottom: 1.25rem;
|
| 535 |
}
|
|
|
|
| 543 |
}
|
| 544 |
.stat-box:hover { border-color: var(--border-hover); }
|
| 545 |
.stat-box .value {
|
| 546 |
+
font-size: clamp(0.85rem, 3.5vw, 1.35rem);
|
| 547 |
font-weight: 700;
|
| 548 |
background: var(--gradient-h);
|
| 549 |
-webkit-background-clip: text;
|
| 550 |
-webkit-text-fill-color: transparent;
|
| 551 |
background-clip: text;
|
| 552 |
font-family: var(--font-mono);
|
| 553 |
+
overflow: hidden;
|
| 554 |
+
text-overflow: ellipsis;
|
| 555 |
+
white-space: nowrap;
|
| 556 |
+
word-break: break-all;
|
| 557 |
}
|
| 558 |
.stat-box .label {
|
| 559 |
font-size: 0.7rem;
|
static/js/app.js
CHANGED
|
@@ -236,6 +236,12 @@ function readFileAsDataURL(file) {
|
|
| 236 |
});
|
| 237 |
}
|
| 238 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
function showResult(data) {
|
| 240 |
const card = document.getElementById('result-card');
|
| 241 |
const statsEl = document.getElementById('result-stats');
|
|
@@ -243,8 +249,8 @@ function showResult(data) {
|
|
| 243 |
|
| 244 |
statsEl.innerHTML = `
|
| 245 |
<div class="stat-box"><div class="value">${data.statistics.changePercentage.toFixed(2)}%</div><div class="label">Changed</div></div>
|
| 246 |
-
<div class="stat-box"><div class="value"
|
| 247 |
-
<div class="stat-box"><div class="value"
|
| 248 |
<div class="stat-box"><div class="value">${(data.regions || []).length}</div><div class="label">Regions</div></div>
|
| 249 |
`;
|
| 250 |
|
|
|
|
| 236 |
});
|
| 237 |
}
|
| 238 |
|
| 239 |
+
function formatCompact(n) {
|
| 240 |
+
if (n >= 1_000_000) return (n / 1_000_000).toFixed(1).replace(/\.0$/, '') + 'M';
|
| 241 |
+
if (n >= 10_000) return (n / 1_000).toFixed(1).replace(/\.0$/, '') + 'K';
|
| 242 |
+
return n.toLocaleString();
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
function showResult(data) {
|
| 246 |
const card = document.getElementById('result-card');
|
| 247 |
const statsEl = document.getElementById('result-stats');
|
|
|
|
| 249 |
|
| 250 |
statsEl.innerHTML = `
|
| 251 |
<div class="stat-box"><div class="value">${data.statistics.changePercentage.toFixed(2)}%</div><div class="label">Changed</div></div>
|
| 252 |
+
<div class="stat-box"><div class="value" title="${data.statistics.changedPixels.toLocaleString()}">${formatCompact(data.statistics.changedPixels)}</div><div class="label">Changed px</div></div>
|
| 253 |
+
<div class="stat-box"><div class="value" title="${data.statistics.totalPixels.toLocaleString()}">${formatCompact(data.statistics.totalPixels)}</div><div class="label">Total px</div></div>
|
| 254 |
<div class="stat-box"><div class="value">${(data.regions || []).length}</div><div class="label">Regions</div></div>
|
| 255 |
`;
|
| 256 |
|