Skip to content

Commit ad9aa85

Browse files
Selectively clear search text or filters (#289 -> #326)
* Keeping input on Show All button press * Clarifying text * Fixing spacing * Adding dedicated button layout * translating and fixing * Linting fix * Deduplication --------- Co-authored-by: Rob B <[email protected]>
1 parent 868f590 commit ad9aa85

File tree

1 file changed

+41
-10
lines changed

1 file changed

+41
-10
lines changed

frontend/src/lib/components/mods-list/ModsList.svelte

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@
163163
}
164164
}
165165
166+
$: userHasSearchText = $search != '';
167+
$: userHasSearchFilters = $filter != filterOptions[0];
168+
169+
const removeSearchText = () => {
170+
$search = '';
171+
};
172+
const removeSearchFilters = () => {
173+
$filter = filterOptions[0];
174+
};
175+
166176
export let hideMods: boolean = false;
167177
</script>
168178

@@ -184,16 +194,37 @@
184194
{#if displayMods.length === 0 && !fetchingMods && !filteringMods && $hasFetchedMods}
185195
<div class="flex flex-col h-full items-center justify-center">
186196
{#if mods.length !== 0}
187-
<p class="text-xl text-center text-surface-400-700-token"><T defaultValue="No mods matching your filters" keyName="mods-list.no-mods-filtered"/></p>
188-
<button
189-
class="btn variant-filled-primary mt-4"
190-
on:click={() => {
191-
$search = '';
192-
$filter = filterOptions[0];
193-
}}
194-
>
195-
<T defaultValue="Show all" keyName="mods-list.show-all"/>
196-
</button>
197+
<p class="text-xl text-center text-surface-400-700-token"><T defaultValue="No mods matching your search" keyName="mods-list.no-mods-filtered"/></p>
198+
{#if userHasSearchFilters}
199+
{#if userHasSearchText}
200+
<button
201+
class="btn variant-filled-primary mt-4"
202+
on:click={removeSearchFilters}
203+
>
204+
<T defaultValue="Remove search filters" keyName="mods-list.remove-search-filters"/>
205+
</button>
206+
<button
207+
class="btn variant-filled-primary mt-4"
208+
on:click={removeSearchText}
209+
>
210+
<T defaultValue="Remove search text" keyName="mods-list.remove-search-text"/>
211+
</button>
212+
{:else}
213+
<button
214+
class="btn variant-filled-primary mt-4"
215+
on:click={removeSearchFilters}
216+
>
217+
<T defaultValue="Show all" keyName="mods-list.show-all"/>
218+
</button>
219+
{/if}
220+
{:else}
221+
<button
222+
class="btn variant-filled-primary mt-4"
223+
on:click={removeSearchText}
224+
>
225+
<T defaultValue="Show all" keyName="mods-list.show-all"/>
226+
</button>
227+
{/if}
197228
{:else}
198229
<p class="text-xl text-center text-surface-400-700-token"><T defaultValue="No mods found" keyName="mods-list.no-mods-found"/></p>
199230
{/if}

0 commit comments

Comments
 (0)