diff --git a/modules/gui/src/components/NavBar/NavBar.svelte b/modules/gui/src/components/NavBar/NavBar.svelte index 7a3d3ed..d50a78b 100644 --- a/modules/gui/src/components/NavBar/NavBar.svelte +++ b/modules/gui/src/components/NavBar/NavBar.svelte @@ -2,6 +2,7 @@ import { page } from '$app/stores'; import { open } from '@tauri-apps/api/shell'; import { appWindow } from '@tauri-apps/api/window'; + import { searchStore } from '$libs/stores'; import SearchInput from '@tea/ui/SearchInput/SearchInput.svelte'; import Button from '@tea/ui/Button/Button.svelte'; @@ -63,7 +64,7 @@ }); const onSearch = (term: string) => { - console.log('navbar search:', term); + searchStore.search(term); }; diff --git a/modules/gui/src/libs/stores.ts b/modules/gui/src/libs/stores.ts index 60dbe7b..c267b52 100644 --- a/modules/gui/src/libs/stores.ts +++ b/modules/gui/src/libs/stores.ts @@ -60,3 +60,23 @@ function initPackagesReviewStore() { } export const packagesReviewStore = initPackagesReviewStore(); + +function initSearchStore() { + const { subscribe, set } = writable(''); + // TODO: + // add fuse.js index here: packages, articles/posts, etc + // define fuse.js shape { tags:[], desc:string, title: string, thumb_image_url: string } + // should use algolia if user is somehow online + + let term = ''; + + subscribe((v) => (term = v)); + + return { + term, + subscribe, + search: (term: string) => set(term) + }; +} + +export const searchStore = initSearchStore();