Skip to content

Commit 1f06d3e

Browse files
committed
fix: Move main layout config into +layout.svelte
1 parent 0d8f237 commit 1f06d3e

File tree

2 files changed

+47
-56
lines changed

2 files changed

+47
-56
lines changed

src/lib/components/mainLayout.svelte

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/routes/(main)/+layout.svelte

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,50 @@
11
<script lang="ts">
2-
import MainLayout from '$lib/components/mainLayout.svelte';
3-
import type { LayoutProps } from './$types';
4-
let { data, children }: LayoutProps = $props();
2+
import { Toaster } from '$lib/components/ui/sonner/index';
3+
import { MessagesSquare } from 'lucide-svelte';
4+
import type { Snippet } from 'svelte';
5+
import type { PageData } from '../../routes/(main)/$types';
6+
import Channel from '$lib/components/channel.svelte';
7+
import ChannelDialog from '$lib/components/forms/channelDialog.svelte';
8+
import ModeSwitcher from '$lib/components/modeSwitcher.svelte';
9+
import User from '$lib/components/user.svelte';
10+
11+
interface Props {
12+
data: PageData;
13+
children: Snippet;
14+
}
15+
16+
let sidebarWidth = $state(0);
17+
const { data, children }: Props = $props();
18+
const channels = data.channels;
519
</script>
620

7-
<MainLayout {data}>
8-
{@render children()}
9-
</MainLayout>
21+
<div class="w-screen">
22+
<Toaster />
23+
<div class="grid h-screen w-full md:grid-cols-[220px_1fr] lg:grid-cols-[280px_1fr]">
24+
<div class="hidden border-r bg-muted/40 md:block" bind:clientWidth={sidebarWidth}>
25+
<div class="flex h-full max-h-screen flex-col gap-2">
26+
<div class="flex h-14 items-center border-b px-4 lg:h-[60px] lg:px-6">
27+
<a href="/" class="flex items-center gap-2 font-semibold">
28+
<MessagesSquare class="h-6 w-6" />
29+
<span class="">SVChat</span>
30+
</a>
31+
<ModeSwitcher />
32+
</div>
33+
<div class="h-full flex-1 overflow-scroll">
34+
<nav class="grid items-start px-2 text-sm font-medium lg:px-4">
35+
{#each channels as channelName}
36+
<Channel {channelName} />
37+
{/each}
38+
</nav>
39+
</div>
40+
<div class="mt-auto border-t p-4">
41+
<User {data} />
42+
<ChannelDialog data={data.form} />
43+
</div>
44+
</div>
45+
</div>
46+
<div class="relative max-h-screen p-2" style={`max-width: calc(100vw - 1px - ${sidebarWidth}px)`}>
47+
{@render children()}
48+
</div>
49+
</div>
50+
</div>

0 commit comments

Comments
 (0)