Skip to content

Commit 96e80a0

Browse files
committed
fix(ui): prevent long clone paths from breaking report cards
1 parent e33a6c0 commit 96e80a0

2 files changed

Lines changed: 50 additions & 13 deletions

File tree

codeclone/html_report.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,9 +536,15 @@ def render_section(
536536
f'data-cache-used="{_escape(_meta_display(meta.get("cache_used")))}"',
537537
]
538538
)
539+
540+
def _meta_row_class(label: str) -> str:
541+
if label in {"Baseline", "Cache path"}:
542+
return "meta-row meta-row-wide"
543+
return "meta-row"
544+
539545
meta_rows_html = "".join(
540546
(
541-
'<div class="meta-row">'
547+
f'<div class="{_meta_row_class(label)}">'
542548
f"<dt>{_escape(label)}</dt>"
543549
f"<dd>{_escape(_meta_display(value))}</dd>"
544550
"</div>"

codeclone/templates.py

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@
133133
padding: 0;
134134
}
135135
136+
.icon {
137+
width: 1em;
138+
height: 1em;
139+
display: inline-block;
140+
vertical-align: middle;
141+
flex-shrink: 0;
142+
}
143+
136144
html {
137145
scroll-behavior: smooth;
138146
}
@@ -327,7 +335,7 @@
327335
.meta-grid {
328336
margin: 0;
329337
display: grid;
330-
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
338+
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
331339
gap: 8px 16px;
332340
}
333341
@@ -352,7 +360,12 @@
352360
color: var(--text-secondary);
353361
font-family: var(--font-mono);
354362
font-size: var(--text-xs);
355-
word-break: break-all;
363+
word-break: normal;
364+
overflow-wrap: anywhere;
365+
}
366+
367+
.meta-row-wide {
368+
grid-column: 1 / -1;
356369
}
357370
358371
.section-head {
@@ -1014,30 +1027,47 @@
10141027
}
10151028
10161029
.stat-card {
1017-
padding: 20px;
1030+
padding: 16px 18px;
10181031
background: var(--surface-1);
10191032
border: 1px solid var(--border-subtle);
10201033
border-radius: var(--radius-lg);
1021-
text-align: center;
1034+
text-align: left;
1035+
display: grid;
1036+
grid-template-columns: auto 1fr;
1037+
grid-template-rows: auto auto;
1038+
gap: 2px 12px;
1039+
align-items: center;
10221040
}
10231041
10241042
.stat-icon {
1025-
font-size: 32px;
1026-
margin-bottom: 8px;
1027-
opacity: 0.8;
1043+
grid-column: 1;
1044+
grid-row: 1 / span 2;
1045+
width: 38px;
1046+
height: 38px;
1047+
color: var(--text-tertiary);
1048+
opacity: 0.92;
1049+
}
1050+
1051+
.stat-icon .icon {
1052+
width: 100%;
1053+
height: 100%;
10281054
}
10291055
10301056
.stat-value {
1057+
grid-column: 2;
1058+
grid-row: 1;
10311059
font-size: var(--text-2xl);
10321060
font-weight: 700;
10331061
color: var(--text-primary);
1034-
margin-bottom: 4px;
1062+
line-height: 1.1;
10351063
}
10361064
10371065
.stat-label {
1066+
grid-column: 2;
1067+
grid-row: 2;
10381068
font-size: var(--text-sm);
1039-
color: var(--text-tertiary);
1040-
margin-bottom: 8px;
1069+
color: var(--text-muted);
1070+
margin: 0;
10411071
}
10421072
10431073
.stat-trend {
@@ -1832,6 +1862,7 @@
18321862
18331863
const metrics = collectSectionMetrics();
18341864
const maxValue = Math.max(1, ...metrics.map((m) => m.value));
1865+
const yMax = Math.max(4, Math.ceil(maxValue / 4) * 4);
18351866
const left = 52;
18361867
const right = 18;
18371868
const top = 16;
@@ -1848,7 +1879,7 @@
18481879
ctx.lineTo(left + chartWidth, y);
18491880
ctx.stroke();
18501881
1851-
const value = Math.round(maxValue - (maxValue * step) / 4);
1882+
const value = Math.round(yMax - (yMax * step) / 4);
18521883
ctx.fillStyle = textMuted;
18531884
ctx.font = '12px ' + sansFont;
18541885
ctx.textAlign = 'right';
@@ -1859,7 +1890,7 @@
18591890
const barWidth = Math.max(40, Math.min(90, slot * 0.56));
18601891
metrics.forEach((metric, idx) => {
18611892
const x = left + slot * idx + (slot - barWidth) / 2;
1862-
const barHeight = (metric.value / maxValue) * chartHeight;
1893+
const barHeight = (metric.value / yMax) * chartHeight;
18631894
const y = top + chartHeight - barHeight;
18641895
const color = styles.getPropertyValue(metric.colorVar).trim() || '#4f46e5';
18651896

0 commit comments

Comments
 (0)