|
34 | 34 | </div> |
35 | 35 |
|
36 | 36 | <div class="filter-tag-row"> |
37 | | - <span class="filter-label">{{ include.label }}:</span> |
38 | | - <button class="filter-btn active" onclick="applyTagFilter('all')"> |
39 | | - All <span class="count-pill">{{ include.items.size }}</span> |
| 37 | + <span class="filter-label">{{ include.label }}:</span> |
| 38 | + |
| 39 | + {% comment %} Set your threshold here: tags with count < threshold are hidden {% endcomment %} |
| 40 | + {% assign threshold = 2 %} |
| 41 | + {% assign has_extra = false %} |
| 42 | + |
| 43 | + <button class="filter-btn" onclick="applyTagFilter('all')"> |
| 44 | + All <span class="count-pill">{{ include.items.size }}</span> |
| 45 | + </button> |
| 46 | + |
| 47 | + {% for entry in sorted_tag_counts %} |
| 48 | + {% assign parts = entry | split: "|" %} |
| 49 | + {% assign tag = parts[1] %} |
| 50 | + {% assign count = parts[0] | plus: 0 %} |
| 51 | + |
| 52 | + {% if tag != "" %} |
| 53 | + {% if count >= threshold %} |
| 54 | + <button class="filter-btn" onclick="applyTagFilter('{{ tag }}')"> |
| 55 | + {{ tag }} <span class="count-pill">{{ count }}</span> |
| 56 | + </button> |
| 57 | + {% else %} |
| 58 | + {% if has_extra == false %} |
| 59 | + <span id="extra-tag-container" class="is-hidden" style="display: contents;"> |
| 60 | + {% assign has_extra = true %} |
| 61 | + {% endif %} |
| 62 | + <button class="filter-btn" onclick="applyTagFilter('{{ tag }}')"> |
| 63 | + {{ tag }} <span class="count-pill">{{ count }}</span> |
| 64 | + </button> |
| 65 | + {% endif %} |
| 66 | + {% endif %} |
| 67 | + {% endfor %} |
| 68 | + |
| 69 | + {% if has_extra %} |
| 70 | + </span> <button id="toggle-more-btn" class="filter-btn" onclick="toggleExtraTags()" style="border-style: dashed; opacity: 0.7;"> |
| 71 | + + More |
40 | 72 | </button> |
41 | | - {% for entry in sorted_tag_counts %} |
42 | | - {% assign parts = entry | split: "|" %}{% assign tag = parts[1] %}{% assign count = parts[0] | plus: 0 %} |
43 | | - <button class="filter-btn" onclick="applyTagFilter('{{ tag }}')"> |
44 | | - {{ tag }} <span class="count-pill">{{ count }}</span> |
45 | | - </button> |
46 | | - {% endfor %} |
| 73 | + {% endif %} |
47 | 74 | </div> |
| 75 | + |
48 | 76 | <div id="no-results" class="no-results-message is-hidden"> |
49 | 77 | Please select a tag to view items. |
50 | 78 | </div> |
|
206 | 234 | document.getElementById('search-input').value = ''; |
207 | 235 | window.applyTagFilter('all'); |
208 | 236 | }; |
| 237 | + |
| 238 | +window.toggleExtraTags = function() { |
| 239 | + const container = document.getElementById('extra-tag-container'); |
| 240 | + const btn = document.getElementById('toggle-more-btn'); |
| 241 | + |
| 242 | + if (container && btn) { |
| 243 | + const isHidden = container.classList.toggle('is-hidden'); |
| 244 | + btn.innerText = isHidden ? "+ More" : "- Less"; |
| 245 | + // Optional: add a class to style the button differently when open |
| 246 | + btn.classList.toggle('active-toggle', !isHidden); |
| 247 | + } |
| 248 | +}; |
209 | 249 | </script> |
0 commit comments