Skip to content

Commit

Permalink
✨ Fix sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
asim-shrestha committed Jun 8, 2023
1 parent 0370b87 commit 71d9a82
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions next/src/layout/sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { FC, PropsWithChildren, ReactNode } from "react";
import { Fragment, useState } from "react";
import { Fragment, useEffect, useState } from "react";
import { Transition } from "@headlessui/react";
import { useAuth } from "../hooks/useAuth";
import type { Session } from "next-auth";
Expand Down Expand Up @@ -59,7 +59,7 @@ const LinkItem = (props: {
const SidebarLayout = (props: Props) => {
const router = useRouter();
const { session, signIn, signOut, status } = useAuth();
const [sidebarOpen, setSidebarOpen] = useState(true);
const [sidebarOpen, setSidebarOpen] = useState(false);
const [t] = useTranslation("drawer");

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

useEffect(() => {
const handleResize = () => {
const isDesktop = window.innerWidth >= 1280
setSidebarOpen(isDesktop);
};
handleResize(); // Initial check on open
window.addEventListener('resize', handleResize);

return () => {
window.removeEventListener('resize', handleResize);
};
}, []);


return (
<div>
<Transition.Root show={sidebarOpen} as={Fragment}>
Expand Down Expand Up @@ -192,7 +206,7 @@ const SidebarLayout = (props: Props) => {
<main
className={clsx("bg-gradient-to-b from-[#2B2B2B] to-[#1F1F1F]", sidebarOpen && "lg:pl-60")}
>
<DottedGridBackground className="min-w-screenx">
<DottedGridBackground className="min-w-screen min-h-screen">
<div>{props.children}</div>
</DottedGridBackground>
</main>
Expand Down

1 comment on commit 71d9a82

@vercel
Copy link

@vercel vercel bot commented on 71d9a82 Jun 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./docs

docs-git-main-reworkd.vercel.app
docs-reworkd.vercel.app
docs.reworkd.ai

Please sign in to comment.