|
1 | 1 | <script lang="ts"> |
2 | 2 | import type { LayoutServerData } from './$types'; |
3 | | - export let data: LayoutServerData; |
| 3 | + import type { Snippet } from 'svelte'; |
| 4 | + import { page } from '$app/state'; |
4 | 5 |
|
5 | 6 | // Global styles: |
6 | | - import '../app.css'; |
| 7 | + import '@/styles/globals.css'; |
7 | 8 | import { cn } from '@/utils/cn'; |
8 | 9 | import { ModeWatcher, mode } from 'mode-watcher'; |
| 10 | +
|
9 | 11 | import { sidebarCategoryCountStyles } from '@/ui/styles'; |
10 | 12 | import { sidebarItemStyles } from '@/ui/styles'; |
11 | 13 |
|
12 | 14 | // Get categories: |
13 | 15 | import { svgs } from '@/data/svgs'; |
14 | | - const categories = getCategories(); |
15 | | -
|
16 | | - // Get category counts: |
17 | | - let categoryCounts: Record<string, number> = {}; |
18 | | - categories.forEach((category) => { |
19 | | - categoryCounts[category] = svgs.filter((svg) => svg.category.includes(category)).length; |
20 | | - }); |
21 | 16 |
|
22 | 17 | // Toaster: |
23 | 18 | import { Toaster } from 'svelte-sonner'; |
|
29 | 24 | // Layout: |
30 | 25 | import Navbar from '@/components/navbar.svelte'; |
31 | 26 | import { getCategories } from '@/data'; |
| 27 | +
|
| 28 | + interface Props { |
| 29 | + data: LayoutServerData; |
| 30 | + children?: Snippet; |
| 31 | + } |
| 32 | +
|
| 33 | + const categories = getCategories(); |
| 34 | +
|
| 35 | + // Get category counts: |
| 36 | + let categoryCounts: Record<string, number> = $state({}); |
| 37 | + categories.forEach((category) => { |
| 38 | + categoryCounts[category] = svgs.filter((svg) => svg.category.includes(category)).length; |
| 39 | + }); |
| 40 | +
|
| 41 | + let { children }: Props = $props(); |
32 | 42 | </script> |
33 | 43 |
|
34 | 44 | <ModeWatcher /> |
35 | | -<Navbar currentPath={data.pathname} /> |
| 45 | +<Navbar currentPath={page.url.pathname} /> |
36 | 46 | <main> |
37 | 47 | <aside |
38 | 48 | class={cn( |
|
51 | 61 | href="/" |
52 | 62 | class={cn( |
53 | 63 | sidebarItemStyles, |
54 | | - data.pathname === '/' |
| 64 | + page.url.pathname === '/' |
55 | 65 | ? 'bg-neutral-200 font-medium text-dark dark:bg-neutral-700/30 dark:text-white' |
56 | 66 | : '' |
57 | 67 | )} |
|
64 | 74 | data-sveltekit-preload-data |
65 | 75 | class={cn( |
66 | 76 | sidebarItemStyles, |
67 | | - data.pathname === `/directory/${category.toLowerCase()}` |
| 77 | + page.url.pathname === `/directory/${category.toLowerCase()}` |
68 | 78 | ? 'bg-neutral-200 font-medium text-dark dark:bg-neutral-700/30 dark:text-white' |
69 | 79 | : '' |
70 | 80 | )} |
|
73 | 83 | <span |
74 | 84 | class={cn( |
75 | 85 | sidebarCategoryCountStyles, |
76 | | - data.pathname === `/directory/${category.toLowerCase()}` |
| 86 | + page.url.pathname === `/directory/${category.toLowerCase()}` |
77 | 87 | ? 'border-neutral-300 dark:border-neutral-700' |
78 | 88 | : '', |
79 | 89 | 'hidden font-mono text-xs md:inline' |
|
86 | 96 | </aside> |
87 | 97 | <div class="ml-0 pb-6 md:ml-56"> |
88 | 98 | <Warning /> |
89 | | - <Transition pathname={data.pathname}> |
90 | | - <slot /> |
| 99 | + <Transition pathname={page.url.pathname}> |
| 100 | + {@render children?.()} |
91 | 101 | </Transition> |
92 | 102 | <Toaster |
93 | 103 | position="bottom-right" |
|
0 commit comments