Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #50 from pvdthings/SearchIcons
Browse files Browse the repository at this point in the history
Add icon for search and clear search
  • Loading branch information
dillonfagan authored Aug 28, 2023
2 parents 8865f32 + b13f0bf commit b3092fd
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/lib/components/TextInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
on:change
on:keyup={keyReleased}
class:invalid
class="px-4 py-2 brutal hovers outline-none {customClass}"
class="w-full px-4 py-2 pl-10 brutal hovers outline-none {customClass}"
/>

<style lang="postcss">
Expand Down
3 changes: 3 additions & 0 deletions src/lib/icons/magnifying-glass.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions src/lib/views/SearchInputView.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<script>
import { TextInput } from '$lib/components';
import { t } from '$lib/language/translate';
import { searchFilter } from '$lib/stores/catalog';
import XMarkIcon from '$lib/icons/x-mark.svg';
import SearchIcon from '$lib/icons/magnifying-glass.svg';
const clearSearch = () => {
$searchFilter = '';
};
</script>

<div class="relative">
<img src={SearchIcon} alt="searchIcon" class="w-6 h-6 absolute top-2.5 left-2 transform" />
<TextInput bind:value={$searchFilter} placeholder={$t('Input.Search')} />
{#if $searchFilter.length > 0}
<button class="btn btn-circle btn-sm btn-ghost absolute right-2 top-1.5" on:click={clearSearch}>
<img src={XMarkIcon} alt="searchIcon" class="w-5 h-5 absolute top-1.75 left-2.25 transform" />
</button>
{/if}
</div>
7 changes: 4 additions & 3 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
import ThingsView from '$lib/views/ThingsView.svelte';
import WishListButtonView from '$lib/views/WishListButtonView.svelte';
import CategoryChooserView from '$lib/views/CategoryChooserView.svelte';
import SearchInputView from '$lib/views/SearchInputView.svelte';
export let data;
$things = data.things;
$categories = data.categories;
$categories = data.categories;
onMount(() => {
const urlParams = new URLSearchParams(window.location.search);
$wishListFilter = urlParams.get('showWishList') === 'true';
$wishListFilter = urlParams.get('showWishList') === 'true';
});
</script>

Expand All @@ -29,7 +30,7 @@
<CategoryChooserView />
<WishListButtonView />
</div>
<TextInput bind:value={$searchFilter} placeholder={$t('Input.Search')} />
<SearchInputView />
</div>
<div class="mb-8">
{#if $filteredThings.length > 0}
Expand Down

0 comments on commit b3092fd

Please sign in to comment.