diff --git a/themes/intotheeast/templates/trip.html.twig b/themes/intotheeast/templates/trip.html.twig index b10f1a3..9bf0f10 100644 --- a/themes/intotheeast/templates/trip.html.twig +++ b/themes/intotheeast/templates/trip.html.twig @@ -137,6 +137,7 @@ {% else %}
No entries yet. The journey is about to begin.
{% endif %} + @@ -189,5 +190,38 @@ if (TRIP_ENTRIES.length === 0) { map.fitBounds(L.latLngBounds(latLngs), { padding: [20, 20] }); } setTimeout(function() { map.invalidateSize(); }, 100); + +(function() { + var filterBtns = document.querySelectorAll('.trip-filter-btn'); + var cards = document.querySelectorAll('[data-type]'); + var filterEmpty = document.getElementById('feed-filter-empty'); + + filterBtns.forEach(function(btn) { + btn.addEventListener('click', function() { + filterBtns.forEach(function(b) { b.classList.remove('is-active'); }); + btn.classList.add('is-active'); + + var filter = btn.getAttribute('data-filter'); + var visible = 0; + + cards.forEach(function(card) { + var show = filter === 'all' || card.getAttribute('data-type') === filter; + card.style.display = show ? '' : 'none'; + if (show) visible++; + }); + + if (filterEmpty) { + if (visible === 0) { + filterEmpty.textContent = filter === 'story' + ? 'No stories yet for this trip.' + : 'No entries yet.'; + filterEmpty.style.display = ''; + } else { + filterEmpty.style.display = 'none'; + } + } + }); + }); +})(); {% endblock %}