Skip to content

Commit 0a9da75

Browse files
committed
feat(downloads): add total downloads display in navigation and mobile card
1 parent 638d85d commit 0a9da75

3 files changed

Lines changed: 55 additions & 2 deletions

File tree

webapp/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,10 @@
559559
<svg class="ic star-ic"><use href="#i-star"/></svg>
560560
<span id="star-count">Star</span>
561561
</a>
562+
<a class="ghost-pill nav-downloads" href="https://github.com/TechyCSR/OpenCluely/releases/latest" target="_blank" rel="noopener" aria-label="Total downloads from GitHub releases">
563+
<svg class="ic dl-ic"><use href="#i-download"/></svg>
564+
<span id="dl-count-nav">Downloads</span>
565+
</a>
562566
<button class="menu-btn" id="menu-btn" aria-label="Open menu" aria-expanded="false">
563567
<svg class="ic icon-menu"><use href="#i-menu"/></svg>
564568
<svg class="ic icon-close"><use href="#i-close"/></svg>
@@ -572,6 +576,14 @@
572576
<a href="#how">How it works</a>
573577
<a href="#download">Download</a>
574578
<a href="#faq">FAQ</a>
579+
<a class="mobile-dl-card" href="https://github.com/TechyCSR/OpenCluely/releases/latest" target="_blank" rel="noopener">
580+
<span class="mobile-dl-icon"><svg class="ic dl-ic"><use href="#i-download"/></svg></span>
581+
<span class="mobile-dl-text">
582+
<span class="mobile-dl-eyebrow">Latest release</span>
583+
<span class="mobile-dl-count"><span id="dl-count-mobile"></span> Downloads</span>
584+
</span>
585+
<span class="mobile-dl-go" aria-hidden="true"><svg class="ic"><use href="#i-arrow"/></svg></span>
586+
</a>
575587
<a href="https://github.com/TechyCSR/OpenCluely" target="_blank" rel="noopener">GitHub</a>
576588
</div>
577589
</header>

webapp/script.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,24 @@
9797
fetch('https://api.github.com/repos/' + REPO, { headers: { Accept: 'application/vnd.github+json' } })
9898
.then(function (r) { return r.ok ? r.json() : null; })
9999
.then(function (d) {
100-
if (d && typeof d.stargazers_count === 'number' && starEl) {
101-
starEl.textContent = d.stargazers_count >= 1000
100+
if (d && typeof d.stargazers_count === 'number') {
101+
var label = d.stargazers_count >= 1000
102102
? (d.stargazers_count / 1000).toFixed(1) + 'k'
103103
: String(d.stargazers_count);
104+
if (starEl) { starEl.textContent = label; }
105+
}
106+
})
107+
.catch(function () {});
108+
109+
/* ---------- GitHub total downloads (live, mirrors README badge) ---------- */
110+
var dlEl = el('dl-count-nav');
111+
var dlElMobile = el('dl-count-mobile');
112+
fetch('https://img.shields.io/github/downloads/TechyCSR/OpenCluely/total.json')
113+
.then(function (r) { return r.ok ? r.json() : null; })
114+
.then(function (d) {
115+
if (d && typeof d.value === 'string' && d.value.length) {
116+
if (dlEl) { dlEl.textContent = d.value + ' downloads'; }
117+
if (dlElMobile) { dlElMobile.textContent = d.value; }
104118
}
105119
})
106120
.catch(function () {});

webapp/style.css

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,33 @@ img, video, svg { display: block; max-width: 100%; }
9898
.ghost-pill:hover { background: var(--surface-2); border-color: #3a3a3a; }
9999
.ghost-pill .ic { font-size: 1.05rem; }
100100
.ghost-pill .star-ic { color: #f5c518; font-size: 0.98rem; }
101+
.ghost-pill .dl-ic { color: #9ad7ff; font-size: 1rem; }
102+
103+
.nav-downloads { display: none; }
104+
@media (min-width: 761px) { .nav-downloads { display: inline-flex; } }
105+
106+
.mobile-dl-card {
107+
display: flex; align-items: center; gap: 14px;
108+
margin: 14px 16px; padding: 14px 16px;
109+
background: linear-gradient(180deg, #161616 0%, #0e0e0e 100%);
110+
border: 1px solid var(--border-2); border-radius: 14px;
111+
color: var(--text); text-decoration: none;
112+
font-weight: 600; box-shadow: 0 1px 0 rgba(255,255,255,0.02) inset;
113+
}
114+
.mobile-dl-card:active { background: var(--surface); }
115+
.mobile-dl-card .mobile-dl-icon {
116+
width: 40px; height: 40px; border-radius: 10px;
117+
display: inline-flex; align-items: center; justify-content: center;
118+
background: rgba(154, 215, 255, 0.12); border: 1px solid rgba(154, 215, 255, 0.3);
119+
flex: 0 0 auto;
120+
}
121+
.mobile-dl-card .mobile-dl-icon .dl-ic { color: #9ad7ff; font-size: 1.2rem; }
122+
.mobile-dl-card .mobile-dl-text { display: flex; flex-direction: column; gap: 2px; line-height: 1.2; flex: 1 1 auto; min-width: 0; }
123+
.mobile-dl-card .mobile-dl-eyebrow { font-size: 0.72rem; font-weight: 600; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
124+
.mobile-dl-card .mobile-dl-count { font-size: 1.05rem; font-weight: 700; color: var(--text); }
125+
.mobile-dl-card .mobile-dl-go { color: var(--muted); flex: 0 0 auto; }
126+
.mobile-dl-card .mobile-dl-go .ic { font-size: 1.1rem; }
127+
@media (min-width: 761px) { .mobile-dl-card { display: none; } }
101128

102129
.menu-btn {
103130
display: none; background: var(--surface); color: var(--text);

0 commit comments

Comments
 (0)