diff --git a/modules/gui/src/components/SearchResults/SearchResults.svelte b/modules/gui/src/components/SearchPopupResults/SearchPopupResults.svelte similarity index 79% rename from modules/gui/src/components/SearchResults/SearchResults.svelte rename to modules/gui/src/components/SearchPopupResults/SearchPopupResults.svelte index 412ed6f..2444caa 100644 --- a/modules/gui/src/components/SearchResults/SearchResults.svelte +++ b/modules/gui/src/components/SearchPopupResults/SearchPopupResults.svelte @@ -9,16 +9,16 @@ import { installPackage } from '@api'; import type { AirtablePost } from '@tea/ui/types'; let term: string; - let packagesFound: GUIPackage[] = []; - + let packages: GUIPackage[] = []; let articles: AirtablePost[] = []; // news, blogs, etc let workshops: AirtablePost[] = []; // workshops, course + let loading = true; searchStore.subscribe((v) => { term = v; }); searchStore.packagesSearch.subscribe((pkgs) => { - packagesFound = pkgs; + packages = pkgs; }); searchStore.postsSearch.subscribe((posts) => { let partialArticles: AirtablePost[] = []; @@ -36,6 +36,8 @@ workshops = partialWorkshops; }); + searchStore.searching.subscribe((v) => (loading = v)); + const getCTALabel = (state: PackageStates): string => { return { [PackageStates.AVAILABLE]: 'INSTALL', @@ -44,24 +46,32 @@ [PackageStates.UNINSTALLED]: 'RE-INSTALL' }[state]; }; + + const onClose = () => { + term = ''; + };
-
-
- Showing search results for `{term}` + +
+
+
+
Showing search results for `{term}`
+ +
- +
- Top Package Results ({packagesFound.length}) + Top Package Results ({packages.length})
    - {#if packagesFound.length > 0} - {#each packagesFound as pkg} + {#if packages.length > 0} + {#each packages as pkg}
    {/each} - {:else} + {:else if loading} {#each Array(12) as _}
    @@ -92,7 +102,7 @@
{#if articles.length} - {:else} + {:else if loading}
@@ -102,7 +112,7 @@ {#if workshops.length} - {:else} + {:else if loading}
@@ -122,14 +132,23 @@ opacity: 0%; overflow: hidden; height: 0px; + z-index: 10; } + section > figure { + position: absolute; + left: 0; + right: 0; + top: 0; + bottom: 0; + } section.show { opacity: 100%; height: 100%; } section > div { + position: relative; height: 0%; transition: height 0.6s ease-in-out; overflow-y: scroll; diff --git a/modules/gui/src/libs/stores.ts b/modules/gui/src/libs/stores.ts index 3589f80..8abb466 100644 --- a/modules/gui/src/libs/stores.ts +++ b/modules/gui/src/libs/stores.ts @@ -119,6 +119,7 @@ function initPosts() { export const postsStore = initPosts(); function initSearchStore() { + const searching = writable(false); const { subscribe, set } = writable(''); const packagesSearch = writable([]); const postsSearch = writable([]); @@ -137,18 +138,29 @@ function initSearchStore() { return { term, + searching, packagesSearch, postsSearch, packagesFound, subscribe, search: async (term: string) => { - const [resultPkgs, resultPosts] = await Promise.all([ - packagesStore.search(term, 5), - postsStore.search(term, 10) - ]); - packagesSearch.set(resultPkgs); - postsSearch.set(resultPosts); - set(term); + searching.set(true); + try { + if (term) { + const [resultPkgs, resultPosts] = await Promise.all([ + packagesStore.search(term, 5), + postsStore.search(term, 10) + ]); + packagesSearch.set(resultPkgs); + postsSearch.set(resultPosts); + } else { + packagesSearch.set([]); + postsSearch.set([]); + } + set(term); + } finally { + searching.set(false); + } } }; } diff --git a/modules/gui/src/routes/+layout.svelte b/modules/gui/src/routes/+layout.svelte index 0afed1e..fa7a693 100644 --- a/modules/gui/src/routes/+layout.svelte +++ b/modules/gui/src/routes/+layout.svelte @@ -6,7 +6,7 @@ import FooterLinks from '$components/FooterLinks/FooterLinks.svelte'; import { backLink as backLinkStore } from '$libs/stores'; - import SearchResults from '$components/SearchResults/SearchResults.svelte'; + import SearchPopupResults from '$components/SearchPopupResults/SearchPopupResults.svelte'; let view: HTMLElement; @@ -37,7 +37,7 @@
- +
@@ -58,15 +58,17 @@ overflow-y: scroll; } + figure { + z-index: 0; + position: fixed; + top: 220px; + left: 240px; + right: 0px; + bottom: 0px; + background-image: url('/images/gui-background-grid.svg'); + } @media screen and (min-width: 1440px) { figure { - position: fixed; - z-index: 0; - top: 220px; - left: 240px; - right: 0px; - bottom: 0px; - background-image: url('/images/gui-background-grid.svg'); background-size: cover; background-repeat: repeat-y; } @@ -76,13 +78,6 @@ } @media screen and (max-width: 1440px) { figure { - position: fixed; - z-index: 0; - top: 220px; - left: 240px; - right: 0px; - bottom: 0px; - background-image: url('/images/gui-background-grid.svg'); background-size: contain; background-repeat: repeat; }