Skip to content

Commit e27e462

Browse files
authored
Merge pull request #29 from andrewginns/merbench-ui-tweaks
feat: Light/dark mode text colouring for legibility
2 parents c440c9d + e390e5b commit e27e462

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed

src/components/merbench/LeaderboardTable.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ const costRange = maxCost - minCost;
307307
transform: translate(-50%, -50%);
308308
font-size: 0.75rem;
309309
font-weight: 600;
310-
color: white;
311-
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
310+
color: var(--progress-text-color);
311+
text-shadow: var(--progress-text-shadow);
312312
}
313313

314314
.cost {

src/layouts/BaseLayout.astro

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ const tagPairs = topTags.map((tag) => ({
251251
--shadow-light: rgba(0, 0, 0, 0.08);
252252
--shadow-medium: rgba(0, 0, 0, 0.12);
253253
--shadow-strong: rgba(0, 0, 0, 0.16);
254+
255+
/* Progress bar text styling - light mode */
256+
--progress-text-color: #000000;
257+
--progress-text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
254258
--sidebar-width: 240px;
255259
--content-max-width: 800px;
256260
--spacing-unit: 1rem;
@@ -300,6 +304,10 @@ const tagPairs = topTags.map((tag) => ({
300304
--shadow-light: rgba(1, 4, 9, 0.3);
301305
--shadow-medium: rgba(1, 4, 9, 0.4);
302306
--shadow-strong: rgba(1, 4, 9, 0.5);
307+
308+
/* Progress bar text styling - dark mode */
309+
--progress-text-color: #ffffff;
310+
--progress-text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
303311
}
304312

305313
* {

src/lib/merbench.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,22 +371,27 @@ export const updateLeaderboard = (filteredData: FilteredData): void => {
371371
const currentCost = entry.Avg_Cost || calculateCost(entry.Avg_Tokens);
372372
const costWidth = costRange > 0 ? (currentCost / maxCost) * 100 : 0;
373373

374+
const successRateClass =
375+
entry.Success_Rate >= 30
376+
? 'progress-fill--high'
377+
: entry.Success_Rate >= 15
378+
? 'progress-fill--medium'
379+
: 'progress-fill--low';
380+
374381
return `
375382
<tr>
376383
<td class="rank">${index + 1}</td>
377384
<td class="model-name">${entry.Model}</td>
378385
<td class="success-rate">
379386
<div class="progress-bar">
380-
<div class="progress-fill" style="width: ${entry.Success_Rate}%; background-color: ${
381-
entry.Success_Rate >= 30 ? '#27ae60' : entry.Success_Rate >= 15 ? '#f39c12' : '#e74c3c'
382-
}"></div>
383-
<span class="progress-text">${entry.Success_Rate.toFixed(1)}%</span>
387+
<div class="progress-fill ${successRateClass}" style="width: ${entry.Success_Rate}%;"></div>
388+
<span class="progress-text" style="color: var(--progress-text-color); text-shadow: var(--progress-text-shadow);">${entry.Success_Rate.toFixed(1)}%</span>
384389
</div>
385390
</td>
386391
<td class="cost">
387392
<div class="progress-bar">
388393
<div class="progress-fill progress-fill--cost" style="width: ${costWidth}%; background-color: #9ca3af;"></div>
389-
<span class="progress-text">$${currentCost.toFixed(4)}</span>
394+
<span class="progress-text" style="color: var(--progress-text-color); text-shadow: var(--progress-text-shadow);">$${currentCost.toFixed(4)}</span>
390395
</div>
391396
</td>
392397
<td class="duration">${entry.Avg_Duration.toFixed(2)}s</td>

src/scripts/merbench-sorting.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,27 @@ const renderLeaderboard = (data: LeaderboardEntry[]): void => {
9898
const currentCost = entry.Avg_Cost || calculateCost(entry.Avg_Tokens);
9999
const costWidth = costRange > 0 ? (currentCost / maxCost) * 100 : 0;
100100

101+
const successRateClass =
102+
entry.Success_Rate >= 30
103+
? 'progress-fill--high'
104+
: entry.Success_Rate >= 15
105+
? 'progress-fill--medium'
106+
: 'progress-fill--low';
107+
101108
return `
102109
<tr>
103110
<td class="rank">${index + 1}</td>
104111
<td class="model-name">${entry.Model}</td>
105112
<td class="success-rate">
106113
<div class="progress-bar">
107-
<div class="progress-fill" style="width: ${entry.Success_Rate}%; background-color: ${
108-
entry.Success_Rate >= 30 ? '#27ae60' : entry.Success_Rate >= 15 ? '#f39c12' : '#e74c3c'
109-
}"></div>
110-
<span class="progress-text">${entry.Success_Rate.toFixed(1)}%</span>
114+
<div class="progress-fill ${successRateClass}" style="width: ${entry.Success_Rate}%;"></div>
115+
<span class="progress-text" style="color: var(--progress-text-color); text-shadow: var(--progress-text-shadow);">${entry.Success_Rate.toFixed(1)}%</span>
111116
</div>
112117
</td>
113118
<td class="cost">
114119
<div class="progress-bar">
115120
<div class="progress-fill progress-fill--cost" style="width: ${costWidth}%; background-color: #9ca3af;"></div>
116-
<span class="progress-text">$${currentCost.toFixed(4)}</span>
121+
<span class="progress-text" style="color: var(--progress-text-color); text-shadow: var(--progress-text-shadow);">$${currentCost.toFixed(4)}</span>
117122
</div>
118123
</td>
119124
<td class="duration">${entry.Avg_Duration.toFixed(2)}s</td>

0 commit comments

Comments
 (0)