mirror of
https://github.com/ivabus/gui
synced 2025-06-07 15:50:27 +03:00
#36 initialize search
This commit is contained in:
parent
74ffe61951
commit
a3be80627c
2 changed files with 22 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
import { open } from '@tauri-apps/api/shell';
|
import { open } from '@tauri-apps/api/shell';
|
||||||
import { appWindow } from '@tauri-apps/api/window';
|
import { appWindow } from '@tauri-apps/api/window';
|
||||||
|
import { searchStore } from '$libs/stores';
|
||||||
import SearchInput from '@tea/ui/SearchInput/SearchInput.svelte';
|
import SearchInput from '@tea/ui/SearchInput/SearchInput.svelte';
|
||||||
import Button from '@tea/ui/Button/Button.svelte';
|
import Button from '@tea/ui/Button/Button.svelte';
|
||||||
|
|
||||||
|
@ -63,7 +64,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
const onSearch = (term: string) => {
|
const onSearch = (term: string) => {
|
||||||
console.log('navbar search:', term);
|
searchStore.search(term);
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -60,3 +60,23 @@ function initPackagesReviewStore() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const packagesReviewStore = initPackagesReviewStore();
|
export const packagesReviewStore = initPackagesReviewStore();
|
||||||
|
|
||||||
|
function initSearchStore() {
|
||||||
|
const { subscribe, set } = writable<string>('');
|
||||||
|
// 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();
|
||||||
|
|
Loading…
Reference in a new issue