Skip to content

Commit

Permalink
add page transition
Browse files Browse the repository at this point in the history
  • Loading branch information
tjheffner committed Nov 11, 2022
1 parent bd46e4d commit e9fd6d2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/routes/+layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const load = ({ url }) => {
const currentRoute = url.pathname

return {
currentRoute
}
}
9 changes: 9 additions & 0 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
import { onMount } from 'svelte';
import { MY_TWITTER_HANDLE, GH_USER, SITE_TITLE } from '$lib/siteConfig';
import { fade } from 'svelte/transition'
let showBackToTop = true;
let showGetInTouch = false;
export let data
onMount(async () => {
if ($page.url.pathname === '/') showBackToTop = !showBackToTop;
if ($page.url.pathname === '/about') showGetInTouch = !showGetInTouch;
Expand All @@ -30,7 +34,10 @@
<Header />
</div>
<!-- for skip link -->

{#key data.currentRoute}
<main
in:fade={{ duration: 150, delay: 150 }} out:fade={{ duration: 150 }}
id="maincontent"
class="flex flex-col justify-center bg-orange-100 px-4 dark:bg-slate-900 sm:px-8"
>
Expand All @@ -41,6 +48,7 @@
{/if}

</main>

<footer class="flex flex-col justify-center bg-orange-100 px-4 py-12 dark:bg-slate-900 sm:px-8">
{#if showGetInTouch}
<br> <!-- force slice top-border -->
Expand Down Expand Up @@ -104,3 +112,4 @@
</div>
</div>
</footer>
{/key}

0 comments on commit e9fd6d2

Please sign in to comment.