From ce56d08efe92221fd35293543e0ca36643139c95 Mon Sep 17 00:00:00 2001 From: zach Date: Fri, 6 Mar 2026 13:53:15 -0500 Subject: [PATCH] scrolling within modals using keys/buttons/swipe (needs help with infinite scrolling) --- src/assets/css/main.scss | 69 ++++++ src/layouts/Main.astro | 2 + src/pages/partials/card-modal.astro | 334 +++++++++++++++++++++++++++- src/pages/partials/cards.astro | 1 - 4 files changed, 398 insertions(+), 8 deletions(-) diff --git a/src/assets/css/main.scss b/src/assets/css/main.scss index 794b5a7..1f5142e 100644 --- a/src/assets/css/main.scss +++ b/src/assets/css/main.scss @@ -530,4 +530,73 @@ $tiers: ( fill: var(--bs-success-border-subtle); stroke: var(--bs-success-border-subtle); color: var(--bs-success-border-subtle); +} + +/* Card Modal Navigation Styles */ + +.card-nav-prev, +.card-nav-next { + transition: all 0.2s ease-in-out; + display: inline-flex; + align-items: center; + justify-content: center; + min-width: 36px; + padding: 0.375rem 0.5rem; +} + +.card-nav-prev:hover:not(:disabled), +.card-nav-next:hover:not(:disabled) { + background-color: var(--bs-secondary); + border-color: var(--bs-secondary); + color: white; + transform: translateY(-1px); + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); +} + +.card-nav-prev:active:not(:disabled), +.card-nav-next:active:not(:disabled) { + transform: translateY(0); +} + +.card-nav-prev:disabled, +.card-nav-next:disabled { + cursor: not-allowed; +} + +/* Optional: Add keyboard indicator hint */ +.modal-header { + position: relative; +} + +/* Smooth fade in/out for disabled state */ +.card-nav-prev, +.card-nav-next { + will-change: opacity; +} + +/* Touch-friendly sizing on mobile */ +@media (max-width: 768px) { + .card-nav-prev, + .card-nav-next { + min-width: 40px; + padding: 0.5rem; + } +} + +/* Optional: Add a subtle animation when swiping */ +@keyframes swipe-feedback { + 0% { + transform: scale(1); + } + 50% { + transform: scale(0.95); + } + 100% { + transform: scale(1); + } +} + +.card-nav-prev.swiping, +.card-nav-next.swiping { + animation: swipe-feedback 0.3s ease-out; } \ No newline at end of file diff --git a/src/layouts/Main.astro b/src/layouts/Main.astro index 6e5ae23..5355700 100644 --- a/src/layouts/Main.astro +++ b/src/layouts/Main.astro @@ -17,6 +17,7 @@ import '/src/assets/css/main.scss'; + Rigid's App Thing @@ -40,5 +41,6 @@ import '/src/assets/css/main.scss'; + \ No newline at end of file diff --git a/src/pages/partials/card-modal.astro b/src/pages/partials/card-modal.astro index e3cd1ff..2e66d60 100644 --- a/src/pages/partials/card-modal.astro +++ b/src/pages/partials/card-modal.astro @@ -12,7 +12,6 @@ export const prerender = false; const searchParams = Astro.url.searchParams; const cardId = Number(searchParams.get('cardId')) || 0; - // query the database for the card with the given productId and return the card data as json const card = await db.query.cards.findFirst({ where: { cardId: Number(cardId) }, @@ -22,6 +21,16 @@ const card = await db.query.cards.findFirst({ } }); +// Get the current card's position in the grid and find previous/next cards +// This assumes cards are displayed in a specific order in the DOM +const cardElements = typeof document !== 'undefined' ? document.querySelectorAll('[data-card-id]') : []; +let prevCardId = null; +let nextCardId = null; + +// Since this is server-side, we can't access the DOM directly +// Instead, we'll pass the current cardId and let JavaScript handle navigation +// The JS will look for the next/prev cards in the grid based on the visible cards + function timeAgo(date: Date | null) { if (!date) return "Not applicable"; @@ -100,16 +109,27 @@ const ebaySearchUrl = (card: any) => { }; --- -