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

modify 'no results' text and add feedback link #129

Merged
merged 5 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions src/components/Search/PageFind.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,18 @@ const PageFind = ({
compatibility: url.searchParams.get("compatibility")?.split(","),
auto_super_resolution: url.searchParams.get("auto_super_resolution")?.split(","),
page: url.searchParams.get("page"),
searchrun: false,
};
});

const [page, setPage] = createSignal(
pathParams().page ? Number(pathParams().page) : 1
);

const [searchrun, setSearchRun] = createSignal(
pathParams().searchrun ? pathParams().searchrun: Boolean(false)
);

const [search, setSearch] = createSignal<{
query: string | null;
filters: Filters;
Expand Down Expand Up @@ -233,6 +238,7 @@ const PageFind = ({
window.history.replaceState({}, "", url.toString());
setRequest(search());
setPage(1);
setSearchRun(Boolean(true));
};

const [results] = createResource<Results, SearchQuery>(request, fetchResults);
Expand Down Expand Up @@ -304,6 +310,7 @@ const PageFind = ({
clearSearch={clearSearch}
setFilter={setFilter}
type={type}
searchRun={searchrun}
/>
</Show>
</div>
Expand Down
37 changes: 27 additions & 10 deletions src/components/Search/Results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ const Results = ({
clearSearch,
setFilter,
type,
searchRun,
}: {
page: Accessor<number>;
setPage: Setter<number>;
Expand All @@ -188,6 +189,7 @@ const Results = ({
clearSearch: () => void;
setFilter: (filter: string, selection: string, value: boolean) => void;
type: "applications" | "games";
searchRun: Accessor<boolean>
}) => {
const [paginatedResults, setPaginatedResults] = createSignal([]);

Expand Down Expand Up @@ -227,14 +229,24 @@ const Results = ({
setFilter(filter, selection, true);
};

return (
console.log(search().filters)

return (
<div class={`w-full my-6`}>
<Switch>
<Match when={results.loading}>
<div class="w-full flex flex-col items-center gap-3 p-10 ">
Loading results...
</div>
<Show
when={
search().query !== null ||
search().filters?.category?.length > 0
}
>
<div class="w-full flex flex-col items-center gap-3 p-10 ">
Loading results...
</div>
</Show>
</Match>

<Match when={results().results.length > 0}>
<div class="flex flex-col">
<ul>
Expand All @@ -256,22 +268,27 @@ const Results = ({
/>
</div>
</Match>
<Match when={results().results.length === 0}>

<Match when={
results().results.length === 0 &&
searchRun() === Boolean(true)
}>
<div class="w-full flex flex-col items-center gap-3 p-10">
No Results
<p class="text-center text-xl mb-2">
There is no information in our data about that. Why not contact the developer on their web site, or complete a feedback request <a class="underline text-blue-500" href="/contributing">here</a> for us to investigate.
</p>
<button
class="px-10 py-2 bg-white hover:bg-slate-300 border-white text-black font-bold border rounded-full"
onClick={clearSearch}
>
onClick={clearSearch}>
Clear search
</button>
</div>
</Match>

<Match
when={
request().query === null &&
request().filters?.category?.length === 0
search().query === null &&
search().filters?.category?.length === 0
}
>
<p class="text-center text-xl">
Expand Down