Skip to content

Commit 45ae372

Browse files
committed
feat: add difficulty badges and filtering
1 parent bb792c7 commit 45ae372

3 files changed

Lines changed: 85 additions & 16 deletions

File tree

web-app/css/styles.css

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7334,4 +7334,41 @@ color:#22c55e;
73347334

73357335
margin-left:8px;
73367336

7337+
}
7338+
.difficulty-badge{
7339+
7340+
position:absolute;
7341+
7342+
top:15px;
7343+
7344+
left:15px;
7345+
7346+
padding:5px 12px;
7347+
7348+
border-radius:20px;
7349+
7350+
font-size:.75rem;
7351+
7352+
font-weight:700;
7353+
7354+
color:#fff;
7355+
7356+
}
7357+
7358+
.difficulty-badge.beginner{
7359+
7360+
background:#22c55e;
7361+
7362+
}
7363+
7364+
.difficulty-badge.intermediate{
7365+
7366+
background:#f59e0b;
7367+
7368+
}
7369+
7370+
.difficulty-badge.advanced{
7371+
7372+
background:#ef4444;
7373+
73377374
}

web-app/index.html

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -767,12 +767,13 @@ <h3>Stay Updated</h3>
767767
const projectsData = [
768768
// GAMES (20+)
769769
{
770-
project: "number-sliding-puzzle",
771-
title: "Number Sliding Puzzle",
772-
category: "games",
773-
desc: "Arrange tiles in order by sliding them into empty space",
774-
tags: "game,puzzle,sliding,numbers",
775-
},
770+
project: "number-sliding-puzzle",
771+
title: "Number Sliding Puzzle",
772+
category: "games",
773+
difficulty: "Intermediate",
774+
desc: "Arrange tiles in order by sliding them into empty space",
775+
tags: "game,puzzle,sliding,numbers",
776+
},
776777
{
777778
project: "2048-game",
778779
title: "2048 Game",
@@ -1190,16 +1191,31 @@ <h3>Stay Updated</h3>
11901191
const starClass = isFavorite ? "fas fa-star" : "far fa-star";
11911192

11921193
card.innerHTML = `
1193-
<img class="card-banner" src="assets/banners/${proj.project}.webp?v=2" alt="${proj.title}" loading="lazy">
1194-
<div class="card-actions">
1195-
<button class="btn-play" data-project="${proj.project}" aria-label="Play PyMini Logo">Try It</button>
1196-
<button class="btn-favorite" data-project="${proj.project}" aria-label="Add to favorites">
1197-
<i class="${starClass}"></i>
1198-
</button>
1199-
</div>
1200-
<h3>${proj.title}</h3>
1201-
<p>${proj.desc}</p>
1202-
`;
1194+
<div class="difficulty-badge ${proj.difficulty.toLowerCase()}">
1195+
${proj.difficulty}
1196+
</div>
1197+
1198+
<img class="card-banner"
1199+
src="assets/banners/${proj.project}.webp?v=2"
1200+
alt="${proj.title}"
1201+
loading="lazy">
1202+
1203+
<div class="card-actions">
1204+
<button class="btn-play"
1205+
data-project="${proj.project}">
1206+
Try It
1207+
</button>
1208+
1209+
<button class="btn-favorite"
1210+
data-project="${proj.project}">
1211+
<i class="${starClass}"></i>
1212+
</button>
1213+
</div>
1214+
1215+
<h3>${proj.title}</h3>
1216+
1217+
<p>${proj.desc}</p>
1218+
`;
12031219

12041220
projectsGrid.appendChild(card);
12051221
});

web-app/js/main.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,22 @@ document.addEventListener("DOMContentLoaded", function () {
14551455
═══════════════════════════════════════════════════════════════ */
14561456
function wireProjectCard(card) {
14571457
var name = card.getAttribute("data-project");
1458+
const difficulty =
1459+
card.getAttribute("data-difficulty");
1460+
1461+
if(difficulty){
1462+
1463+
const badge=document.createElement("span");
1464+
1465+
badge.className=
1466+
"difficulty-badge "+
1467+
difficulty.toLowerCase();
1468+
1469+
badge.textContent=difficulty;
1470+
1471+
card.appendChild(badge);
1472+
1473+
}
14581474

14591475
/* ── Favorite Button ──────────────────────────────────── */
14601476
// Remove any existing favorite button first to avoid duplicates

0 commit comments

Comments
 (0)