summaryrefslogtreecommitdiff
path: root/ping/frontend/src/routes/dashboard/+layout.svelte
blob: a2f7efebd1282cbc000b07870473486408ff8077 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<script lang="ts">
	import ToastList from '$lib/components/ToastList.svelte';
	import Avatar from '$lib/components/Avatar.svelte';
	import NavBar from '$lib/components/NavBar.svelte';
	import NumberStatList from '$lib/components/NumberStatList.svelte';
	import SideBar from '$lib/components/SideBar.svelte';

	import '../../app.css';
	import { getPageIndex, pages } from '$lib/pages';
	import { onMount } from 'svelte';
	import { page } from '$app/stores';
	import { user } from '$lib/stores/auth';

	let { children } = $props();

	let selectedIndex = $state(0);

	$effect(() => {
		selectedIndex = getPageIndex($page.url.pathname);
	});
</script>

<ToastList />
<NavBar pageTitle={pages[selectedIndex].name}>
	{#snippet rightComponent()}
		<div class="flex items-center gap-4">
			<form>
				<input type="search" name="search" id="search" placeholder="Search..." />
			</form>
			<Avatar username={$user?.login ?? 'No auth'} url={$user?.avatar} />
		</div>
	{/snippet}
</NavBar>
<SideBar bind:selectedIndex />
<section class="dashboard">{@render children()}</section>

<style>
	section.dashboard {
		padding-left: 208px;
		padding-top: 72px;
		width: 100%;
		height: calc(100vh);
	}
</style>