Skip to content

Commit 71d9a82

Browse files
committed
✨ Fix sidebar
1 parent 0370b87 commit 71d9a82

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

next/src/layout/sidebar.tsx

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { FC, PropsWithChildren, ReactNode } from "react";
2-
import { Fragment, useState } from "react";
2+
import { Fragment, useEffect, useState } from "react";
33
import { Transition } from "@headlessui/react";
44
import { useAuth } from "../hooks/useAuth";
55
import type { Session } from "next-auth";
@@ -59,7 +59,7 @@ const LinkItem = (props: {
5959
const SidebarLayout = (props: Props) => {
6060
const router = useRouter();
6161
const { session, signIn, signOut, status } = useAuth();
62-
const [sidebarOpen, setSidebarOpen] = useState(true);
62+
const [sidebarOpen, setSidebarOpen] = useState(false);
6363
const [t] = useTranslation("drawer");
6464

6565
const [showSettings, setShowSettings] = useState(false);
@@ -69,6 +69,20 @@ const SidebarLayout = (props: Props) => {
6969
});
7070
const userAgents = query.data ?? [];
7171

72+
useEffect(() => {
73+
const handleResize = () => {
74+
const isDesktop = window.innerWidth >= 1280
75+
setSidebarOpen(isDesktop);
76+
};
77+
handleResize(); // Initial check on open
78+
window.addEventListener('resize', handleResize);
79+
80+
return () => {
81+
window.removeEventListener('resize', handleResize);
82+
};
83+
}, []);
84+
85+
7286
return (
7387
<div>
7488
<Transition.Root show={sidebarOpen} as={Fragment}>
@@ -192,7 +206,7 @@ const SidebarLayout = (props: Props) => {
192206
<main
193207
className={clsx("bg-gradient-to-b from-[#2B2B2B] to-[#1F1F1F]", sidebarOpen && "lg:pl-60")}
194208
>
195-
<DottedGridBackground className="min-w-screenx">
209+
<DottedGridBackground className="min-w-screen min-h-screen">
196210
<div>{props.children}</div>
197211
</DottedGridBackground>
198212
</main>

0 commit comments

Comments
 (0)