Skip to content

Commit

Permalink
feat(web): improved loading screen when setting up session
Browse files Browse the repository at this point in the history
Signed-off-by: Jordan Shatford <[email protected]>
  • Loading branch information
jordanshatford committed Sep 27, 2023
1 parent 600e61b commit 101da32
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 30 deletions.
16 changes: 5 additions & 11 deletions apps/web/src/lib/components/Loading.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@
import { Icon, LoaderIcon } from '@yd/ui';
</script>

<div class="bg-white dark:bg-zinc-900">
<div class="flex h-screen">
<div class="m-auto text-center">
<div class="w-100 relative inline-block overflow-hidden align-middle">
<div class="h-48 text-zinc-900 dark:text-white">
<Icon src={LoaderIcon} class="h-50 relative inline-block animate-spin" />
<img class="absolute inset-6 h-36 w-auto" src="images/logo.png" alt="Logo" />
</div>
</div>
</div>
</div>
<div
class="-mt-16 flex h-screen flex-col items-center justify-center space-y-2 text-zinc-900 dark:text-white"
>
<Icon src={LoaderIcon} class="h-10 w-10 animate-spin" />
<div>Setting up session...</div>
</div>
40 changes: 21 additions & 19 deletions apps/web/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

<script lang="ts">
import '../app.css';
import { onMount } from 'svelte';
import { page } from '$app/stores';
import { Toasts, NavBar, Footer, ThemeToggle } from '@yd/ui';
import { page } from '$app/stores';
import { browser } from '$app/environment';
import Loading from '$lib/components/Loading.svelte';
import { session } from '$lib/stores/session';
import { downloads } from '$lib/stores/downloads';
Expand All @@ -22,29 +22,31 @@
return $session;
};
$: if ($session) {
session.setup();
$: if ($session && browser) {
downloads.setupStatusListener();
}
onMount(async () => {
await session.setup();
});
</script>

<svelte:head>
<title>{config.about.title}</title>
</svelte:head>

<Toasts position="bottom-right" />
<div class="h-full min-h-screen dark:bg-zinc-900">
{#if $session}
<div class="h-full">
<NavBar links={navbarLinks} activeLink={$page.url.pathname}>
<Logo slot="logo" />
<ThemeToggle slot="right" />
</NavBar>
<main class="mx-auto h-full max-w-7xl px-4 pt-20 sm:px-6 lg:px-8">
<div class="h-full">
<NavBar links={navbarLinks} activeLink={$page.url.pathname}>
<Logo slot="logo" />
<ThemeToggle slot="right" />
</NavBar>
<main class="mx-auto h-full max-w-7xl px-4 pt-20 sm:px-6 lg:px-8">
{#if $session}
<slot />
</main>
</div>
{:else}
<Loading />
{/if}
{:else}
<Loading />
{/if}
</main>
</div>
</div>
<Footer copyright={config.copyright} links={footerLinks} githubLink={config.github} />

1 comment on commit 101da32

@vercel
Copy link

@vercel vercel bot commented on 101da32 Sep 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.