Add search button to search bar (#97)

This commit is contained in:
Brahim Hadriche authored and GitHub committed 2023-06-29 14:11:53 -04:00
1 parent c705ce86d3
commit 191b88f4d0
2 files changed
+31 -18

No files matched your search

@@ -0,0 +1,6 @@
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 24 24" preserveAspectRatio="xMidYMid meet" focusable="false" style="pointer-events: none; display: block; width: 100%; height: 100%;">
<g class="fill-current">
<path d="m20.87 20.17-5.59-5.59C16.35 13.35 17 11.75 17 10c0-3.87-3.13-7-7-7s-7 3.13-7 7 3.13 7 7 7c1.75 0 3.35-.65 4.58-1.71l5.59 5.59.7-.71zM10 16c-3.31 0-6-2.69-6-6s2.69-6 6-6 6 2.69 6 6-2.69 6-6 6z"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 528 B

+25 -18
View File
@@ -1,9 +1,9 @@
<script lang="ts"> <script lang="ts">
import { onMount } from "svelte";
import { InvidiousApi } from "./InvidiousApi"; import { InvidiousApi } from "./InvidiousApi";
import { PlayletApi } from "./PlayletApi"; import { PlayletApi } from "./PlayletApi";
import { playletStateStore, searchHistoryStore } from "./Stores"; import { playletStateStore, searchHistoryStore } from "./Stores";
import VideoCell from "./VideoCell.svelte"; import VideoCell from "./VideoCell.svelte";
import SearchThinIcon from "../assets/search-thin-icon.svg.svelte";
export let visibility: boolean; export let visibility: boolean;
@@ -90,23 +90,30 @@
await searchVideos(); await searchVideos();
}} }}
> >
<input <div class="join w-full border border-neutral rounded-full">
type="search" <input
dir="auto" type="search"
placeholder="Search..." dir="auto"
class="input w-full border border-neutral rounded-full" placeholder="Search..."
bind:this={searchBox} class="join-item input w-full border border-neutral rounded-full"
bind:value={searchBoxText} bind:this={searchBox}
on:input={searchSuggestions} bind:value={searchBoxText}
on:focus={searchSuggestions} on:input={searchSuggestions}
on:blur={() => { on:focus={searchSuggestions}
// A delay before clearing the suggestions allows the user to click on a suggestion on:blur={() => {
// Clicking the suggestion will trigger the blur event immediately, and the search won't happen // A delay before clearing the suggestions allows the user to click on a suggestion
setTimeout(() => { // Clicking the suggestion will trigger the blur event immediately, and the search won't happen
suggestions = { suggestions: [] }; setTimeout(() => {
}, 200); suggestions = { suggestions: [] };
}} }, 200);
/> }}
/>
<button class="join-item btn" on:click={searchVideos}>
<div class="h-6">
<SearchThinIcon />
</div>
</button>
</div>
{#if suggestions.suggestions.length > 0} {#if suggestions.suggestions.length > 0}
<ul <ul
class="dropdown-content menu z-10 p-2 shadow-xl bg-base-200 rounded-box" class="dropdown-content menu z-10 p-2 shadow-xl bg-base-200 rounded-box"