|
163 | 163 | } |
164 | 164 | } |
165 | 165 |
|
| 166 | + $: userHasSearchText = $search != ''; |
| 167 | + $: userHasSearchFilters = $filter != filterOptions[0]; |
| 168 | +
|
| 169 | + const removeSearchText = () => { |
| 170 | + $search = ''; |
| 171 | + }; |
| 172 | + const removeSearchFilters = () => { |
| 173 | + $filter = filterOptions[0]; |
| 174 | + }; |
| 175 | +
|
166 | 176 | export let hideMods: boolean = false; |
167 | 177 | </script> |
168 | 178 |
|
|
184 | 194 | {#if displayMods.length === 0 && !fetchingMods && !filteringMods && $hasFetchedMods} |
185 | 195 | <div class="flex flex-col h-full items-center justify-center"> |
186 | 196 | {#if mods.length !== 0} |
187 | | - {#if $filter != filterOptions[0]} |
188 | | - {#if $search != ''} |
189 | | - <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> |
| 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} |
190 | 200 | <button |
191 | 201 | class="btn variant-filled-primary mt-4" |
192 | | - on:click={() => { |
193 | | - $filter = filterOptions[0]; |
194 | | - }} |
| 202 | + on:click={removeSearchFilters} |
195 | 203 | > |
196 | 204 | <T defaultValue="Remove search filters" keyName="mods-list.remove-search-filters"/> |
197 | 205 | </button> |
198 | 206 | <button |
199 | 207 | class="btn variant-filled-primary mt-4" |
200 | | - on:click={() => { |
201 | | - $search = ''; |
202 | | - }} |
| 208 | + on:click={removeSearchText} |
203 | 209 | > |
204 | 210 | <T defaultValue="Remove search text" keyName="mods-list.remove-search-text"/> |
205 | 211 | </button> |
206 | 212 | {:else} |
207 | | - <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> |
208 | 213 | <button |
209 | 214 | class="btn variant-filled-primary mt-4" |
210 | | - on:click={() => { |
211 | | - $filter = filterOptions[0]; |
212 | | - }} |
| 215 | + on:click={removeSearchFilters} |
213 | 216 | > |
214 | 217 | <T defaultValue="Show all" keyName="mods-list.show-all"/> |
215 | 218 | </button> |
216 | 219 | {/if} |
217 | 220 | {:else} |
218 | | - <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> |
219 | 221 | <button |
220 | 222 | class="btn variant-filled-primary mt-4" |
221 | | - on:click={() => { |
222 | | - $search = ''; |
223 | | - $filter = filterOptions[0]; |
224 | | - }} |
| 223 | + on:click={removeSearchText} |
225 | 224 | > |
226 | 225 | <T defaultValue="Show all" keyName="mods-list.show-all"/> |
227 | 226 | </button> |
|
0 commit comments