fixed dropdown locations

This commit is contained in:
John O'Keefe 2024-08-15 15:20:57 -04:00
parent 0f647e85cb
commit c2bf45313d
2 changed files with 88 additions and 15 deletions

View File

@ -0,0 +1,76 @@
<script lang="ts">
import {Avatar} from "flowbite-svelte";
import type {AniListUser} from "./anilist/types/AniListTypes";
import {aniListLoggedIn, aniListUser, malLoggedIn, simklLoggedIn,} from "./GlobalVariablesAndHelperFunctions.svelte"
import * as runtime from "../wailsjs/runtime";
let currentAniListUser: AniListUser
let isAniListLoggedIn: boolean
let isSimklLoggedIn: boolean
let isMALLoggedIn: boolean
aniListUser.subscribe((value) => currentAniListUser = value)
aniListLoggedIn.subscribe((value) => isAniListLoggedIn = value)
simklLoggedIn.subscribe((value) => isSimklLoggedIn = value)
malLoggedIn.subscribe((value) => isMALLoggedIn = value)
function dropdownUser(): void {
let dropdown = document.querySelector("#userDropdown")
dropdown.classList.toggle("hidden")
}
</script>
<div class="relative">
<button id="userDropdownButton" on:click={dropdownUser}>
{#if isAniListLoggedIn}
<Avatar src="{currentAniListUser.data.Viewer.avatar.medium}" class="cursor-pointer"
dot={{ color: 'green' }}/>
{:else}
<Avatar class="cursor-pointer" dot={{ color: 'red' }}/>
{/if}
</button>
<div id="userDropdown"
class="absolute right-0 2xl:left-1/2 2xl:-translate-x-1/2 z-10 bg-white divide-y divide-gray-100 rounded-lg shadow w-44 dark:bg-gray-700 dark:divide-gray-600">
<div class="px-4 py-3 text-sm text-gray-900 dark:text-white">
{#if isAniListLoggedIn}
<div>{currentAniListUser.data.Viewer.name}</div>
{:else}
<div>You are not logged into AniList</div>
{/if}
</div>
<ul class="py-2 text-sm text-gray-700 dark:text-gray-200"
aria-labelledby="dropdownUserAvatarButton">
{#if isAniListLoggedIn}
<li>
<button
class="block px-4 py-2 w-full hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
Logout Anilist
</button>
</li>
{/if}
{#if isMALLoggedIn}
<li>
<button
class="block px-4 py-2 w-full hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
Logout MAL
</button>
</li>
{/if}
{#if isSimklLoggedIn}
<li>
<button
class="block px-4 py-2 w-full hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
Logout Simkl
</button>
</li>
{/if}
</ul>
<div class="py-2">
<button on:click={() => runtime.Quit()}
class="block px-4 py-2 w-full text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white">
Exit Application
</button>
</div>
</div>
</div>

View File

@ -16,10 +16,15 @@
})
}
function searchDropdown(): void {
let dropdown = document.querySelector("#aniListSearchDropdown")
dropdown.classList.toggle("hidden")
}
</script>
<div>
<div id="searchDropdown" class="relative">
<div class="max-w-md mx-auto">
<div class="flex">
<label for="anime-search" class="mb-2 text-sm font-medium text-gray-900 sr-only dark:text-white">Find
@ -28,12 +33,12 @@
<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"
data-dropdown-offset-distance="0"
data-dropdown-offset-skidding="-50"
data-dropdown-placement="bottom"
<button id="aniListSearchButton"
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={() => {if(aniSearch.length > 0) runAniListSearch()}}>
on:click={() => {
searchDropdown()
if(aniSearch.length > 0) 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"
@ -45,7 +50,7 @@
</div>
</div>
<div id="aniListSearch" class="z-10 hidden bg-white rounded-lg shadow w-80 dark:bg-gray-700">
<div id="aniListSearchDropdown" class="z-10 absolute left-0 hidden bg-white rounded-lg shadow w-60 2xl:w-80 dark:bg-gray-700">
{#if aniListSearchActive}
<ul class="h-56 w-full py-2 overflow-y-auto text-gray-700 dark:text-gray-200"
aria-labelledby="aniListSearchButton">
@ -69,13 +74,5 @@
{:else if aniSearch.length === 0}
<div class="m-4">Please enter a search term...</div>
{/if}
<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>