2024-07-25 20:02:15 -04:00
|
|
|
<script lang="ts">
|
|
|
|
|
|
|
|
import {AniListSearch} from "../wailsjs/go/main/App";
|
|
|
|
import type {AniSearchList} from "./anilist/types/AniListTypes";
|
|
|
|
import {GetAniListSingleItemAndOpenModal} from "./GetAniListSingleItemAndOpenModal.svelte";
|
|
|
|
|
|
|
|
let aniSearch = ""
|
|
|
|
let aniListSearch: AniSearchList
|
|
|
|
let aniListSearchActive = false
|
|
|
|
|
|
|
|
function runAniListSearch(): void {
|
|
|
|
AniListSearch(aniSearch).then(result => {
|
2024-07-27 21:18:03 -04:00
|
|
|
console.log(result.data.Page.media[5])
|
2024-07-25 20:02:15 -04:00
|
|
|
aniListSearch = result
|
|
|
|
aniListSearchActive = true
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<div>
|
2024-07-25 21:11:18 -04:00
|
|
|
<div class="max-w-md mx-auto">
|
2024-07-25 20:02:15 -04:00
|
|
|
<div class="flex">
|
2024-07-25 21:11:18 -04:00
|
|
|
<label for="anime-search" class="mb-2 text-sm font-medium text-gray-900 sr-only dark:text-white">Find
|
|
|
|
Anime</label>
|
2024-07-25 20:02:15 -04:00
|
|
|
<div class="relative w-full">
|
2024-07-25 21:11:18 -04:00
|
|
|
<input type="search" id="anime-search" bind:value={aniSearch}
|
|
|
|
class="rounded-s-lg block p-2.5 w-full z-20 text-sm text-gray-900 bg-gray-50 rounded-e-lg border-s-gray-50 border-s-2 border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-s-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:border-blue-500"
|
|
|
|
placeholder="Search for Anime" required/>
|
|
|
|
<button id="aniListSearchButton" data-dropdown-toggle="aniListSearch"
|
2024-07-26 16:48:06 -04:00
|
|
|
data-dropdown-offset-distance="0"
|
|
|
|
data-dropdown-offset-skidding="-50"
|
2024-07-25 21:11:18 -04:00
|
|
|
data-dropdown-placement="bottom"
|
|
|
|
class="absolute top-0 end-0 h-full p-2.5 text-sm font-medium text-white bg-blue-700 rounded-e-lg border border-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
|
2024-07-26 16:48:06 -04:00
|
|
|
on:click={() => {if(aniSearch.length > 0) runAniListSearch()}}>
|
2024-07-25 21:11:18 -04:00
|
|
|
<svg class="w-4 h-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none"
|
|
|
|
viewBox="0 0 20 20">
|
|
|
|
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
|
|
d="m19 19-4-4m0-7A7 7 0 1 1 1 8a7 7 0 0 1 14 0Z"/>
|
2024-07-25 20:02:15 -04:00
|
|
|
</svg>
|
|
|
|
<span class="sr-only">Search</span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-07-25 21:11:18 -04:00
|
|
|
</div>
|
2024-07-25 20:02:15 -04:00
|
|
|
|
2024-07-26 16:48:06 -04:00
|
|
|
<div id="aniListSearch" class="z-10 hidden bg-white rounded-lg shadow w-80 dark:bg-gray-700">
|
2024-07-25 21:11:18 -04:00
|
|
|
{#if aniListSearchActive}
|
2024-07-26 16:48:06 -04:00
|
|
|
<ul class="h-56 w-full py-2 overflow-y-auto text-gray-700 dark:text-gray-200"
|
2024-07-25 21:11:18 -04:00
|
|
|
aria-labelledby="aniListSearchButton">
|
|
|
|
{#each aniListSearch.data.Page.media as media}
|
2024-07-26 16:48:06 -04:00
|
|
|
<li class="w-full">
|
|
|
|
<button on:click={() => {
|
2024-07-27 21:18:03 -04:00
|
|
|
GetAniListSingleItemAndOpenModal(media.id, false)
|
2024-07-26 16:48:06 -04:00
|
|
|
}}
|
|
|
|
class="flex w-full items-start p-1 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white rounded-lg">
|
|
|
|
<img class="rounded-bl-lg rounded-tl-lg max-w-24 max-h-24" src={media.coverImage.large}
|
2024-07-25 21:11:18 -04:00
|
|
|
alt="{media.title.english === '' || media.title.english === null ? media.title.romaji : media.title.english} Cover">
|
2024-07-26 16:48:06 -04:00
|
|
|
<p class="bg-gray-800 text-left w-full h-24 p-2 rounded-tr-lg rounded-br-lg">{media.title.english === '' || media.title.english === null ? media.title.romaji : media.title.english }</p>
|
2024-07-25 21:11:18 -04:00
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
{/each}
|
|
|
|
</ul>
|
2024-07-26 16:48:06 -04:00
|
|
|
{:else if aniSearch.length === 0}
|
|
|
|
<div class="m-4">Please enter a search term...</div>
|
2024-07-25 21:11:18 -04:00
|
|
|
{/if}
|
2024-07-25 20:02:15 -04:00
|
|
|
<a href="#"
|
|
|
|
class="flex items-center p-3 text-sm font-medium text-blue-600 border-t border-gray-200 rounded-b-lg bg-gray-50 dark:border-gray-600 hover:bg-gray-100 dark:bg-gray-700 dark:hover:bg-gray-600 dark:text-blue-500 hover:underline">
|
|
|
|
<svg class="w-4 h-4 me-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor"
|
|
|
|
viewBox="0 0 20 18">
|
|
|
|
<path d="M6.5 9a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9ZM8 10H5a5.006 5.006 0 0 0-5 5v2a1 1 0 0 0 1 1h11a1 1 0 0 0 1-1v-2a5.006 5.006 0 0 0-5-5Zm11-3h-2V5a1 1 0 0 0-2 0v2h-2a1 1 0 1 0 0 2h2v2a1 1 0 0 0 2 0V9h2a1 1 0 1 0 0-2Z"/>
|
|
|
|
</svg>
|
|
|
|
Add new user
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|