|
2 | 2 | import '../app.css'; |
3 | 3 | import Footer from './footer.svelte'; |
4 | 4 | import { page } from '$app/stores'; |
| 5 | + import { onMount } from 'svelte'; |
| 6 | +
|
5 | 7 | let { children } = $props(); |
| 8 | + let isLoading = $state(true); // Loading state |
6 | 9 |
|
7 | 10 | const isActive = (route: string) => { |
8 | 11 | return $page.url.pathname === route; |
9 | 12 | }; |
| 13 | +
|
| 14 | + // Wait for all assets (images, fonts) to load |
| 15 | + onMount(() => { |
| 16 | + const handleLoad = () => { |
| 17 | + isLoading = false; // Hide the loader once everything is loaded |
| 18 | + }; |
| 19 | +
|
| 20 | + // Check if the document is already loaded |
| 21 | + if (document.readyState === 'complete') { |
| 22 | + handleLoad(); |
| 23 | + } else { |
| 24 | + window.addEventListener('load', handleLoad); |
| 25 | + } |
| 26 | +
|
| 27 | + // Cleanup event listener |
| 28 | + return () => { |
| 29 | + window.removeEventListener('load', handleLoad); |
| 30 | + }; |
| 31 | + }); |
10 | 32 | </script> |
11 | 33 |
|
12 | | -<div class="md:h-[89vh] md:grid md:grid-cols-6"> |
13 | | - <nav class="font-dm-serif col-span-1 space-x-10 border-r px-7 md:pt-10 pt-5 text-xl md:flex flex-col gap-3"> |
14 | | - <span><a href="/" class={`hover:underline ${isActive('/') && 'underline'}`}>Intro</a></span> |
15 | | - <span><a href="/history" class={`hover:underline ${isActive('/history') && 'underline'}`}>History</a></span> |
16 | | - <span><a href="/works" class={`hover:underline ${isActive('/works') && 'underline'}`}>Works</a></span> |
17 | | - </nav> |
| 34 | +{#if isLoading} |
| 35 | + <!-- Loading Animation --> |
| 36 | + <div class="fixed inset-0 flex items-center justify-center bg-yellow-50 z-50"> |
| 37 | + <p class="absolute bottom-10 right-10 text-7xl font-black font-mono">LOADING...</p> |
| 38 | + </div> |
| 39 | +{:else} |
| 40 | + <!-- Main Content --> |
| 41 | + <div class="md:h-[89vh] md:grid md:grid-cols-6"> |
| 42 | + <nav class="font-dm-serif col-span-1 space-x-10 border-r px-7 md:pt-10 pt-5 text-xl md:flex flex-col gap-3"> |
| 43 | + <span><a href="/" class={`hover:underline ${isActive('/') && 'underline'}`}>Intro</a></span> |
| 44 | + <span><a href="/history" class={`hover:underline ${isActive('/history') && 'underline'}`}>History</a></span> |
| 45 | + <span><a href="/works" class={`hover:underline ${isActive('/works') && 'underline'}`}>Works</a></span> |
| 46 | + </nav> |
18 | 47 |
|
19 | | - <div class="col-span-5 overflow-y-auto py-10 px-10 md:px-20 "> |
20 | | - {@render children()} |
| 48 | + <div class="col-span-5 overflow-y-auto py-10 px-10 md:px-20 "> |
| 49 | + {@render children()} |
| 50 | + </div> |
21 | 51 | </div> |
22 | | -</div> |
23 | 52 |
|
24 | | -<Footer /> |
| 53 | + <Footer /> |
| 54 | +{/if} |
0 commit comments