anitrack/frontend/src/App.svelte

126 lines
3.4 KiB
Svelte
Raw Normal View History

2024-07-09 10:16:53 -04:00
<script lang="ts">
import logo from './assets/images/logo-universal.png'
import {Greet} from '../wailsjs/go/main/App.js'
import {AniListLogin, AniListSearch, GetAniListItem} from "../wailsjs/go/main/App";
import type {AniListItem, AniSearchList} from "./AniListTypes";
2024-07-09 10:16:53 -04:00
let resultText: string = "Please enter your name below 👇"
let name: string
let aniId = "157371"
let aniSearch = ""
let aniListItem: AniListItem
let aniListSearch: AniSearchList
let aniListLoggedIn = false
2024-07-09 10:16:53 -04:00
function greet(): void {
Greet(name).then(result => resultText = result)
}
function getAniListitem(): void {
GetAniListItem(Number(aniId)).then(result => aniListItem = result)
}
function runAniListSearch(): void {
AniListSearch(aniSearch).then(result => aniListSearch = result)
}
function loginToAniList(): void {
AniListLogin().then(() => aniListLoggedIn = true)
}
2024-07-09 10:16:53 -04:00
</script>
<main>
<img alt="Wails logo" id="logo" src="{aniListItem === undefined ? logo : aniListItem.data.Media.coverImage.extraLarge}">
<!-- <div class="result" id="result">{resultText}</div>-->
<!-- <div class="input-box" id="input">-->
<!-- <input autocomplete="off" bind:value={name} class="input" id="name" type="text"/>-->
<!-- <button class="btn" on:click={greet}>Greet</button>-->
<!-- </div>-->
<div class="result" id="AniTest">{aniListItem !== undefined ? aniListItem.data.Media.title.english : ""}</div>
<div class="input-box" id="aniButton">
<input autocomplete="off" bind:value={aniId} class="input" id="aniId" type="text"/>
<button class="btn" on:click={getAniListitem}>Get AniList Item</button>
</div>
<button class="btn" on:click={loginToAniList}>Login to AniList</button>
{#if aniListLoggedIn}
<div>You are logged in!</div>
{/if}
<div class="input-box" id="aniSearch">
<input autocomplete="off" bind:value={aniSearch} class="input" id="aniSearchInput" type="text"/>
<button class="btn" on:click={runAniListSearch}>Search AniList</button>
2024-07-09 10:16:53 -04:00
</div>
{#if aniListSearch !== undefined}
<ul>
{#each aniListSearch.data.Page.media as media, index (media.id)}
<li>
<div>{media.title.english !== null ? media.title.english : media.title.romaji}</div>
</li>
{:else}
<div>No Results Yet...</div>
{/each}
</ul>
{/if}
2024-07-09 10:16:53 -04:00
</main>
<style>
#logo {
display: block;
width: 50%;
height: 50%;
margin: auto;
padding: 10% 0 0;
background-position: center;
background-repeat: no-repeat;
background-size: 100% 100%;
background-origin: content-box;
}
.result {
height: 20px;
line-height: 20px;
margin: 1.5rem auto;
}
.input-box .btn {
/*width: 60px;*/
2024-07-09 10:16:53 -04:00
height: 30px;
line-height: 30px;
border-radius: 3px;
border: none;
margin: 0 0 0 20px;
padding: 0 8px;
cursor: pointer;
}
.input-box .btn:hover {
background-image: linear-gradient(to top, #cfd9df 0%, #e2ebf0 100%);
color: #333333;
}
.input-box .input {
border: none;
border-radius: 3px;
outline: none;
height: 30px;
line-height: 30px;
padding: 0 10px;
background-color: rgba(240, 240, 240, 1);
-webkit-font-smoothing: antialiased;
}
.input-box .input:hover {
border: none;
background-color: rgba(255, 255, 255, 1);
}
.input-box .input:focus {
border: none;
background-color: rgba(255, 255, 255, 1);
}
</style>