Skip to content

Commit 1316b29

Browse files
committed
added search functionality
1 parent ffbe93c commit 1316b29

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

src/css/global.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,10 @@ footer a:hover {
151151
text-align: center;
152152
}
153153
}
154+
155+
input[type=text]{
156+
border-radius: 0.5em;
157+
margin: 0.5em;
158+
padding: 0.5em;
159+
border-color: #2c3e50;
160+
}

src/routes/icons/+page.svelte

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<main>
77
<h1>Available Font-Awesome v4 Icons</h1>
8-
8+
<input type="text" name="search" placeholder="Search Icon" on:input={(e) => debounce(e.currentTarget.value)}>
99
<table>
1010
<thead>
1111
<tr>
@@ -15,7 +15,7 @@
1515
<th>Example Snippet</th>
1616
</tr>
1717
</thead>
18-
{#each data as icon}
18+
{#each filteredIcons as icon}
1919
<tr>
2020
<td><Icon data={getIcon(icon.fileName)} scale={5} /></td>
2121
<td>{icon.fileName}</td>
@@ -52,4 +52,15 @@
5252
function getIcon(name: string): IconType {
5353
return (icons as Record<string, IconType>)[name];
5454
}
55+
56+
let searchValue = '';
57+
let timer : number;
58+
const debounce = (v : string) => {
59+
clearTimeout(timer);
60+
timer = setTimeout(() => {
61+
searchValue = v;
62+
}, 750);
63+
}
64+
65+
$: filteredIcons = data.filter(icon => icon.iconName.toLowerCase().startsWith(searchValue))
5566
</script>

0 commit comments

Comments
 (0)