From 002964572c487e5062ce7045863d7bec9ec84130 Mon Sep 17 00:00:00 2001 From: Jelle van Snik Date: Fri, 18 Feb 2022 14:36:32 +0100 Subject: [PATCH] Added icon patch and better looking error+search suffix --- src/components/Buttons/IconPatch.tsx | 25 ++++++++++++++++ src/components/Icon.tsx | 4 ++- src/providers/list/temp/index.ts | 1 - src/views/SearchView.tsx | 43 +++++++++++++++++++++------- 4 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 src/components/Buttons/IconPatch.tsx diff --git a/src/components/Buttons/IconPatch.tsx b/src/components/Buttons/IconPatch.tsx new file mode 100644 index 00000000..67f18106 --- /dev/null +++ b/src/components/Buttons/IconPatch.tsx @@ -0,0 +1,25 @@ +import { Icon, Icons } from "components/Icon"; + +export interface IconPatchProps { + active?: boolean; + onClick?: () => void; + clickable?: boolean; + className?: string; + icon: Icons; +} + +export function IconPatch(props: IconPatchProps) { + return ( +
+
+ +
+
+ ); +} diff --git a/src/components/Icon.tsx b/src/components/Icon.tsx index 249f02d8..d714ca89 100644 --- a/src/components/Icon.tsx +++ b/src/components/Icon.tsx @@ -9,6 +9,7 @@ export enum Icons { CLAPPER_BOARD = "clapperBoard", FILM = "film", DRAGON = "dragon", + WARNING = "warning", } export interface IconProps { @@ -16,7 +17,7 @@ export interface IconProps { className?: string; } -const iconList = { +const iconList: Record = { search: ``, bookmark: ``, clock: ``, @@ -27,6 +28,7 @@ const iconList = { clapperBoard: ``, film: ``, dragon: ``, + warning: ``, }; export function Icon(props: IconProps) { diff --git a/src/providers/list/temp/index.ts b/src/providers/list/temp/index.ts index adb4e392..9530b7a1 100644 --- a/src/providers/list/temp/index.ts +++ b/src/providers/list/temp/index.ts @@ -24,7 +24,6 @@ export const tempScraper: MWMediaProvider = { }, async searchForMedia(query: MWQuery): Promise { - return []; }, }; diff --git a/src/views/SearchView.tsx b/src/views/SearchView.tsx index 0fbc0202..3c75e594 100644 --- a/src/views/SearchView.tsx +++ b/src/views/SearchView.tsx @@ -16,6 +16,7 @@ import { Tagline } from "components/Text/Tagline"; import { Title } from "components/Text/Title"; import { useDebounce } from "hooks/useDebounce"; import { useLoading } from "hooks/useLoading"; +import { IconPatch } from "components/Buttons/IconPatch"; function SearchLoading() { return ; @@ -26,18 +27,38 @@ function SearchSuffix(props: { total: number; resultsSize: number; }) { + const allFailed: boolean = props.fails === props.total; + const icon: Icons = allFailed ? Icons.WARNING : Icons.EYE_SLASH; + return ( -
- {props.fails > 0 ? ( -

- {props.fails}/{props.total} providers failed -

+
+ + + {/* standard suffix */} + {!allFailed ? ( +
+ {props.fails > 0 ? ( +

+ {props.fails}/{props.total} providers failed +

+ ) : null} + {props.resultsSize > 0 ? ( +

That's all we have — sorry

+ ) : ( +

We couldn't find anything — sorry

+ )} +
+ ) : null} + + {/* Error result */} + {allFailed ? ( +
+

All providers failed — whoops

+
) : null} - {props.resultsSize > 0 ? ( -

Thats all we have to show

- ) : ( -

No results to show

- )}
); } @@ -82,7 +103,7 @@ function SearchResultsView({ searchQuery }: { searchQuery: MWQuery }) { ) : null} {/* error */} - {error ?

All scrapers failed

: null} + {error ? : null} {/* Loading icon */} {loading ? : null}