From a4014182a06eb381ba4d2943077d3676361c7e01 Mon Sep 17 00:00:00 2001 From: Syco21 Date: Fri, 15 May 2026 22:33:39 +0200 Subject: [PATCH] Add mobile layout: full-width list with bottom sheet card detail --- src/components/CardRow/CardRow.jsx | 4 +- src/components/FilterBar/FilterBar.jsx | 2 +- src/hooks/useMediaQuery.js | 12 ++ src/index.css | 40 ++++++ src/pages/HomePage.jsx | 175 +++++++++++++++---------- 5 files changed, 162 insertions(+), 71 deletions(-) create mode 100644 src/hooks/useMediaQuery.js diff --git a/src/components/CardRow/CardRow.jsx b/src/components/CardRow/CardRow.jsx index b756a87..43488df 100644 --- a/src/components/CardRow/CardRow.jsx +++ b/src/components/CardRow/CardRow.jsx @@ -19,9 +19,9 @@ function typeBadge(type) { const PRINTING_COLS = '80px 1fr 150px 100px'; -function CardRow({ card }) { +function CardRow({ card, isMobile }) { const { expandedCardId, setExpandedCardId, ownedAmounts } = useContext(CardContext); - const isExpanded = expandedCardId === card.id; + const isExpanded = !isMobile && expandedCardId === card.id; const totalOwned = card.printings?.reduce((sum, p) => { const key = `${p.set_id}-${p.rarity_id}`; diff --git a/src/components/FilterBar/FilterBar.jsx b/src/components/FilterBar/FilterBar.jsx index 329d652..7344bdb 100644 --- a/src/components/FilterBar/FilterBar.jsx +++ b/src/components/FilterBar/FilterBar.jsx @@ -9,7 +9,7 @@ const CHIPS = [ function FilterBar({ typeFilter, setTypeFilter, ownedOnly, setOwnedOnly, sortBy, setSortBy }) { return ( -
+
{CHIPS.map(({ label, activeClass }) => ( + {artworkIndex + 1} / {ids.length} + +
+ )} +
+ +
+ {card.name} +
+ {card.type} + {card.attribute && {card.attribute}} + {card.race && {card.race}} +
+ {card.level != null && {'★'.repeat(Math.min(card.level, 13))} Lv.{card.level}} + {card.link_val != null && Link {card.link_val}} +
+ + {isMobile && card.printings?.length > 0 && ( +
+
+ CodeSetRarityOwned +
+ {card.printings.map((printing, i) => ( + + ))} +
+ )} + + ); + }; + return (
{/* Stats bar */}
- {stats.total.toLocaleString()} cards in DB - {stats.uniqueOwned.toLocaleString()} unique owned - {stats.totalCopies.toLocaleString()} total copies + {isMobile ? ( + <> + {stats.total.toLocaleString()} cards + {stats.uniqueOwned.toLocaleString()} owned + {stats.totalCopies.toLocaleString()} copies + + ) : ( + <> + {stats.total.toLocaleString()} cards in DB + {stats.uniqueOwned.toLocaleString()} unique owned + {stats.totalCopies.toLocaleString()} total copies + + )}
@@ -110,9 +184,9 @@ function HomePage() { {/* Main panels */}
- {/* Left — card list */} -
-
+ {/* Card list */} +
+
} + itemContent={(_, card) => } />
- {/* Right — card detail */} -
- {expandedCard ? ( - <> - {(() => { - const imgs = cardImages[expandedCardId]; - const blob = imgs?.blobs[artworkIndex]; - const ids = imgs?.ids ?? []; - return ( -
- {blob ? ( - {expandedCard.name} - ) : ( -
Loading image…
- )} - {ids.length > 1 && ( -
- - {artworkIndex + 1} / {ids.length} - -
- )} -
- ); - })()} -
- {expandedCard.name} -
- - {expandedCard.type} - - {expandedCard.attribute && ( - - {expandedCard.attribute} - - )} - {expandedCard.race && ( - - {expandedCard.race} - - )} -
- {expandedCard.level != null && ( - - {'★'.repeat(Math.min(expandedCard.level, 13))} Lv.{expandedCard.level} - - )} - {expandedCard.link_val != null && ( - Link {expandedCard.link_val} - )} -
- - ) : ( - Click a card to see details - )} -
+ {/* Desktop: right panel */} + {!isMobile && ( +
+ {expandedCard + ? cardDetailContent(expandedCard) + : Click a card to see details + } +
+ )}
+ {/* Mobile: bottom sheet */} + {isMobile && expandedCard && ( + <> +
setExpandedCardId(null)} /> +
+
+
+ {cardDetailContent(expandedCard)} +
+
+ + )}
); }