Skip to content

Commit 33bd29b

Browse files
authored
Display progress outside the progress bar when it is low (#39)
1 parent c680fdd commit 33bd29b

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

style.css

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,36 @@ th {
1515
background-color: #f4f4f4;
1616
}
1717
.progress-bar {
18+
display: inline-block;
1819
background-color: #4caf50;
1920
color: white;
2021
height: 20px;
2122
line-height: 20px;
2223
text-align: center;
2324
overflow: hidden;
2425
white-space: nowrap;
25-
min-width: 50px;
2626
box-sizing: border-box;
2727
}
28+
.progress-bar-outer-label {
29+
display: none;
30+
padding-left: .5em;
31+
height: 20px;
32+
line-height: 20px;
33+
overflow: hidden;
34+
}
35+
.progress-bar.low {
36+
color: transparent;
37+
user-select: none;
38+
}
39+
.progress-bar.low + .progress-bar-outer-label {
40+
display: inline-block;
41+
}
2842
td[data-label="visitors"], td[data-label="translators"] {
2943
text-align: right;
3044
}
3145
td[data-label="completion"] {
3246
width: 100%;
47+
line-height: 0;
3348
}
3449
@media screen and (max-width: 600px) {
3550
table, thead, tbody, th, td, tr {

template.html.jinja

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,31 @@
4747
{% if translators_link %}</a>{% endif %}
4848
</td>
4949
<td data-label="completion">
50-
<div class="progress-bar" style="width: {{ completion | round(2) }}%;">{{ completion | round(2) }}%</div>
50+
<div class="progress-bar" style="width: {{ completion }}%;">{{ completion | round(2) }}%</div>
51+
<div class="progress-bar-outer-label">{{ completion | round(2) }}%</div>
5152
</td>
5253
</tr>
5354
{% endfor %}
5455
</tbody>
5556
</table>
5657
<p>Last updated at {{ generation_time.strftime('%A, %d %B %Y, %X %Z') }}.</p>
5758
</body>
59+
<script>
60+
function updateProgressBarVisibility() {
61+
document.querySelectorAll('.progress-bar').forEach(progressBar => {
62+
const textWidth = progressBar.scrollWidth;
63+
const barWidth = progressBar.offsetWidth;
64+
65+
if (barWidth < textWidth) {
66+
progressBar.classList.add('low');
67+
} else {
68+
progressBar.classList.remove('low');
69+
}
70+
});
71+
}
72+
73+
updateProgressBarVisibility();
74+
75+
window.addEventListener('resize', updateProgressBarVisibility);
76+
</script>
5877
</html>

0 commit comments

Comments
 (0)