Shared card filter panel: News set browser gets every Library filter
Extract the filter fields and LibraryFilter-building state into src/cardFilter.tsx (CardFilterPanel + useCardFilter) and use it in the Library, Card Search and News set browser, replacing three diverging copies. search_reference now honors in_deck/location too, so every filter works in every tab. Closes #13
This commit is contained in:
@@ -2181,16 +2181,12 @@ export function CardCriteriaFields({
|
||||
value: c,
|
||||
onChange,
|
||||
hideNotOwned,
|
||||
showSpares,
|
||||
}: {
|
||||
value: CardCriteria;
|
||||
onChange: (patch: Partial<CardCriteria>) => void;
|
||||
/** Omit the "Not owned" toggle — for the Library tab, which already shows
|
||||
* nothing but owned cards, so the filter would just be a no-op there. */
|
||||
hideNotOwned?: boolean;
|
||||
/** Offer the "spare copies" toggle — a question about your collection, so
|
||||
* it belongs in the Library rather than in a search of every card. */
|
||||
showSpares?: boolean;
|
||||
}) {
|
||||
const toggleRarity = (key: string) =>
|
||||
onChange({
|
||||
@@ -2296,15 +2292,13 @@ export function CardCriteriaFields({
|
||||
on={c.vanillaOnly}
|
||||
onToggle={() => onChange({ vanillaOnly: !c.vanillaOnly })}
|
||||
/>
|
||||
{showSpares && (
|
||||
<IconToggle
|
||||
icon={ICON_SPARE}
|
||||
label="Only spare copies"
|
||||
hint="Cards you own more copies of than your decks use — free for a trade or a new deck. Maybeboards don't count."
|
||||
on={c.sparesOnly}
|
||||
onToggle={() => onChange({ sparesOnly: !c.sparesOnly })}
|
||||
/>
|
||||
)}
|
||||
<IconToggle
|
||||
icon={ICON_SPARE}
|
||||
label="Only spare copies"
|
||||
hint="Cards you own more copies of than your decks use — free for a trade or a new deck. Maybeboards don't count."
|
||||
on={c.sparesOnly}
|
||||
onToggle={() => onChange({ sparesOnly: !c.sparesOnly })}
|
||||
/>
|
||||
{!hideNotOwned && (
|
||||
<IconToggle
|
||||
icon={ICON_PACKAGE}
|
||||
|
||||
Reference in New Issue
Block a user