Deck chips open their deck

Deck-name chips in the Library, Card Search and the card preview modal are
now buttons (DeckChip) that open that deck in the Decks tab — on mobile,
straight to its building screen. App provides the open-deck callback via
context and hands the deck id to DeckView.

Closes #19
This commit is contained in:
2026-10-23 23:10:40 -05:00
parent 945e5ed766
commit b96931c7b8
6 changed files with 95 additions and 21 deletions

View File

@@ -427,7 +427,16 @@ function computeDeckLegality(deck: Deck | null | undefined, contents: DeckEntry[
* card list, mana curve, and legality tile recompute immediately instead of
* only on the next mount.
*/
export function DeckView({ refreshSignal }: { refreshSignal?: number }) {
export function DeckView({
refreshSignal,
openDeckId,
onOpenedDeck,
}: {
refreshSignal?: number;
/** A deck to open, e.g. from a deck chip elsewhere; `onOpenedDeck` clears it. */
openDeckId?: number | null;
onOpenedDeck?: () => void;
}) {
const [decks, setDecks] = useState<Deck[]>([]);
const [selected, setSelected] = usePersistedState<number | null>(libraryKey("deck-selected"), null);
const [newName, setNewName] = useState("");
@@ -444,6 +453,14 @@ export function DeckView({ refreshSignal }: { refreshSignal?: number }) {
// this only matters below the .deck-layout stacking breakpoint; CSS keeps
// both panes visible side by side above it regardless of this flag.
const [mobileShowList, setMobileShowList] = useState(true);
// Open a deck asked for from outside — straight to its building screen.
useEffect(() => {
if (openDeckId == null) return;
setSelected(openDeckId);
setMobileShowList(false);
onOpenedDeck?.();
}, [openDeckId]);
// Android back from the deck-building screen returns to the deck list, like
// its ← button. Only while they're separate screens (the ≤720px
// `.deck-layout` breakpoint): side by side, flipping the flag changes