mirror of
https://github.com/pheralb/svgl.git
synced 2024-11-13 08:46:56 +08:00
🛠️ Add route transitions.
This commit is contained in:
parent
a2aee89088
commit
9afab3cf44
10
src/components/transition.svelte
Normal file
10
src/components/transition.svelte
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { fade } from 'svelte/transition';
|
||||||
|
export let pathname: string = '';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#key pathname}
|
||||||
|
<div in:fade={{ duration: 300 }}>
|
||||||
|
<slot />
|
||||||
|
</div>
|
||||||
|
{/key}
|
5
src/routes/+layout.server.ts
Normal file
5
src/routes/+layout.server.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import type { LayoutServerLoad } from './$types';
|
||||||
|
|
||||||
|
export const load: LayoutServerLoad = async ({ url: { pathname } }) => {
|
||||||
|
return { pathname };
|
||||||
|
};
|
@ -1,10 +1,13 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import type { LayoutServerData } from './$types';
|
||||||
|
export let data: LayoutServerData;
|
||||||
|
|
||||||
// Global styles:
|
// Global styles:
|
||||||
import '../app.css';
|
import '../app.css';
|
||||||
|
|
||||||
// Get categories:
|
// Get categories:
|
||||||
import svgData from '../data/svgs.json';
|
import { svgs } from '@/data/svgs';
|
||||||
const categories = svgData
|
const categories = svgs
|
||||||
.map((svg) => svg.category)
|
.map((svg) => svg.category)
|
||||||
.filter((category, index, array) => array.indexOf(category) === index);
|
.filter((category, index, array) => array.indexOf(category) === index);
|
||||||
|
|
||||||
@ -14,6 +17,7 @@
|
|||||||
|
|
||||||
// Toaster:
|
// Toaster:
|
||||||
import { Toaster } from 'svelte-french-toast';
|
import { Toaster } from 'svelte-french-toast';
|
||||||
|
import Transition from '@/components/transition.svelte';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<main class="min-h-screen bg-dark font-sans text-mini text-white">
|
<main class="min-h-screen bg-dark font-sans text-mini text-white">
|
||||||
@ -33,7 +37,7 @@
|
|||||||
<a
|
<a
|
||||||
href={`/directory/${category.toLowerCase()}`}
|
href={`/directory/${category.toLowerCase()}`}
|
||||||
class="flex w-full items-center rounded-md p-2 transition-all duration-100 hover:bg-neutral-700/40"
|
class="flex w-full items-center rounded-md p-2 transition-all duration-100 hover:bg-neutral-700/40"
|
||||||
>{category}</a
|
data-sveltekit-preload-data>{category}</a
|
||||||
>
|
>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
@ -69,7 +73,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
<div class="ml-60 py-6">
|
<div class="ml-60 py-6">
|
||||||
<slot />
|
<Transition pathname={data.pathname}>
|
||||||
|
<slot />
|
||||||
|
</Transition>
|
||||||
<Toaster position="bottom-center" />
|
<Toaster position="bottom-center" />
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
Loading…
Reference in New Issue
Block a user