feat: Add "Go back a day..." and "Filter by distance..." to index.html

This commit is contained in:
Your Name (aider) committed 2025-04-28 11:51:32 +00:00
1 parent 4f1fb05bd6
commit 3528a38c4f
1 file changed
+59 -4
+59 -4
View File
@@ -17,8 +17,8 @@
<div class="hidden md:flex">
<a class="py-2 px-3 text-primary hover:bg-opacity-5 hover:bg-primary font-semibold" href="#">top 🔥</a>
<a class="py-2 px-3 text-primary hover:bg-opacity-5 hover:bg-primary" href="#">new</a>
<a class="py-2 px-3 text-primary hover:bg-opacity-5 hover:bg-primary" href="#">nearby</a>
<a class="py-2 px-3 text-primary hover:bg-opacity-5 hover:bg-primary" href="#">past</a>
<a class="py-2 px-3 text-primary hover:bg-opacity-5 hover:bg-primary" id="nearby-link" href="#">nearby</a>
<a class="py-2 px-3 text-primary hover:bg-opacity-5 hover:bg-primary" id="past-link" href="#">past</a>
<a class="py-2 px-3 text-primary hover:bg-opacity-5 hover:bg-primary" href="#">ask</a>
<span class="py-2 px-3 text-primary">|</span>
<a class="py-2 px-3 text-primary hover:bg-opacity-5 hover:bg-primary" href="#">rant</a>
@@ -44,8 +44,8 @@
<div id="mobileMenu" class="hidden md:hidden">
<a class="block py-2 px-3 text-primary hover:bg-opacity-5 hover:bg-primary font-semibold" href="#">top 🔥</a>
<a class="block py-2 px-3 text-primary hover:bg-opacity-5 hover:bg-primary" href="#">new</a>
<a class="block py-2 px-3 text-primary hover:bg-opacity-5 hover:bg-primary" href="#">nearby</a>
<a class="block py-2 px-3 text-primary hover:bg-opacity-5 hover:bg-primary" href="#">past</a>
<a class="block py-2 px-3 text-primary hover:bg-opacity-5 hover:bg-primary" id="mobile-nearby-link" href="#">nearby</a>
<a class="block py-2 px-3 text-primary hover:bg-opacity-5 hover:bg-primary" id="mobile-past-link" href="#">past</a>
<a class="block py-2 px-3 text-primary hover:bg-opacity-5 hover:bg-primary" href="#">ask</a>
<span class="block py-2 px-3 text-primary">|</span>
<a class="block py-2 px-3 text-primary hover:bg-opacity-5 hover:bg-primary" href="#">rant</a>
@@ -61,6 +61,19 @@
<p><strong>Quick Tips:</strong> Keep it brief, keep it real. Share your desk moments, finds, or frustrations. Upvote what resonates!</p>
</div>
<!-- Filter Container -->
<div id="filter-container" class="hidden">
<!-- Date Display -->
<div id="date-display" class="mb-4 text-text-muted hidden">
<p>Stories from <a href="#" class="text-primary hover:underline">April</a> <a href="#" class="text-primary hover:underline">24</a>, <a href="#" class="text-primary hover:underline">2025</a> (UTC)</p>
</div>
<!-- Filter Section -->
<div id="filter-section" class="mb-4 text-text-muted hidden">
<p id="filter-text"></p>
</div>
</div>
<div class="post-list space-y-2">
<!-- Post 1 -->
<div class="mb-1">
@@ -660,6 +673,48 @@
menuButton.setAttribute('aria-expanded', !expanded);
});
}
const nearbyLink = document.getElementById('nearby-link');
const pastLink = document.getElementById('past-link');
const mobileNearbyLink = document.getElementById('mobile-nearby-link');
const mobilePastLink = document.getElementById('mobile-past-link');
const filterContainer = document.getElementById('filter-container');
const dateDisplay = document.getElementById('date-display');
const filterSection = document.getElementById('filter-section');
const filterText = document.getElementById('filter-text');
const showFilter = (type) => {
filterContainer.classList.remove('hidden');
if (type === 'nearby') {
dateDisplay.classList.add('hidden');
filterSection.classList.remove('hidden');
filterText.innerHTML = 'Filter by distance: <a href="#" class="text-primary hover:underline">1 mile</a>, <a href="#" class="text-primary hover:underline">3 miles</a>, <a href="#" class="text-primary hover:underline">10 miles</a>. Go forward a <a href="#" class="text-primary hover:underline">20 miles</a>.';
} else if (type === 'past') {
dateDisplay.classList.remove('hidden');
filterSection.classList.remove('hidden');
filterText.innerHTML = 'Go back a <a href="#" class="text-primary hover:underline">day</a>, <a href="#" class="text-primary hover:underline">month</a>, or <a href="#" class="text-primary hover:underline">year</a>. Go forward a <a href="#" class="text-primary hover:underline">day</a>.';
}
};
nearbyLink.addEventListener('click', (e) => {
e.preventDefault();
showFilter('nearby');
});
pastLink.addEventListener('click', (e) => {
e.preventDefault();
showFilter('past');
});
mobileNearbyLink.addEventListener('click', (e) => {
e.preventDefault();
showFilter('nearby');
});
mobilePastLink.addEventListener('click', (e) => {
e.preventDefault();
showFilter('past');
});
});
</script>
</body>