diff options
| author | Adam Soltys <[email protected]> | 2022-08-16 15:31:41 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-08-16 15:31:41 -0700 |
| commit | 770725fbdcc8ea7bf47ef0af5a43a239bef98ff6 (patch) | |
| tree | 445d55b896a63eab5a29204e720a9e74d0629697 /src/routes/__layout.svelte | |
| parent | 0b51e1dfd0d099c243d21889fb77fea4769dac0a (diff) | |
| download | coinos-ui-770725fbdcc8ea7bf47ef0af5a43a239bef98ff6.tar.gz coinos-ui-770725fbdcc8ea7bf47ef0af5a43a239bef98ff6.zip | |
sveltekit route migration
Diffstat (limited to 'src/routes/__layout.svelte')
| -rw-r--r-- | src/routes/__layout.svelte | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/src/routes/__layout.svelte b/src/routes/__layout.svelte deleted file mode 100644 index 316bf6b3..00000000 --- a/src/routes/__layout.svelte +++ /dev/null @@ -1,57 +0,0 @@ -<script> - import { SvelteToast } from '@zerodevx/svelte-toast'; - import '$lib/i18n'; - import { isLoading, locale } from 'svelte-i18n'; - import '../app.css'; - import { onMount } from 'svelte'; - import { connect } from '$lib/socket'; - import { user, token } from '$lib/store'; - import { page, session } from '$app/stores'; - import { browser } from '$app/env'; - import { goto } from '$app/navigation'; - import { LoadingSplash } from '$comp'; - import { warning, protectedRoutes } from '$lib/utils'; - - browser && ($token ||= $session.token); - - let ready = false; - - onMount(() => { - // get locale from local storage - let localStorageLocale = localStorage.getItem('svelte-i18n-locale'); - if (localStorageLocale) locale.set(localStorageLocale); - - locale.subscribe((lng) => { - if (lng) localStorage.setItem('svelte-i18n-locale', lng); - }); - - if (protectedRoutes.find((p) => $page.url.pathname.match(p))) { - if (!$token) { - goto('/login'); - warning('Please sign in to continue.'); - } - user.subscribe((u) => u?.username && (ready = true)); - } else { - ready = true; - } - - connect(); - }); -</script> - -{#if ready && !$isLoading} - <SvelteToast options={{ reversed: true, intro: { y: 192 } }} /> - <slot /> -{:else} - <LoadingSplash /> -{/if} - -<style> - :root { - --toastContainerTop: auto; - --toastContainerRight: auto; - --toastContainerBottom: 8rem; - --toastContainerLeft: calc(50vw - 8rem); - --toastBackground: #292929; - } -</style> |
