This commit is contained in:
Eric Liu 2020-09-13 14:05:51 -07:00
commit d250a0c3cc
16 changed files with 167 additions and 155 deletions

View file

@ -1,41 +1,41 @@
import { writable } from 'svelte/store';
import { writable } from "svelte/store";
const data = [
{
href: '#',
title: 'Test title search 1',
menu: 'Test menu 1',
description: 'This is a description for seach #1'
href: "#",
title: "Test title search 1",
menu: "Test menu 1",
description: "This is a description for seach #1",
},
{
href: '#',
title: 'Changing text to simulate search',
menu: 'Test menu 2',
description: 'This is a description for seach #2'
href: "#",
title: "Changing text to simulate search",
menu: "Test menu 2",
description: "This is a description for seach #2",
},
{
href: '#',
title: 'More testing texts',
menu: 'Test menu 3',
description: 'This is a description for seach #3'
href: "#",
title: "More testing texts",
menu: "Test menu 3",
description: "This is a description for seach #3",
},
{
href: '#',
title: 'We can find here another test text',
menu: 'Test menu 4',
description: 'This is a description for seach #4'
}
href: "#",
title: "We can find here another test text",
menu: "Test menu 4",
description: "This is a description for seach #4",
},
];
const globalStore = writable(undefined);
const store = {
subscribe: globalStore.subscribe,
search: searchString => {
search: (searchString) => {
if (searchString.length > 1) {
let resultSearch = [];
data.forEach(item => {
data.forEach((item) => {
if (item.title.toLowerCase().includes(searchString.toLowerCase())) {
resultSearch.push(item);
}
@ -52,7 +52,7 @@ const store = {
},
clear: () => {
globalStore.set(undefined);
}
},
};
export default store;