From dbb53a663ea854ea7e1965dfd91ddda8aacdca89 Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com> Date: Fri, 11 Aug 2023 15:53:10 +0530 Subject: [PATCH] style: sidebar ui improvement (#1816) * style: sidebar ui improvement * style: sidebar menu spacing * style: sidebar consistent spacing * style: notification improvement * style: remove from favorite filled icon added * chore: settings option added in sidebar context menu * chore: update delete project option visibility for sidebar * style: sidebar project list display border top on scroll --- .../notifications/notification-popover.tsx | 14 +- apps/app/components/project/sidebar-list.tsx | 156 ++++++++++-------- .../project/single-project-card.tsx | 2 +- .../project/single-sidebar-project.tsx | 26 ++- apps/app/components/workspace/index.ts | 1 + .../app/components/workspace/sidebar-menu.tsx | 2 +- .../workspace/sidebar-quick-action.tsx | 47 ++++++ apps/app/layouts/app-layout/app-sidebar.tsx | 2 + 8 files changed, 166 insertions(+), 84 deletions(-) create mode 100644 apps/app/components/workspace/sidebar-quick-action.tsx diff --git a/apps/app/components/notifications/notification-popover.tsx b/apps/app/components/notifications/notification-popover.tsx index da9fb5668..39e4d8764 100644 --- a/apps/app/components/notifications/notification-popover.tsx +++ b/apps/app/components/notifications/notification-popover.tsx @@ -84,7 +84,7 @@ export const NotificationPopover = () => { disabled={!store?.theme?.sidebarCollapsed} > { {store?.theme?.sidebarCollapsed ? null : Notifications} {totalNotificationCount && totalNotificationCount > 0 ? ( - - {getNumberCount(totalNotificationCount)} - + store?.theme?.sidebarCollapsed ? ( + + ) : ( + + {getNumberCount(totalNotificationCount)} + + ) ) : null} @@ -108,7 +112,7 @@ export const NotificationPopover = () => { leaveFrom="opacity-100 translate-y-0" leaveTo="opacity-0 translate-y-1" > - + { const [projectToDelete, setProjectToDelete] = useState(null); // router + const [isScrolled, setIsScrolled] = useState(false); + + const containerRef = useRef(null); + const router = useRouter(); const { workspaceSlug, projectId } = router.query; @@ -126,6 +130,27 @@ export const ProjectSidebarList: FC = () => { }); }; + const handleScroll = () => { + if (containerRef.current) { + const scrollTop = containerRef.current.scrollTop; + setIsScrolled(scrollTop > 0); + } + }; + + useEffect(() => { + const currentContainerRef = containerRef.current; + + if (currentContainerRef) { + currentContainerRef.addEventListener("scroll", handleScroll); + } + + return () => { + if (currentContainerRef) { + currentContainerRef.removeEventListener("scroll", handleScroll); + } + }; + }, []); + return ( <> { data={projectToDelete} user={user} /> -
+
{(provided) => ( @@ -147,7 +177,7 @@ export const ProjectSidebarList: FC = () => { Favorites { {({ open }) => ( <> {!store?.theme?.sidebarCollapsed && ( - - Projects - - +
+ + Projects + + + +
)} - - {orderedJoinedProjects.map((project, index) => ( - - {(provided, snapshot) => ( -
- handleDeleteProject(project)} - handleCopyText={() => handleCopyText(project.id)} - /> -
- )} -
- ))} -
+ + + {orderedJoinedProjects.map((project, index) => ( + + {(provided, snapshot) => ( +
+ handleDeleteProject(project)} + handleCopyText={() => handleCopyText(project.id)} + /> +
+ )} +
+ ))} +
+
{provided.placeholder} )} @@ -239,43 +289,7 @@ export const ProjectSidebarList: FC = () => { )}
- {otherProjects && otherProjects.length > 0 && ( - p.id === projectId) ? true : false} - > - {({ open }) => ( - <> - {!store?.theme?.sidebarCollapsed && ( - - Other Projects - - - )} - - {otherProjects?.map((project, index) => ( - handleDeleteProject(project)} - handleCopyText={() => handleCopyText(project.id)} - shortContextMenu - /> - ))} - - - )} - - )} + {allProjects && allProjects.length === 0 && (
)} + router.push(`/${workspaceSlug}/projects/${project?.id}/settings`)} + > +
+ + Settings +
+
)}
diff --git a/apps/app/components/workspace/index.ts b/apps/app/components/workspace/index.ts index d40b9d58e..8e354a718 100644 --- a/apps/app/components/workspace/index.ts +++ b/apps/app/components/workspace/index.ts @@ -9,3 +9,4 @@ export * from "./issues-stats"; export * from "./settings-header"; export * from "./sidebar-dropdown"; export * from "./sidebar-menu"; +export * from "./sidebar-quick-action"; diff --git a/apps/app/components/workspace/sidebar-menu.tsx b/apps/app/components/workspace/sidebar-menu.tsx index 3e4d5472b..59882284a 100644 --- a/apps/app/components/workspace/sidebar-menu.tsx +++ b/apps/app/components/workspace/sidebar-menu.tsx @@ -51,7 +51,7 @@ export const WorkspaceSidebarMenu = () => { const { collapsed: sidebarCollapse } = useTheme(); return ( -
+
{workspaceLinks(workspaceSlug as string).map((link, index) => { const isActive = link.name === "Settings" diff --git a/apps/app/components/workspace/sidebar-quick-action.tsx b/apps/app/components/workspace/sidebar-quick-action.tsx new file mode 100644 index 000000000..781ef353f --- /dev/null +++ b/apps/app/components/workspace/sidebar-quick-action.tsx @@ -0,0 +1,47 @@ +import React from "react"; + +// ui +import { Icon } from "components/ui"; +// mobx store +import { useMobxStore } from "lib/mobx/store-provider"; + +export const WorkspaceSidebarQuickAction = () => { + const store: any = useMobxStore(); + + return ( +
+ + + +
+ ); +}; diff --git a/apps/app/layouts/app-layout/app-sidebar.tsx b/apps/app/layouts/app-layout/app-sidebar.tsx index 60ef645cf..7143d9cad 100644 --- a/apps/app/layouts/app-layout/app-sidebar.tsx +++ b/apps/app/layouts/app-layout/app-sidebar.tsx @@ -5,6 +5,7 @@ import { WorkspaceHelpSection, WorkspaceSidebarDropdown, WorkspaceSidebarMenu, + WorkspaceSidebarQuickAction, } from "components/workspace"; import { ProjectSidebarList } from "components/project"; // mobx react lite @@ -30,6 +31,7 @@ const Sidebar: React.FC = observer(({ toggleSidebar, setToggleSide >
+