From 4261ab0f3f9828669b2417a42c753d085e70afd8 Mon Sep 17 00:00:00 2001 From: anoopkarnik Date: Thu, 5 Sep 2024 20:13:56 +0530 Subject: [PATCH 1/2] Left Sidebar only with icons now --- .../components/organisms/home/LeftSidebar.tsx | 26 ++++++++++--------- .../organisms/home/LeftSidebarItem.tsx | 18 +++++++------ 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/packages/ui/src/components/organisms/home/LeftSidebar.tsx b/packages/ui/src/components/organisms/home/LeftSidebar.tsx index d91c501..91ecada 100644 --- a/packages/ui/src/components/organisms/home/LeftSidebar.tsx +++ b/packages/ui/src/components/organisms/home/LeftSidebar.tsx @@ -1,9 +1,10 @@ 'use client' + import { cn } from '@repo/ui/lib/utils' import { usePathname } from 'next/navigation' import { ElementRef, useEffect, useRef, useState } from 'react' import { useMediaQuery } from 'usehooks-ts' -import { ChevronsLeft, AlignJustifyIcon, PlusIcon, MinusIcon, CircleChevronDown, CircleChevronUp } from 'lucide-react' +import { ChevronsLeft, AlignJustifyIcon } from 'lucide-react' import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../../atoms/shadcn/Tooltip' import LeftSidebarItem from './LeftSidebarItem' @@ -15,7 +16,7 @@ interface LeftSidebarProps { redirect: (href: string) => void } -const LeftSidebar = ({ appName, appIcon,sidebarStartItems, sidebarEndItems, redirect }: LeftSidebarProps) => { +const LeftSidebar = ({ appName, appIcon, sidebarStartItems, sidebarEndItems, redirect }: LeftSidebarProps) => { const pathname = usePathname(); const isMobile = useMediaQuery("(max-width: 640px)"); const isNotMobile = useMediaQuery("(min-width: 640px)"); @@ -71,31 +72,32 @@ const LeftSidebar = ({ appName, appIcon,sidebarStartItems, sidebarEndItems, redi return ( <> -
- {isMobile && } + {isMobile && !isCollapsed && }
-
+
-
- {appIcon && {appName}} - {appName &&

{appName}

} +
+ {(!isMobile || (isMobile && !isCollapsed)) && appIcon && {appName}} + {(!isMobile || (isMobile && !isCollapsed)) && appName &&

{appName}

}
{sidebarStartItems.map((item: any, index: number) => ( - + ))}
{sidebarEndItems.map((item: any, index: number) => ( - + ))}
diff --git a/packages/ui/src/components/organisms/home/LeftSidebarItem.tsx b/packages/ui/src/components/organisms/home/LeftSidebarItem.tsx index 9108dd7..fb8a9fc 100644 --- a/packages/ui/src/components/organisms/home/LeftSidebarItem.tsx +++ b/packages/ui/src/components/organisms/home/LeftSidebarItem.tsx @@ -6,7 +6,7 @@ import { CircleChevronDown, CircleChevronUp } from "lucide-react"; import { useState } from "react"; -const LeftSidebarItem = ({index,item,redirect}:any) =>{ +const LeftSidebarItem = ({index,item,redirect,isMobile,isCollapsed}:any) =>{ const [showSubItems, setShowSubItems] = useState({}); const pathname = usePathname(); @@ -34,18 +34,20 @@ const LeftSidebarItem = ({index,item,redirect}:any) =>{
- {item.title} + {(!isMobile || (isMobile && !isCollapsed)) && item.title} {showSubItems[index] ? - : - + : + }
<> {showSubItems[index] && item.subItems.map((subItem: any, subIndex: number) => (
redirect(subItem.href)} - className={cn('flex items-center gap-2 p-2 mx-8 rounded-lg text-sm hover:bg-destructive/10 transition cursor-pointer ', - pathname === subItem.href && 'bg-destructive/30' + className={cn('flex items-center gap-2 p-2 rounded-lg text-sm hover:bg-destructive/10 transition cursor-pointer ', + pathname === subItem.href && 'bg-destructive/30', + isMobile && 'ml-4', + !isMobile && 'mx-8' )}> @@ -54,7 +56,7 @@ const LeftSidebarItem = ({index,item,redirect}:any) =>{ {subItem.title} - {{subItem.title}} + {(!isMobile || (isMobile && !isCollapsed)) && {subItem.title}}
))} @@ -73,7 +75,7 @@ const LeftSidebarItem = ({index,item,redirect}:any) =>{ {item.title} - {{item.title}} + {(!isMobile || (isMobile && !isCollapsed)) && {item.title}}
} From 8a8f45f7af9a27b6254dd5b455762bac05b97379 Mon Sep 17 00:00:00 2001 From: anoopkarnik Date: Thu, 5 Sep 2024 20:21:08 +0530 Subject: [PATCH 2/2] Left Sidebar only with icons now --- packages/ui/src/components/organisms/home/Navbar.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/ui/src/components/organisms/home/Navbar.tsx b/packages/ui/src/components/organisms/home/Navbar.tsx index dcff9cc..a35b187 100644 --- a/packages/ui/src/components/organisms/home/Navbar.tsx +++ b/packages/ui/src/components/organisms/home/Navbar.tsx @@ -4,6 +4,8 @@ import { Theme } from './Theme'; import { GoTriangleDown } from "react-icons/go"; import { UserDropdown } from './UserDropdown'; import { Notification } from './Notification'; +import { useMediaQuery } from 'usehooks-ts'; +import { cn } from '../../../lib/utils'; interface NavbarProps { title?: string; @@ -22,14 +24,16 @@ interface NavbarProps { export const Navbar = ({title, screens, user,setTheme, onSignout,resetFunction}:NavbarProps) => { - + const isMobile = useMediaQuery("(max-width: 640px)"); return (
- {title &&
{title}
} + {!isMobile && title &&
{title}
}
-
+