Skip to content

Commit af36774

Browse files
brunoborgesCopilot
andcommitted
Show 'no results' message when filters yield empty results
Display a centered message when category + JDK filter combination matches no patterns. Includes translations for all 13 locales. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 21896b2 commit af36774

File tree

16 files changed

+32
-1
lines changed

16 files changed

+32
-1
lines changed

site/app.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,10 @@
216216
'25': [22, 25]
217217
};
218218

219+
const noResultsMsg = document.getElementById('noResultsMessage');
220+
219221
const applyFilters = () => {
222+
let visibleCount = 0;
220223
cards.forEach(card => {
221224
const matchesCategory = !activeCategory || card.dataset.category === activeCategory;
222225
let matchesJdk = true;
@@ -225,9 +228,15 @@
225228
const range = LTS_RANGES[activeJdk];
226229
matchesJdk = range && version >= range[0] && version <= range[1];
227230
}
228-
card.classList.toggle('filter-hidden', !(matchesCategory && matchesJdk));
231+
const visible = matchesCategory && matchesJdk;
232+
card.classList.toggle('filter-hidden', !visible);
233+
if (visible) visibleCount++;
229234
});
230235

236+
if (noResultsMsg) {
237+
noResultsMsg.style.display = visibleCount === 0 ? '' : 'none';
238+
}
239+
231240
if (window.updateViewToggleState) {
232241
window.updateViewToggleState();
233242
}

site/styles.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,14 @@ nav {
415415
display: none;
416416
}
417417

418+
.no-results-message {
419+
text-align: center;
420+
color: var(--text-muted);
421+
padding: 3rem 1rem;
422+
font-size: 1.1rem;
423+
width: 100%;
424+
}
425+
418426
.tip-card {
419427
background: var(--surface);
420428
border: 1px solid var(--border);

templates/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ <h2 class="section-title">{{site.allComparisons}}</h2>
275275
<div class="tips-grid" id="tipsGrid">
276276
{{tipCards}}
277277
</div>
278+
<p class="no-results-message" id="noResultsMessage" style="display:none">{{filters.noResults}}</p>
278279
</section>
279280

280281
<div class="stats-bar">

translations/strings/ar.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ sections:
3131
filters:
3232
show: "عرض:"
3333
all: الكل
34+
noResults: لم يتم العثور على أنماط برمجية لهذا الفلتر.
3435
difficulty:
3536
beginner: مبتدئ
3637
intermediate: متوسط

translations/strings/bn.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ filters:
3434
all: সব
3535
jdk: 'JDK:'
3636
category: 'বিভাগ:'
37+
noResults: এই ফিল্টারের জন্য কোনো কোড প্যাটার্ন পাওয়া যায়নি।
3738
difficulty:
3839
beginner: প্রাথমিক
3940
intermediate: মধ্যম

translations/strings/de.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ sections:
3333
filters:
3434
show: 'Anzeigen:'
3535
all: Alle
36+
noResults: Keine Code-Muster für diesen Filter gefunden.
3637
difficulty:
3738
beginner: Einsteiger
3839
intermediate: Fortgeschritten

translations/strings/en.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ filters:
3535
all: All
3636
jdk: 'JDK:'
3737
category: 'Category:'
38+
noResults: No code patterns found for this filter.
3839
difficulty:
3940
beginner: Beginner
4041
intermediate: Intermediate

translations/strings/es.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ sections:
3333
filters:
3434
show: 'Mostrar:'
3535
all: Todos
36+
noResults: No se encontraron patrones de código para este filtro.
3637
difficulty:
3738
beginner: Principiante
3839
intermediate: Intermedio

translations/strings/fr.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ sections:
3333
filters:
3434
show: 'Afficher :'
3535
all: Tous
36+
noResults: Aucun patron de code trouvé pour ce filtre.
3637
difficulty:
3738
beginner: Débutant
3839
intermediate: Intermédiaire

translations/strings/it.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ sections:
3333
filters:
3434
show: 'Mostra:'
3535
all: Tutti
36+
noResults: Nessun pattern di codice trovato per questo filtro.
3637
difficulty:
3738
beginner: Principiante
3839
intermediate: Intermedio

0 commit comments

Comments
 (0)