Skip to content

Commit

Permalink
added search functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Der-Penz committed Aug 12, 2023
1 parent ffbe93c commit 1316b29
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/css/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,10 @@ footer a:hover {
text-align: center;
}
}

input[type=text]{
border-radius: 0.5em;
margin: 0.5em;
padding: 0.5em;
border-color: #2c3e50;
}
15 changes: 13 additions & 2 deletions src/routes/icons/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<main>
<h1>Available Font-Awesome v4 Icons</h1>

<input type="text" name="search" placeholder="Search Icon" on:input={(e) => debounce(e.currentTarget.value)}>
<table>
<thead>
<tr>
Expand All @@ -15,7 +15,7 @@
<th>Example Snippet</th>
</tr>
</thead>
{#each data as icon}
{#each filteredIcons as icon}
<tr>
<td><Icon data={getIcon(icon.fileName)} scale={5} /></td>
<td>{icon.fileName}</td>
Expand Down Expand Up @@ -52,4 +52,15 @@
function getIcon(name: string): IconType {
return (icons as Record<string, IconType>)[name];
}
let searchValue = '';
let timer : number;
const debounce = (v : string) => {
clearTimeout(timer);
timer = setTimeout(() => {
searchValue = v;
}, 750);
}
$: filteredIcons = data.filter(icon => icon.iconName.toLowerCase().startsWith(searchValue))
</script>

0 comments on commit 1316b29

Please sign in to comment.