()
| 49 | } |
| 50 | |
| 51 | function render() { |
| 52 | if (!grid || !count || !emptyState) return |
| 53 | |
| 54 | const query = searchInput?.value.trim().toLowerCase() ?? '' |
| 55 | const visibleCards = sortCards(cards.filter((card) => matchesSearch(card, query) && matchesTags(card))) |
| 56 | const visibleSet = new Set(visibleCards) |
| 57 | |
| 58 | for (const card of cards) { |
| 59 | card.hidden = !visibleSet.has(card) |
| 60 | } |
| 61 | |
| 62 | for (const card of visibleCards) { |
| 63 | grid.append(card) |
| 64 | } |
| 65 | |
| 66 | count.textContent = `${visibleCards.length} ${visibleCards.length === 1 ? 'theme' : 'themes'}` |
| 67 | emptyState.hidden = visibleCards.length > 0 |
| 68 | } |
| 69 | |
| 70 | for (const button of tagButtons) { |
| 71 | button.addEventListener('click', () => { |
no test coverage detected