Skip to content

Commit 3543c89

Browse files
committed
Add bars in background
1 parent 90e0de2 commit 3543c89

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

static/css/layout.css

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ nav {
219219
.leaderboard-table td:first-child,
220220
.leaderboard-table th:first-child {
221221
text-align: left;
222-
width: 3rem;
222+
width: 1rem;
223223
}
224224

225225
.leaderboard-table td:last-child,
@@ -228,6 +228,21 @@ nav {
228228
width: 8rem;
229229
}
230230

231+
/* ELO row with background bar visualization spanning entire row */
232+
.elo-row {
233+
position: relative;
234+
background: linear-gradient(
235+
to right,
236+
rgba(34, 197, 94, 0.25) calc(var(--elo-percent) * 1%),
237+
transparent calc(var(--elo-percent) * 1%)
238+
);
239+
}
240+
241+
.elo-row td {
242+
position: relative;
243+
z-index: 1;
244+
}
245+
231246
/* Insights */
232247
.insights-container {
233248
width: 75%;

templates/_leaderboard.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
{% set elo_min_scale = 700 %}
2+
{% set elo_max_scale = leaderboard.board | map(attribute='elo') | max %}
3+
{% set elo_scale_range = elo_max_scale - elo_min_scale %}
14
<table class="leaderboard-table">
25
<thead>
36
<tr>
@@ -8,7 +11,9 @@
811
</thead>
912
<tbody>
1013
{% for entry in leaderboard.board %}
11-
<tr>
14+
{% set elo_percent_raw = (entry.elo - elo_min_scale) / elo_scale_range * 100 %}
15+
{% set elo_percent = [0, [elo_percent_raw, 100] | min] | max %}
16+
<tr class="elo-row" style="--elo-percent: {{ '%.1f' | format(elo_percent) }}">
1217
<td>{{ entry.rank }}</td>
1318
<td>
1419
{% set logos = {
@@ -28,7 +33,7 @@
2833
/>
2934
{{ entry.model }}
3035
</td>
31-
<td>{{ entry.elo }} ± {{ entry.elo_std }}</td>
36+
<td class="elo-value">{{ entry.elo }} ± {{ entry.elo_std }}</td>
3237
</tr>
3338
{% endfor %}
3439
</tbody>

0 commit comments

Comments
 (0)