From 496a2340c53efecf85f4a2b5b0f870056e846de4 Mon Sep 17 00:00:00 2001 From: Prateek Shourya Date: Thu, 22 Feb 2024 15:20:12 +0530 Subject: [PATCH] chore: sidebar responsiveness. --- god-mode/app/header.tsx | 4 +- god-mode/app/sidebar.tsx | 40 ++++++++++++++++--- god-mode/components/sidebar/help-section.tsx | 11 +---- .../sidebar/sidebar-menu-hamburger-toogle.tsx | 21 ++++++++++ god-mode/components/sidebar/sidebar-menu.tsx | 10 ++++- god-mode/hooks/use-outside-click-detector.tsx | 19 +++++++++ 6 files changed, 87 insertions(+), 18 deletions(-) create mode 100644 god-mode/components/sidebar/sidebar-menu-hamburger-toogle.tsx create mode 100644 god-mode/hooks/use-outside-click-detector.tsx diff --git a/god-mode/app/header.tsx b/god-mode/app/header.tsx index f8a5b5386..353552439 100644 --- a/god-mode/app/header.tsx +++ b/god-mode/app/header.tsx @@ -8,6 +8,8 @@ import { observer } from "mobx-react-lite"; import { Breadcrumbs } from "@plane/ui"; // icons import { Settings } from "lucide-react"; +// components +import { SidebarHamburgerToggle } from "components/sidebar/sidebar-menu-hamburger-toogle"; export const InstanceHeader: FC = observer(() => { const pathName = usePathname(); @@ -35,6 +37,7 @@ export const InstanceHeader: FC = observer(() => { return (
+ {title && (
@@ -42,7 +45,6 @@ export const InstanceHeader: FC = observer(() => { type="text" icon={} label="Settings" - link="/" /> diff --git a/god-mode/app/sidebar.tsx b/god-mode/app/sidebar.tsx index bbf792f95..cb65fcf93 100644 --- a/god-mode/app/sidebar.tsx +++ b/god-mode/app/sidebar.tsx @@ -1,9 +1,10 @@ "use client"; -import { FC } from "react"; +import { FC, useEffect, useRef } from "react"; import { observer } from "mobx-react-lite"; // hooks import useAppTheme from "hooks/use-theme"; +import useOutsideClickDetector from "hooks/use-outside-click-detector"; // components import { HelpSection, SidebarMenu, SidebarDropdown } from "components/sidebar"; @@ -11,15 +12,42 @@ export interface IInstanceSidebar {} export const InstanceSidebar: FC = observer(() => { // store - const { sidebarCollapsed } = useAppTheme(); + const themeStore = useAppTheme(); + + const ref = useRef(null); + + useOutsideClickDetector(ref, () => { + if (themeStore.sidebarCollapsed === false) { + if (window.innerWidth < 768) { + themeStore.toggleSidebar(); + } + } + }); + + useEffect(() => { + const handleResize = () => { + if (window.innerWidth <= 768) { + themeStore.toggleSidebar(true); + } + }; + handleResize(); + window.addEventListener("resize", handleResize); + return () => { + window.removeEventListener("resize", handleResize); + }; + }, [themeStore]); return (
-
+
diff --git a/god-mode/components/sidebar/help-section.tsx b/god-mode/components/sidebar/help-section.tsx index c2844e26f..9d1d2bc2d 100644 --- a/god-mode/components/sidebar/help-section.tsx +++ b/god-mode/components/sidebar/help-section.tsx @@ -1,7 +1,7 @@ import { FC, useState, useRef } from "react"; import { Transition } from "@headlessui/react"; import Link from "next/link"; -import { FileText, HelpCircle, MessagesSquare, MoveLeft } from "lucide-react"; +import { FileText, HelpCircle, MoveLeft } from "lucide-react"; // hooks import { useAppTheme } from "hooks/use-theme"; // icons @@ -25,12 +25,6 @@ const helpOptions = [ href: "https://github.com/makeplane/plane/issues/new/choose", Icon: GithubIcon, }, - { - name: "Chat with us", - href: null, - onClick: () => (window as any).$crisp.push(["do", "chat:show"]), - Icon: MessagesSquare, - }, ]; export const HelpSection: FC = () => { @@ -100,7 +94,7 @@ export const HelpSection: FC = () => { ref={helpOptionsRef} >
- {helpOptions.map(({ name, Icon, href, onClick }) => { + {helpOptions.map(({ name, Icon, href }) => { if (href) return ( @@ -120,7 +114,6 @@ export const HelpSection: FC = () => {