Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: min search error message #186

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"me-dutour-mathieu.vscode-github-actions",
"eamodio.gitlens",
"GitHub.copilot",
"GitHub.vscode-pull-request-github"
"GitHub.vscode-pull-request-github",
"medo64.render-crlf"
]
}
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"postinstall": "svelte-kit sync",
"start": "svelte-kit start",
"format": "prettier --write . && eslint . --fix",
"translations": "sh ./download_translations.sh"
"translations": "bash ./download_translations.sh"
},
"dependencies": {
"@felte/core": "^1.4.3",
Expand Down
62 changes: 40 additions & 22 deletions src/lib/components/mods/ModGrid.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,19 @@
let totalMods: number;

let searchField = search;
let searchDisabled = true;
let searchButtonClass = 'variant-filled-primary';
const showPagination: boolean = $mods && !$mods.error && !$mods.fetching;
knightzac19 marked this conversation as resolved.
Show resolved Hide resolved

let timer: number;
$: {
if (searchField.length > 2) {
searchDisabled = false;
searchButtonClass = 'variant-filled-primary';
} else {
searchDisabled = true;
searchButtonClass = 'variant-filled-surface';
}
knightzac19 marked this conversation as resolved.
Show resolved Hide resolved
clearTimeout(timer);
timer = setTimeout(() => {
if (searchField && searchField.length > 2) {
Expand All @@ -70,7 +80,7 @@
$: if (browser) {
const url = new URL(window.location.origin + window.location.pathname);
url.searchParams.append('p', page.toString());
searchField !== '' && searchField !== null && url.searchParams.append('q', searchField);
searchField.length > 2 && searchField !== '' && searchField !== null && url.searchParams.append('q', searchField);
goto(url.toString(), { keepFocus: true });
}

Expand Down Expand Up @@ -149,7 +159,10 @@
class="border-0 bg-transparent p-1.5 ring-0"
name="search"
placeholder={$t('search.placeholder-text')} />
<button class="material-icons variant-filled-primary">arrow_forward</button>
<button
class="material-icons {searchButtonClass}"
disabled={searchDisabled}
title={searchDisabled ? $t('search.disabled') : ''}>arrow_forward</button>
</div>
</div>
{#if tagsOpen}
Expand Down Expand Up @@ -178,16 +191,17 @@
{#if newMod && $user !== null}
<a class="variant-ghost-primary btn self-end" href="{base}/new-mod">{$t('mods.new')}</a>
{/if}

<div class="self-end">
<Paginator
bind:settings={paginationSettings}
showFirstLastButtons={true}
showPreviousNextButtons={true}
on:page={(p) => (page = p.detail)}
on:amount={(p) => (perPage = p.detail)}
controlVariant="variant-filled-surface" />
</div>
{#if showPagination}
<div class="self-end">
<Paginator
bind:settings={paginationSettings}
showFirstLastButtons={true}
showPreviousNextButtons={true}
on:page={(p) => (page = p.detail)}
on:amount={(p) => (perPage = p.detail)}
controlVariant="variant-filled-surface" />
</div>
{/if}
</div>
</div>

Expand All @@ -197,6 +211,8 @@
<FicsitCard fake />
{/each}
</div>
{:else if $mods.error && $mods.error.message.includes("'Search' failed on the 'min' tag")}
{$t('search.failed.query-too-short')}
knightzac19 marked this conversation as resolved.
Show resolved Hide resolved
{:else if $mods.error}
<p>Oh no... {$mods.error.message}</p>
{:else}
Expand All @@ -207,17 +223,19 @@
</div>
{/if}

<div class="ml-auto mt-5 flex justify-end">
<div>
<Paginator
bind:settings={paginationSettings}
showFirstLastButtons={true}
showPreviousNextButtons={true}
on:page={(p) => (page = p.detail)}
on:amount={(p) => (perPage = p.detail)}
controlVariant="variant-filled-surface" />
{#if showPagination}
<div class="ml-auto mt-5 flex justify-end">
<div>
<Paginator
bind:settings={paginationSettings}
showFirstLastButtons={true}
showPreviousNextButtons={true}
on:page={(p) => (page = p.detail)}
on:amount={(p) => (perPage = p.detail)}
controlVariant="variant-filled-surface" />
</div>
</div>
</div>
{/if}

<style lang="postcss">
* :global(.search-paper) {
Expand Down