got search dropdown mostly finished

From here I just want to polish up the looks and make it cleaner and
bigger
This commit is contained in:
John O'Keefe 2024-07-25 21:11:18 -04:00
parent 5a8b64b610
commit d89121a4de
4 changed files with 46 additions and 142 deletions

View File

@ -8,5 +8,6 @@
<body> <body>
<div id="app"></div> <div id="app"></div>
<script src="./src/main.ts" type="module"></script> <script src="./src/main.ts" type="module"></script>
<script src="./node_modules/flowbite/dist/flowbite.js"></script>
</body> </body>
</html> </html>

View File

@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
import {GetAniListSingleItemAndOpenModal, anime, title, anilistModal} from "./GetAniListSingleItemAndOpenModal.svelte"; import {GetAniListSingleItemAndOpenModal, title, anilistModal} from "./GetAniListSingleItemAndOpenModal.svelte";
import { import {
AniListSearch, AniListSearch,
GetAniListUserWatchingList GetAniListUserWatchingList
@ -11,22 +11,22 @@
import ChangeDataDialogue from "./ChangeDataDialogue.svelte"; import ChangeDataDialogue from "./ChangeDataDialogue.svelte";
let aniSearch = "" // let aniSearch = ""
let aniListSearch: AniSearchList // let aniListSearch: AniSearchList
let aniListSearchActive = false // let aniListSearchActive = false
let aniListLoggedIn = false let aniListLoggedIn = false
let aniListWatchlist: AniListCurrentUserWatchList let aniListWatchlist: AniListCurrentUserWatchList
let page = 1 let page = 1
let perPage = 20 let perPage = 20
const size = "xl" const size = "xl"
//
function runAniListSearch(): void { // function runAniListSearch(): void {
AniListSearch(aniSearch).then(result => { // AniListSearch(aniSearch).then(result => {
aniListSearch = result // aniListSearch = result
aniListSearchActive = true // aniListSearchActive = true
}) // })
} // }
function anilistGetUserWatchlist(): void { function anilistGetUserWatchlist(): void {
GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((result) => { GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((result) => {
@ -41,32 +41,7 @@
<Header /> <Header />
<main> <main>
<div class="input-box" id="aniSearch">
<input autocomplete="off" bind:value={aniSearch} class="input text-black" id="aniSearchInput" type="text"/>
<button class="text-gray-800 dark:text-white hover:bg-gray-50 focus:ring-4 focus:ring-gray-300 font-medium rounded-lg text-sm px-4 lg:px-5 py-2 lg:py-2.5 mr-2 dark:hover:bg-gray-700 focus:outline-none dark:focus:ring-gray-800" on:click={runAniListSearch}>Search AniList</button>
</div>
{#if aniListSearchActive}
<div class="mx-auto max-w-2xl px-4 py-16 sm:px-6 sm:py-24 lg:max-w-7xl lg:px-8">
<h1>Your Search Results</h1>
<div class="grid grid-cols-1 gap-x-6 gap-y-10 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 xl:gap-x-8">
{#each aniListSearch.data.Page.media as media}
<button on:click={() => GetAniListSingleItemAndOpenModal(media.id)} class="group">
<!-- <div class="aspect-h-1 aspect-w-1 w-full overflow-hidden rounded-lg bg-gray-200 xl:aspect-h-8 xl:aspect-w-7">-->
<div class="justify-center rounded-lg bg-gray-200">
<img src={media.coverImage.large} alt="anime cover"/>
</div>
<h3 class="mt-4 text-sm text-white-700">{
media.title.english === "" ?
media.title.romaji :
media.title.english
}</h3>
</button>
{/each}
</div>
</div>
{/if}
<button class="btn" on:click={anilistGetUserWatchlist}>Login to AniList</button> <button class="btn" on:click={anilistGetUserWatchlist}>Login to AniList</button>
{#if aniListLoggedIn} {#if aniListLoggedIn}

View File

@ -9,14 +9,12 @@
<div class="flex flex-wrap justify-between items-center mx-auto max-w-screen-xl"> <div class="flex flex-wrap justify-between items-center mx-auto max-w-screen-xl">
<a href="#" class="flex items-center"> <a href="#" class="flex items-center">
<img src={logo} class="mr-3 h-6 sm:h-9" alt="AniTrack Logo" /> <img src={logo} class="mr-3 h-6 sm:h-9" alt="AniTrack Logo" />
<!-- <span class="self-center text-xl font-semibold whitespace-nowrap dark:text-white">AniTrack</span>-->
</a> </a>
<div class="flex items-center lg:order-2"> <div class="flex items-center lg:order-2">
<Search /> <Search />
<a href="#" class="text-gray-800 dark:text-white hover:bg-gray-50 focus:ring-4 focus:ring-gray-300 font-medium rounded-lg text-sm px-4 lg:px-5 py-2 lg:py-2.5 mr-2 dark:hover:bg-gray-700 focus:outline-none dark:focus:ring-gray-800">Log in AniList</a> <a href="#" class="text-gray-800 dark:text-white hover:bg-gray-50 focus:ring-4 focus:ring-gray-300 font-medium rounded-lg text-sm px-4 lg:px-5 py-2 lg:py-2.5 mr-2 dark:hover:bg-gray-700 focus:outline-none dark:focus:ring-gray-800">Log in AniList</a>
<!-- <a href="#" class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-4 lg:px-5 py-2 lg:py-2.5 mr-2 dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none dark:focus:ring-blue-800">Get started</a>-->
<button data-collapse-toggle="mobile-menu-2" type="button" class="inline-flex items-center p-2 ml-1 text-sm text-gray-500 rounded-lg lg:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600" aria-controls="mobile-menu-2" aria-expanded="false"> <button data-collapse-toggle="mobile-menu-2" type="button" class="inline-flex items-center p-2 ml-1 text-sm text-gray-500 rounded-lg lg:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600" aria-controls="mobile-menu-2" aria-expanded="false">
<span class="sr-only">Open main menu</span> <span class="sr-only">Open main menu</span>
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 15a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z" clip-rule="evenodd"></path></svg> <svg class="w-6 h-6" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 15a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z" clip-rule="evenodd"></path></svg>
@ -25,9 +23,9 @@
</div> </div>
<div class="hidden justify-between items-center w-full lg:flex lg:w-auto lg:order-1" id="mobile-menu-2"> <div class="hidden justify-between items-center w-full lg:flex lg:w-auto lg:order-1" id="mobile-menu-2">
<ul class="flex flex-col mt-4 font-medium lg:flex-row lg:space-x-8 lg:mt-0"> <ul class="flex flex-col mt-4 font-medium lg:flex-row lg:space-x-8 lg:mt-0">
<li> <!-- <li>-->
<a href="#" class="block py-2 pr-4 pl-3 text-white rounded bg-blue-700 lg:bg-transparent lg:text-blue-700 lg:p-0 dark:text-white" aria-current="page">Home</a> <!-- <a href="#" class="block py-2 pr-4 pl-3 text-white rounded bg-blue-700 lg:bg-transparent lg:text-blue-700 lg:p-0 dark:text-white" aria-current="page">Home</a>-->
</li> <!-- </li>-->
<!-- <li>--> <!-- <li>-->
<!-- <a href="#" class="block py-2 pr-4 pl-3 text-gray-700 border-b border-gray-100 hover:bg-gray-50 lg:hover:bg-transparent lg:border-0 lg:hover:text-blue-700 lg:p-0 dark:text-gray-400 lg:dark:hover:text-white dark:hover:bg-gray-700 dark:hover:text-white lg:dark:hover:bg-transparent dark:border-gray-700">Company</a>--> <!-- <a href="#" class="block py-2 pr-4 pl-3 text-gray-700 border-b border-gray-100 hover:bg-gray-50 lg:hover:bg-transparent lg:border-0 lg:hover:text-blue-700 lg:p-0 dark:text-gray-400 lg:dark:hover:text-white dark:hover:bg-gray-700 dark:hover:text-white lg:dark:hover:bg-transparent dark:border-gray-700">Company</a>-->
<!-- </li>--> <!-- </li>-->

View File

@ -10,6 +10,7 @@
function runAniListSearch(): void { function runAniListSearch(): void {
AniListSearch(aniSearch).then(result => { AniListSearch(aniSearch).then(result => {
console.log(result)
aniListSearch = result aniListSearch = result
aniListSearchActive = true aniListSearchActive = true
}) })
@ -19,116 +20,45 @@
<div> <div>
<div class="input-box" id="aniSearch"> <div class="max-w-md mx-auto">
<input autocomplete="off" bind:value={aniSearch} class="input text-black" id="aniSearchInput" type="text"/>
<button class="text-gray-800 dark:text-white hover:bg-gray-50 focus:ring-4 focus:ring-gray-300 font-medium rounded-lg text-sm px-4 lg:px-5 py-2 lg:py-2.5 mr-2 dark:hover:bg-gray-700 focus:outline-none dark:focus:ring-gray-800" on:click={runAniListSearch}>Search AniList</button>
</div>
{#if aniListSearchActive}
<div class="mx-auto max-w-2xl px-4 py-16 sm:px-6 sm:py-24 lg:max-w-7xl lg:px-8">
<h1>Your Search Results</h1>
<div class="grid grid-cols-1 gap-x-6 gap-y-10 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 xl:gap-x-8">
{#each aniListSearch.data.Page.media as media}
<button on:click={() => GetAniListSingleItemAndOpenModal(media.id)} class="group">
<div class="justify-center rounded-lg bg-gray-200">
<img src={media.coverImage.large} alt="anime cover"/>
</div>
<h3 class="mt-4 text-sm text-white-700">{
media.title.english === "" ?
media.title.romaji :
media.title.english
}</h3>
</button>
{/each}
</div>
</div>
{/if}
<form class="max-w-md mx-auto">
<div class="flex"> <div class="flex">
<label for="anime-search" class="mb-2 text-sm font-medium text-gray-900 sr-only dark:text-white">Find Anime</label> <label for="anime-search" class="mb-2 text-sm font-medium text-gray-900 sr-only dark:text-white">Find
Anime</label>
<div class="relative w-full"> <div class="relative w-full">
<input type="search" id="anime-search" 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 /> <input type="search" id="anime-search" bind:value={aniSearch}
<button type="submit" id="aniListSearchButton" data-dropdown-toggle="aniListSearch" data-dropdown-placement="bottom" 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"
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"> placeholder="Search for Anime" required/>
<svg class="w-4 h-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20"> <button id="aniListSearchButton" data-dropdown-toggle="aniListSearch"
<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"/> 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"
on:click={runAniListSearch}>
<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"/>
</svg> </svg>
<span class="sr-only">Search</span> <span class="sr-only">Search</span>
</button> </button>
</div> </div>
</div> </div>
</form> </div>
<div id="aniListSearch" class="z-10 hidden bg-white rounded-lg shadow w-60 dark:bg-gray-700"> <div id="aniListSearch" class="z-10 hidden bg-white rounded-lg shadow w-60 dark:bg-gray-700">
<ul class="h-48 py-2 overflow-y-auto text-gray-700 dark:text-gray-200" aria-labelledby="aniListSearchButton"> {#if aniListSearchActive}
<li> <ul class="h-48 py-2 overflow-y-auto text-gray-700 dark:text-gray-200"
<a href="#" aria-labelledby="aniListSearchButton">
class="flex items-center px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white"> {#each aniListSearch.data.Page.media as media}
<img class="w-6 h-6 me-2 rounded-full" src="/docs/images/people/profile-picture-1.jpg" <li>
alt="Jese image"> <button on:click={() => GetAniListSingleItemAndOpenModal(media.id)}
Jese Leos class="flex items-center px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
</a> <img class="w-6 h-6 me-2 rounded-full" src={media.coverImage.large}
</li> alt="{media.title.english === '' || media.title.english === null ? media.title.romaji : media.title.english} Cover">
<li> <h3>{media.title.english === '' || media.title.english === null ? media.title.romaji : media.title.english }</h3>
<a href="#" </button>
class="flex items-center px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white"> </li>
<img class="w-6 h-6 me-2 rounded-full" src="/docs/images/people/profile-picture-2.jpg" {/each}
alt="Jese image"> </ul>
Robert Gough {/if}
</a>
</li>
<li>
<a href="#"
class="flex items-center px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
<img class="w-6 h-6 me-2 rounded-full" src="/docs/images/people/profile-picture-3.jpg"
alt="Jese image">
Bonnie Green
</a>
</li>
<li>
<a href="#"
class="flex items-center px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
<img class="w-6 h-6 me-2 rounded-full" src="/docs/images/people/profile-picture-4.jpg"
alt="Jese image">
Leslie Livingston
</a>
</li>
<li>
<a href="#"
class="flex items-center px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
<img class="w-6 h-6 me-2 rounded-full" src="/docs/images/people/profile-picture-5.jpg"
alt="Jese image">
Michael Gough
</a>
</li>
<li>
<a href="#"
class="flex items-center px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
<img class="w-6 h-6 me-2 rounded-full" src="/docs/images/people/profile-picture-2.jpg"
alt="Jese image">
Joseph Mcfall
</a>
</li>
<li>
<a href="#"
class="flex items-center px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
<img class="w-6 h-6 me-2 rounded-full" src="/docs/images/people/profile-picture-3.jpg"
alt="Jese image">
Roberta Casas
</a>
</li>
<li>
<a href="#"
class="flex items-center px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
<img class="w-6 h-6 me-2 rounded-full" src="/docs/images/people/profile-picture-1.jpg"
alt="Jese image">
Neil Sims
</a>
</li>
</ul>
<a href="#" <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"> 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" <svg class="w-4 h-4 me-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor"