Skip to content

Commit 8f372ab

Browse files
Merge pull request steam-bell-92#1403 from jyotish6699/feature/favorites-count-badge
feat: Add dynamic favorites count badge to My Favorites
2 parents a56ee5f + 7ef8417 commit 8f372ab

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

web-app/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@
150150
</button>
151151
<button aria-selected="false" class="sidebar-tab" data-category="favorites" role="tab" tabindex="-1">
152152
<span class="sidebar-icon"><svg data-lucide="star"></svg></span>
153-
<span class="sidebar-label">My Favorites</span>
153+
<span class="sidebar-label">
154+
My Favorites
155+
<span id="favoritesCountBadge">0</span>
156+
</span>
154157
</button>
155158
<button aria-selected="false" class="sidebar-tab" data-category="playground" role="tab" tabindex="-1">
156159
<span class="sidebar-icon"><svg data-lucide="terminal"></svg></span>

web-app/js/main.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,14 @@ document.addEventListener("DOMContentLoaded", function () {
14251425
window.closeProjectSafe = closeProjectSafe;
14261426
window.setMainInert = setMainInert;
14271427

1428+
function updateFavoritesCountBadge() {
1429+
const badge = document.getElementById("favoritesCountBadge");
1430+
if (!badge) return;
1431+
1432+
const favorites = JSON.parse(localStorage.getItem("favorites") || "[]");
1433+
badge.textContent = `(${favorites.length})`;
1434+
}
1435+
14281436
/* ═══════════════════════════════════════════════════════════════
14291437
WIRE PROJECT CARDS
14301438
═══════════════════════════════════════════════════════════════ */
@@ -1466,6 +1474,7 @@ document.addEventListener("DOMContentLoaded", function () {
14661474
}
14671475
}
14681476
localStorage.setItem("favorites", JSON.stringify(favs));
1477+
updateFavoritesCountBadge();
14691478
});
14701479

14711480
var cardActions = card.querySelector(".card-actions");
@@ -1534,6 +1543,8 @@ document.addEventListener("DOMContentLoaded", function () {
15341543

15351544
projectCards.forEach(wireProjectCard);
15361545

1546+
updateFavoritesCountBadge();
1547+
15371548
window.updateRecentlyViewed = function () {
15381549
var grid = document.getElementById("recentlyViewedGrid");
15391550
var section = document.getElementById("recentlyViewedSection");

0 commit comments

Comments
 (0)