From 098c1d840b824db12ee08b4f75f5997ce8f01580 Mon Sep 17 00:00:00 2001 From: = Date: Thu, 26 Jun 2025 11:30:40 +0530 Subject: [PATCH] feat: org sidebar first version --- frontend/src/components/v2/Lottie/Lottie.tsx | 32 ++ frontend/src/components/v2/Lottie/index.tsx | 1 + frontend/src/components/v2/index.tsx | 1 + .../OrganizationLayout/OrganizationLayout.tsx | 65 +--- .../components/MinimizedOrgSidebar/index.tsx | 1 - .../components/NavBar/Navbar.tsx | 348 ++++++++++++++++++ .../components/NavBar/index.tsx | 1 + .../Copy.tsx} | 2 +- .../components/OrgSidebar/OrgSidebar.tsx | 341 +++++++++++++++++ .../components/OrgSidebar/index.tsx | 1 + 10 files changed, 730 insertions(+), 63 deletions(-) create mode 100644 frontend/src/components/v2/Lottie/Lottie.tsx create mode 100644 frontend/src/components/v2/Lottie/index.tsx delete mode 100644 frontend/src/layouts/OrganizationLayout/components/MinimizedOrgSidebar/index.tsx create mode 100644 frontend/src/layouts/OrganizationLayout/components/NavBar/Navbar.tsx create mode 100644 frontend/src/layouts/OrganizationLayout/components/NavBar/index.tsx rename frontend/src/layouts/OrganizationLayout/components/{MinimizedOrgSidebar/MinimizedOrgSidebar.tsx => OrgSidebar/Copy.tsx} (99%) create mode 100644 frontend/src/layouts/OrganizationLayout/components/OrgSidebar/OrgSidebar.tsx create mode 100644 frontend/src/layouts/OrganizationLayout/components/OrgSidebar/index.tsx diff --git a/frontend/src/components/v2/Lottie/Lottie.tsx b/frontend/src/components/v2/Lottie/Lottie.tsx new file mode 100644 index 000000000..1f5ad5526 --- /dev/null +++ b/frontend/src/components/v2/Lottie/Lottie.tsx @@ -0,0 +1,32 @@ +import { ReactNode, useRef } from "react"; +import { DotLottie, DotLottieReact, Mode } from "@lottiefiles/dotlottie-react"; + +export type LottieProps = { + // Kudos to https://itnext.io/react-polymorphic-components-with-typescript-f7ce72ea7af2 + children?: ReactNode; + icon?: string; + iconMode?: Mode; + className?: string; +}; + +export const Lottie = ({ children, icon, iconMode, ...props }: LottieProps): JSX.Element => { + const iconRef = useRef(null); + return ( +
iconRef.current?.play()} + onMouseLeave={() => iconRef.current?.stop()} + {...props} + > + { + iconRef.current = el; + }} + mode={iconMode} + src={`/lotties/${icon}.json`} + loop + className="h-full w-full" + /> + {children} +
+ ); +}; diff --git a/frontend/src/components/v2/Lottie/index.tsx b/frontend/src/components/v2/Lottie/index.tsx new file mode 100644 index 000000000..70d571e42 --- /dev/null +++ b/frontend/src/components/v2/Lottie/index.tsx @@ -0,0 +1 @@ +export { Lottie } from "./Lottie"; diff --git a/frontend/src/components/v2/index.tsx b/frontend/src/components/v2/index.tsx index ede71e324..a067af75d 100644 --- a/frontend/src/components/v2/index.tsx +++ b/frontend/src/components/v2/index.tsx @@ -22,6 +22,7 @@ export * from "./GenericFieldLabel"; export * from "./HoverCardv2"; export * from "./IconButton"; export * from "./Input"; +export * from "./Lottie"; export * from "./Menu"; export * from "./Modal"; export * from "./NoticeBanner"; diff --git a/frontend/src/layouts/OrganizationLayout/OrganizationLayout.tsx b/frontend/src/layouts/OrganizationLayout/OrganizationLayout.tsx index b3f19c4de..bd5a8f77b 100644 --- a/frontend/src/layouts/OrganizationLayout/OrganizationLayout.tsx +++ b/frontend/src/layouts/OrganizationLayout/OrganizationLayout.tsx @@ -2,7 +2,6 @@ import { useTranslation } from "react-i18next"; import { faMobile } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { linkOptions, Outlet, useLocation, useRouterState } from "@tanstack/react-router"; -import { AnimatePresence, motion } from "framer-motion"; import { twMerge } from "tailwind-merge"; import { CreateOrgModal } from "@app/components/organization/CreateOrgModal"; @@ -14,9 +13,9 @@ import { usePopUp } from "@app/hooks"; import { ProjectType } from "@app/hooks/api/workspace/types"; import { InsecureConnectionBanner } from "./components/InsecureConnectionBanner"; -import { MinimizedOrgSidebar } from "./components/MinimizedOrgSidebar"; -import { SidebarHeader } from "./components/SidebarHeader"; +import { OrgSidebar } from "./components/OrgSidebar"; import { DefaultSideBar, ProjectOverviewSideBar, SecretSharingSideBar } from "./ProductsSideBar"; +import { Navbar } from "./components/NavBar"; export const OrganizationLayout = () => { const matches = useRouterState({ select: (s) => s.matches.at(-1)?.context }); @@ -39,74 +38,18 @@ export const OrganizationLayout = () => { const { t } = useTranslation(); - const isSecretSharingPage = ( - [ - linkOptions({ to: "/organization/secret-sharing" }).to, - linkOptions({ to: "/organization/secret-sharing/settings" }).to - ] as string[] - ).includes(location.pathname); - - const isProjectOverviewOrSettingsPage = ( - [ - linkOptions({ to: "/organization/secret-manager/overview" }).to, - linkOptions({ to: "/organization/secret-manager/settings" }).to, - linkOptions({ to: "/organization/cert-manager/overview" }).to, - linkOptions({ to: "/organization/cert-manager/settings" }).to, - linkOptions({ to: "/organization/kms/overview" }).to, - linkOptions({ to: "/organization/kms/settings" }).to, - linkOptions({ to: "/organization/ssh/overview" }).to, - linkOptions({ to: "/organization/ssh/settings" }).to, - linkOptions({ to: "/organization/secret-scanning/overview" }).to, - linkOptions({ to: "/organization/secret-scanning/settings" }).to - ] as string[] - ).includes(location.pathname); - - const shouldShowOrgSidebar = - location.pathname.startsWith("/organization") && - (!isSecretSharingPage || shouldShowProductsSidebar); - const containerHeight = config.pageFrameContent ? "h-[94vh]" : "h-screen"; - let SideBarComponent = ; - - if (isSecretSharingPage) { - SideBarComponent = ; - } else if (isProjectOverviewOrSettingsPage) { - SideBarComponent = ( - - ); - } - return ( <>