[O] Hide loading

This commit is contained in:
Azalea
2024-04-22 10:43:55 -04:00
parent d3adec5a23
commit dbb41ba249
3 changed files with 13 additions and 6 deletions

View File

@@ -2,6 +2,7 @@
import { onMount, onDestroy } from 'svelte'
export let triggeredBy: string
export let loading: boolean = false
let isHovered = false
let x: number, y: number
let targets: Element[] = []
@@ -49,7 +50,7 @@
</script>
{#if isHovered}
<div style="top: {y}px; left: {x}px" class="tooltip">
<div style="top: {y}px; left: {x}px" class="tooltip" class:loading>
<slot />
</div>
{/if}
@@ -68,4 +69,8 @@
white-space: nowrap
color: #242424
transform: translate(-50%, 0)
transition: opacity 0.2s
&.loading
opacity: 0
</style>

View File

@@ -8,15 +8,16 @@
export let username: string
export let game: GameName
export let setLoading: (loading: boolean) => void = () => {}
let data: GenericGameSummary
let error = ""
let loading = true
GAME.userSummary(username, game).then(d => data = d).catch(e => error = e).finally(_ => loading = false)
setLoading(true)
GAME.userSummary(username, game).then(d => data = d).catch(e => error = e).finally(_ => setLoading(false))
</script>
{#if loading}
{#if !data}
<div>Loading...</div>
{:else if error}
<div>Error: {error}</div>