Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

feat: introduce dataroom sidebar

Marc Seitz720736df3daa
diff --git a/components/layouts/app.tsx b/components/layouts/app.tsx
index 61249a7e..f8754195 100644
--- a/components/layouts/app.tsx
+++ b/components/layouts/app.tsx
@@ -1,129 +1,65 @@
import { useRouter } from "next/router";
-import { useCallback, useEffect, useRef, useState } from "react";
+import { useCallback, useState } from "react";
import Cookies from "js-cookie";
import { AppBreadcrumb } from "@/components/layouts/breadcrumb";
import TrialBanner from "@/components/layouts/trial-banner";
-import { AppSidebar } from "@/components/sidebar/app-sidebar";
+import { SidebarPanels } from "@/components/sidebar/sidebar-panels";
import { Separator } from "@/components/ui/separator";
import {
SIDEBAR_COOKIE_NAME,
+ Sidebar,
SidebarInset,
SidebarProvider,
SidebarTrigger,
} from "@/components/ui/sidebar";
-// import { usePlan } from "@/lib/swr/use-billing";
-// import YearlyUpgradeBanner from "@/components/billing/yearly-upgrade-banner";
-
import { BlockingModal } from "./blocking-modal";
-const DATAROOM_SIDEBAR_COOKIE_NAME = "sidebar:dataroom-state";
-
-// Helper to get initial sidebar state synchronously (avoids flash)
function getInitialSidebarState(isDataroom: boolean): boolean {
- if (typeof window === "undefined") return false; // SSR: default closed to avoid flash
+ if (typeof window === "undefined") return false;
- // For dataroom pages, check dataroom-specific cookie first
if (isDataroom) {
- const dataroomCookie = Cookies.get(DATAROOM_SIDEBAR_COOKIE_NAME);
- if (dataroomCookie !== undefined) {
- return dataroomCookie === "true";
- }
- // No dataroom preference set yet - default to closed for datarooms
- return false;
+ return true;
}
- // For non-dataroom pages, use main cookie
const mainCookie = Cookies.get(SIDEBAR_COOKIE_NAME);
if (mainCookie !== undefined) {
return mainCookie === "true";
}
- return true; // Default open for non-dataroom pages
+ return true;
}
export default function AppLayout({ children }: { children: React.ReactNode }) {
const router = useRouter();
const isDataroom = router.pathname.startsWith("/datarooms/[id]");
- // Use lazy initializer to compute initial state synchronously (avoids flash)
const [sidebarOpen, setSidebarOpen] = useState(() =>
getInitialSidebarState(isDataroom),
);
- // Track previous dataroom state for transitions
- const prevIsDataroomRef = useRef<boolean>(isDataroom);
- const isFirstRenderRef = useRef(true);
-
- // Handle initial mount and transitions between dataroom/non-dataroom
- useEffect(() => {
- if (isFirstRenderRef.current) {
- isFirstRenderRef.current = false;
- // Set cookie on initial mount if in dataroom and no preference exists
- if (
- isDataroom &&
- Cookies.get(DATAROOM_SIDEBAR_COOKIE_NAME) === undefined
- ) {
- Cookies.set(DATAROOM_SIDEBAR_COOKIE_NAME, "false", { expires: 7 });
- }
- return;
- }
-
- // Transitioning from non-dataroom to dataroom
- if (!prevIsDataroomRef.current && isDataroom) {
- setSidebarOpen(false);
- Cookies.set(DATAROOM_SIDEBAR_COOKIE_NAME, "false", { expires: 7 });
- }
-
- // Transitioning from dataroom to non-dataroom
- if (prevIsDataroomRef.current && !isDataroom) {
- Cookies.remove(DATAROOM_SIDEBAR_COOKIE_NAME);
- // Restore main sidebar state
- const mainCookie = Cookies.get(SIDEBAR_COOKIE_NAME);
- // setSidebarOpen(mainCookie === "true");
- setSidebarOpen(mainCookie !== undefined ? mainCookie === "true" : true);
- }
-
- prevIsDataroomRef.current = isDataroom;
- }, [isDataroom]);
-
- // Handle sidebar state changes - save to appropriate cookie
const handleSidebarOpenChange = useCallback(
(open: boolean) => {
setSidebarOpen(open);
- if (isDataroom) {
- Cookies.set(DATAROOM_SIDEBAR_COOKIE_NAME, String(open), { expires: 7 });
- }
},
- [isDataroom],
+ [],
);
- // const { isAnnualPlan, isFree } = usePlan();
- // const [showYearlyBanner, setShowYearlyBanner] = useState<boolean | null>(null);
-
- // Show banner only for paid monthly subscribers (not free, not yearly)
- // useEffect(() => {
- // // Hide banner for free users or yearly subscribers
- // if (isFree || isAnnualPlan) {
- // setShowYearlyBanner(false);
- // return;
- // }
-
- // // Show banner for monthly paid users (if not dismissed)
- // if (Cookies.get("hideYearlyUpgradeBanner") !== "yearly-upgrade-banner") {
- // setShowYearlyBanner(true);
- // } else {
- // setShowYearlyBanner(false);
- // }
- // }, [isFree, isAnnualPlan]);
-
return (
<SidebarProvider open={sidebarOpen} onOpenChange={handleSidebarOpenChange}>
<div className="flex min-w-0 flex-1 flex-col gap-x-1 bg-gray-50 dark:bg-black md:flex-row">
- <AppSidebar />
+ <Sidebar
+ className="bg-gray-50 dark:bg-black"
+ sidebarClassName="bg-gray-50 dark:bg-black"
+ side="left"
+ variant="inset"
+ collapsible="icon"
+ >
+ <SidebarPanels />
+ </Sidebar>
<SidebarInset className="min-w-0 ring-1 ring-gray-200 dark:ring-gray-800">
<header className="flex h-10 shrink-0 items-center gap-2">
<div className="flex items-center gap-2 px-4">
@@ -137,9 +73,6 @@ export default function AppLayout({ children }: { children: React.ReactNode }) {
<main className="min-w-0 flex-1">{children}</main>
</SidebarInset>
</div>
- {/* {showYearlyBanner && (
- <YearlyUpgradeBanner setShowBanner={setShowYearlyBanner} />
- )} */}
</SidebarProvider>
);
}
diff --git a/components/sidebar/app-sidebar.tsx b/components/sidebar/app-sidebar.tsx
index 22396f5c..6e5f4a2b 100644
--- a/components/sidebar/app-sidebar.tsx
+++ b/components/sidebar/app-sidebar.tsx
@@ -1,6 +1,5 @@
"use client";
-import Link from "next/link";
import { useRouter } from "next/router";
import * as React from "react";
@@ -16,9 +15,7 @@ import {
FolderIcon,
HouseIcon,
Loader,
- PauseCircleIcon,
ServerIcon,
- Sparkles as SparklesIcon,
WorkflowIcon,
} from "lucide-react";
@@ -31,7 +28,6 @@ import { useSlackIntegration } from "@/lib/swr/use-slack-integration";
import { nFormatter } from "@/lib/utils";
import { NavMain } from "@/components/sidebar/nav-main";
-import { NavUser } from "@/components/sidebar/nav-user";
import { TeamSwitcher } from "@/components/sidebar/team-switcher";
import {
Sidebar,
@@ -44,27 +40,20 @@ import {
import ProBanner from "../billing/pro-banner";
import { Progress } from "../ui/progress";
-import { BadgeTooltip } from "../ui/tooltip";
import SlackBanner from "./banners/slack-banner";
-export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
+export function AppSidebarContent() {
const router = useRouter();
const [showProBanner, setShowProBanner] = useState<boolean | null>(null);
const [showSlackBanner, setShowSlackBanner] = useState<boolean | null>(null);
const { currentTeam, teams, setCurrentTeam, isLoading }: TeamContextType =
useTeam() || initialState;
const {
- plan: userPlan,
- isAnnualPlan,
- isPro,
isBusiness,
isDatarooms,
isDataroomsPlus,
- isDataroomsPremium,
- isDataroomsUnlimited,
isFree,
isTrial,
- isPaused,
} = usePlan();
const { limits } = useLimits();
@@ -227,18 +216,11 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
: []),
],
},
- // {
- // title: "2025 Recap",
- // url: "/dashboard?openRecap=true",
- // icon: SparklesIcon,
- // current: false,
- // },
],
};
// Filter out items that should be hidden based on feature flags
const filteredNavMain = data.navMain.filter((item) => {
- // Hide workflows if feature flag is not enabled
if (item.title === "Workflows" && !features?.workflows) {
return false;
}
@@ -246,66 +228,8 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
});
return (
- <Sidebar
- className="bg-gray-50 dark:bg-black"
- sidebarClassName="bg-gray-50 dark:bg-black"
- side="left"
- variant="inset"
- collapsible="icon"
- {...props}
- >
- <SidebarHeader className="gap-y-8">
- <p className="hidden w-full justify-center text-2xl font-bold tracking-tighter text-black group-data-[collapsible=icon]:inline-flex dark:text-white">
- <Link href="/dashboard">P</Link>
- </p>
- <p className="ml-2 flex items-center text-2xl font-bold tracking-tighter text-black group-data-[collapsible=icon]:hidden dark:text-white">
- <Link href="/dashboard">Papermark</Link>
- {userPlan && !isFree && !isDataroomsPlus && !isDataroomsPremium ? (
- <span className="relative ml-4 inline-flex items-center rounded-full bg-background px-2.5 py-1 text-xs tracking-normal text-foreground ring-1 ring-gray-800">
- {userPlan.charAt(0).toUpperCase() + userPlan.slice(1)}
- {isPaused ? (
- <BadgeTooltip content="Subscription paused">
- <PauseCircleIcon className="absolute -right-1.5 -top-1.5 h-5 w-5 rounded-full bg-background text-amber-500" />
- </BadgeTooltip>
- ) : null}
- </span>
- ) : null}
- {isDataroomsPlus && !isDataroomsPremium ? (
- <span className="relative ml-4 inline-flex items-center rounded-full bg-background px-2.5 py-1 text-xs tracking-normal text-foreground ring-1 ring-gray-800">
- Datarooms+
- {isPaused ? (
- <BadgeTooltip content="Subscription paused">
- <PauseCircleIcon className="absolute -right-1.5 -top-1.5 h-5 w-5 rounded-full bg-background text-amber-500" />
- </BadgeTooltip>
- ) : null}
- </span>
- ) : null}
- {isDataroomsPremium && !isDataroomsUnlimited ? (
- <span className="relative ml-4 inline-flex items-center rounded-full bg-background px-2.5 py-1 text-xs tracking-normal text-foreground ring-1 ring-gray-800">
- Premium
- {isPaused ? (
- <BadgeTooltip content="Subscription paused">
- <PauseCircleIcon className="absolute -right-1.5 -top-1.5 h-5 w-5 rounded-full bg-background text-amber-500" />
- </BadgeTooltip>
- ) : null}
- </span>
- ) : null}
- {isDataroomsUnlimited ? (
- <span className="relative ml-4 inline-flex items-center rounded-full bg-background px-2.5 py-1 text-xs tracking-normal text-foreground ring-1 ring-gray-800">
- Unlimited
- {isPaused ? (
- <BadgeTooltip content="Subscription paused">
- <PauseCircleIcon className="absolute -right-1.5 -top-1.5 h-5 w-5 rounded-full bg-background text-amber-500" />
- </BadgeTooltip>
- ) : null}
- </span>
- ) : null}
- {isTrial ? (
- <span className="ml-2 rounded-sm bg-foreground px-2 py-0.5 text-xs tracking-normal text-background ring-1 ring-gray-800">
- Trial
- </span>
- ) : null}
- </p>
+ <>
+ <SidebarHeader className="gap-y-0 pt-0">
{isLoading ? (
<div className="flex items-center gap-2 text-sm">
<Loader className="h-5 w-5 animate-spin" /> Loading teams...
@@ -325,15 +249,9 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
<SidebarMenu className="group-data-[collapsible=icon]:hidden">
<SidebarMenuItem>
<div>
- {/*
- * Show Slack banner to all users if they haven't dismissed it and don't have Slack connected
- */}
{!slackIntegration && showSlackBanner ? (
<SlackBanner setShowSlackBanner={setShowSlackBanner} />
) : null}
- {/*
- * if user is free and showProBanner is true show pro banner
- */}
{isFree && !isTrial && showProBanner ? (
<ProBanner setShowProBanner={setShowProBanner} />
) : null}
@@ -364,8 +282,22 @@ export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
</div>
</SidebarMenuItem>
</SidebarMenu>
- <NavUser />
</SidebarFooter>
+ </>
+ );
+}
+
+export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
+ return (
+ <Sidebar
+ className="bg-gray-50 dark:bg-black"
+ sidebarClassName="bg-gray-50 dark:bg-black"
+ side="left"
+ variant="inset"
+ collapsible="icon"
+ {...props}
+ >
+ <AppSidebarContent />
</Sidebar>
);
}
diff --git a/components/sidebar/dataroom-sidebar.tsx b/components/sidebar/dataroom-sidebar.tsx
new file mode 100644
index 00000000..7265a5cb
--- /dev/null
+++ b/components/sidebar/dataroom-sidebar.tsx
@@ -0,0 +1,393 @@
+"use client";
+
+import Link from "next/link";
+import { useRouter } from "next/router";
+
+import { useEffect, useRef, useState } from "react";
+
+import { PlanEnum } from "@/ee/stripe/constants";
+import {
+ BarChart3Icon,
+ BellIcon,
+ BookOpenIcon,
+ BrushIcon,
+ ChevronLeftIcon,
+ ChevronRight,
+ CogIcon,
+ DownloadIcon,
+ FolderIcon,
+ LinkIcon,
+ LogsIcon,
+ MessageSquareIcon,
+ SendIcon,
+ ShieldCheckIcon,
+ ShieldIcon,
+ TableIcon,
+ UsersIcon,
+} from "lucide-react";
+
+import { useDataroom } from "@/lib/swr/use-dataroom";
+import useLimits from "@/lib/swr/use-limits";
+import { cn } from "@/lib/utils";
+
+import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { DataroomLinkSheet } from "@/components/links/link-sheet/dataroom-link-sheet";
+import { Button } from "@/components/ui/button";
+import {
+ Collapsible,
+ CollapsibleContent,
+ CollapsibleTrigger,
+} from "@/components/ui/collapsible";
+import {
+ SidebarContent,
+ SidebarGroup,
+ SidebarHeader,
+ SidebarMenu,
+ SidebarMenuAction,
+ SidebarMenuButton,
+ SidebarMenuItem,
+ SidebarMenuSub,
+ SidebarMenuSubButton,
+ SidebarMenuSubItem,
+ useSidebar,
+} from "@/components/ui/sidebar";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from "@/components/ui/tooltip";
+
+function ScrollingText({
+ children,
+ className,
+}: {
+ children: React.ReactNode;
+ className?: string;
+}) {
+ const containerRef = useRef<HTMLDivElement>(null);
+ const textRef = useRef<HTMLSpanElement>(null);
+ const [overflow, setOverflow] = useState(0);
+ const [hovered, setHovered] = useState(false);
+
+ useEffect(() => {
+ const container = containerRef.current;
+ const text = textRef.current;
+ if (!container || !text) return;
+
+ const check = () => {
+ const diff = text.scrollWidth - container.clientWidth;
+ setOverflow(diff > 0 ? diff : 0);
+ };
+ check();
+
+ const observer = new ResizeObserver(check);
+ observer.observe(container);
+ return () => observer.disconnect();
+ }, [children]);
+
+ const animate = overflow > 0 && hovered;
+
+ return (
+ <div
+ ref={containerRef}
+ className={cn("overflow-hidden", className)}
+ onMouseEnter={() => setHovered(true)}
+ onMouseLeave={() => setHovered(false)}
+ >
+ <span
+ ref={textRef}
+ className={cn(
+ "inline-block whitespace-nowrap transition-transform duration-300 ease-in-out",
+ !animate && "!translate-x-0",
+ )}
+ style={
+ animate
+ ? ({
+ "--marquee-offset": `-${overflow}px`,
+ transform: `translateX(var(--marquee-offset))`,
+ transitionDuration: `${Math.max(overflow * 8, 600)}ms`,
+ } as React.CSSProperties)
+ : undefined
+ }
+ >
+ {children}
+ </span>
+ </div>
+ );
+}
+
+export function DataroomSidebarContent() {
+ const router = useRouter();
+ const { dataroom } = useDataroom();
+ const { limits } = useLimits();
+ const { state } = useSidebar();
+ const dataroomId = dataroom?.id ?? (router.query.id as string);
+ const [isLinkSheetOpen, setIsLinkSheetOpen] = useState(false);
+
+ const navItems = [
+ {
+ title: "Documents",
+ href: `/datarooms/${dataroomId}/documents`,
+ icon: FolderIcon,
+ segment: "documents",
+ },
+ {
+ title: "Permissions",
+ href: `/datarooms/${dataroomId}/permissions`,
+ icon: ShieldCheckIcon,
+ segment: "permissions",
+ segments: ["permissions", "groups"],
+ items: [
+ {
+ title: "Links",
+ href: `/datarooms/${dataroomId}/permissions`,
+ icon: LinkIcon,
+ },
+ {
+ title: "Groups",
+ href: `/datarooms/${dataroomId}/groups`,
+ icon: UsersIcon,
+ },
+ ],
+ },
+ {
+ title: "Analytics",
+ href: `/datarooms/${dataroomId}/analytics`,
+ icon: BarChart3Icon,
+ segment: "analytics",
+ items: [
+ {
+ title: "Overview",
+ href: `/datarooms/${dataroomId}/analytics`,
+ icon: TableIcon,
+ },
+ {
+ title: "Audit Log",
+ href: `/datarooms/${dataroomId}/analytics/audit-log`,
+ icon: LogsIcon,
+ },
+ ],
+ },
+ {
+ title: "Q&A",
+ href: `/datarooms/${dataroomId}/conversations`,
+ icon: MessageSquareIcon,
+ segment: "conversations",
+ limited: !limits?.conversationsInDataroom,
+ },
+ {
+ title: "Branding",
+ href: `/datarooms/${dataroomId}/branding`,
+ icon: BrushIcon,
+ segment: "branding",
+ },
+ {
+ title: "Settings",
+ href: `/datarooms/${dataroomId}/settings`,
+ icon: CogIcon,
+ segment: "settings",
+ items: [
+ {
+ title: "General",
+ href: `/datarooms/${dataroomId}/settings`,
+ icon: CogIcon,
+ },
+ {
+ title: "Introduction",
+ href: `/datarooms/${dataroomId}/settings/introduction`,
+ icon: BookOpenIcon,
+ },
+ {
+ title: "Notifications",
+ href: `/datarooms/${dataroomId}/settings/notifications`,
+ icon: BellIcon,
+ },
+ {
+ title: "Downloads",
+ href: `/datarooms/${dataroomId}/settings/downloads`,
+ icon: DownloadIcon,
+ },
+ {
+ title: "File Permissions",
+ href: `/datarooms/${dataroomId}/settings/file-permissions`,
+ icon: ShieldIcon,
+ },
+ ],
+ },
+ ];
+
+ const currentPath = router.asPath;
+
+ const isItemActive = (item: (typeof navItems)[number]) => {
+ const segments = item.segments ?? [item.segment];
+ if (item.segment === "documents") {
+ return (
+ currentPath.includes(`/datarooms/${dataroomId}/documents`) ||
+ currentPath === `/datarooms/${dataroomId}`
+ );
+ }
+ return segments.some((seg) =>
+ currentPath.includes(`/datarooms/${dataroomId}/${seg}`),
+ );
+ };
+
+ return (
+ <>
+ <SidebarHeader className="gap-y-3 pt-0">
+ <Link
+ href="/datarooms"
+ className="group/back flex items-center gap-2 rounded-lg text-foreground"
+ >
+ <span className="flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border bg-background text-muted-foreground transition-transform duration-150 group-hover/back:-translate-x-0.5">
+ <ChevronLeftIcon className="h-4 w-4" />
+ </span>
+ <div className="min-w-0 group-data-[collapsible=icon]:hidden">
+ <ScrollingText className="text-lg font-semibold leading-tight">
+ {dataroom?.internalName || dataroom?.name || "Loading..."}
+ </ScrollingText>
+ {dataroom?.internalName && dataroom?.name ? (
+ <p className="truncate text-xs text-muted-foreground">
+ {dataroom.name}
+ </p>
+ ) : null}
+ </div>
+ </Link>
+ </SidebarHeader>
+
+ <SidebarContent>
+ <SidebarGroup>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button
+ className="w-full group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2"
+ size="sm"
+ onClick={() => setIsLinkSheetOpen(true)}
+ >
+ <span className="group-data-[collapsible=icon]:hidden">
+ Share dataroom
+ </span>
+ <SendIcon className="hidden !size-4 shrink-0 group-data-[collapsible=icon]:block" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent
+ side="right"
+ align="center"
+ hidden={state !== "collapsed"}
+ >
+ Share dataroom
+ </TooltipContent>
+ </Tooltip>
+ </SidebarGroup>
+
+ <SidebarGroup>
+ <SidebarMenu className="space-y-0.5 text-foreground">
+ {navItems.map((item) => {
+ const active = isItemActive(item);
+ const hasSubItems = item.items && item.items.length > 0;
+
+ if (item.limited) {
+ return (
+ <SidebarMenuItem key={item.title}>
+ <UpgradePlanModal
+ clickedPlan={PlanEnum.DataRoomsPlus}
+ trigger={`sidebar_dataroom_${item.segment}`}
+ >
+ <SidebarMenuButton
+ tooltip={item.title}
+ className="text-muted-foreground"
+ >
+ <item.icon className="h-4 w-4" />
+ <span>{item.title}</span>
+ </SidebarMenuButton>
+ </UpgradePlanModal>
+ </SidebarMenuItem>
+ );
+ }
+
+ if (hasSubItems) {
+ return (
+ <Collapsible key={item.title} asChild defaultOpen={active}>
+ <SidebarMenuItem>
+ <SidebarMenuButton
+ asChild
+ tooltip={item.title}
+ className={cn(
+ active &&
+ "rounded-md bg-gray-200 font-semibold dark:bg-secondary",
+ )}
+ >
+ <Link href={item.href}>
+ <item.icon className="h-4 w-4" />
+ <span>{item.title}</span>
+ </Link>
+ </SidebarMenuButton>
+ <CollapsibleTrigger asChild>
+ <SidebarMenuAction className="data-[state=open]:rotate-90">
+ <ChevronRight />
+ <span className="sr-only">Toggle</span>
+ </SidebarMenuAction>
+ </CollapsibleTrigger>
+ <CollapsibleContent>
+ <SidebarMenuSub className="mr-0 pr-0">
+ {item.items!.map((subItem) => {
+ const isBaseSubItem = subItem.href === item.href;
+ const subActive = isBaseSubItem
+ ? currentPath === subItem.href
+ : currentPath === subItem.href ||
+ currentPath.startsWith(subItem.href + "/");
+ return (
+ <SidebarMenuSubItem
+ key={subItem.title}
+ className={cn(
+ subActive &&
+ "rounded-md bg-gray-200 font-semibold dark:bg-secondary",
+ )}
+ >
+ <SidebarMenuSubButton asChild>
+ <Link href={subItem.href}>
+ {subItem.icon && (
+ <subItem.icon className="h-4 w-4" />
+ )}
+ <span>{subItem.title}</span>
+ </Link>
+ </SidebarMenuSubButton>
+ </SidebarMenuSubItem>
+ );
+ })}
+ </SidebarMenuSub>
+ </CollapsibleContent>
+ </SidebarMenuItem>
+ </Collapsible>
+ );
+ }
+
+ return (
+ <SidebarMenuItem key={item.title}>
+ <SidebarMenuButton
+ asChild
+ tooltip={item.title}
+ className={cn(
+ active &&
+ "rounded-md bg-gray-200 font-semibold dark:bg-secondary",
+ )}
+ >
+ <Link href={item.href}>
+ <item.icon className="h-4 w-4" />
+ <span>{item.title}</span>
+ </Link>
+ </SidebarMenuButton>
+ </SidebarMenuItem>
+ );
+ })}
+ </SidebarMenu>
+ </SidebarGroup>
+ </SidebarContent>
+
+ <DataroomLinkSheet
+ isOpen={isLinkSheetOpen}
+ setIsOpen={setIsLinkSheetOpen}
+ linkType="DATAROOM_LINK"
+ />
+ </>
+ );
+}
diff --git a/components/sidebar/sidebar-panels.tsx b/components/sidebar/sidebar-panels.tsx
new file mode 100644
index 00000000..f3a4dffe
--- /dev/null
+++ b/components/sidebar/sidebar-panels.tsx
@@ -0,0 +1,143 @@
+"use client";
+
+import Link from "next/link";
+import { useRouter } from "next/router";
+
+import { useEffect, useState } from "react";
+
+import { PauseCircleIcon } from "lucide-react";
+import { motion } from "motion/react";
+
+import { usePlan } from "@/lib/swr/use-billing";
+
+import { NavUser } from "@/components/sidebar/nav-user";
+import { SidebarFooter, SidebarHeader } from "@/components/ui/sidebar";
+import { BadgeTooltip } from "@/components/ui/tooltip";
+
+import { AppSidebarContent } from "./app-sidebar";
+import { DataroomSidebarContent } from "./dataroom-sidebar";
+
+let lastKnownIsDataroom: boolean | null = null;
+
+function SidebarBrandHeader() {
+ const {
+ plan: userPlan,
+ isFree,
+ isDataroomsPlus,
+ isDataroomsPremium,
+ isDataroomsUnlimited,
+ isPaused,
+ isTrial,
+ } = usePlan();
+
+ return (
+ <SidebarHeader className="gap-y-0 pb-4">
+ <p className="hidden w-full justify-center text-2xl font-bold tracking-tighter text-black group-data-[collapsible=icon]:inline-flex dark:text-white">
+ <Link href="/dashboard">P</Link>
+ </p>
+ <p className="ml-2 flex items-center text-2xl font-bold tracking-tighter text-black group-data-[collapsible=icon]:hidden dark:text-white">
+ <Link href="/dashboard">Papermark</Link>
+ {userPlan && !isFree && !isDataroomsPlus && !isDataroomsPremium ? (
+ <span className="relative ml-4 inline-flex items-center rounded-full bg-background px-2.5 py-1 text-xs tracking-normal text-foreground ring-1 ring-gray-800">
+ {userPlan.charAt(0).toUpperCase() + userPlan.slice(1)}
+ {isPaused ? (
+ <BadgeTooltip content="Subscription paused">
+ <PauseCircleIcon className="absolute -right-1.5 -top-1.5 h-5 w-5 rounded-full bg-background text-amber-500" />
+ </BadgeTooltip>
+ ) : null}
+ </span>
+ ) : null}
+ {isDataroomsPlus && !isDataroomsPremium ? (
+ <span className="relative ml-4 inline-flex items-center rounded-full bg-background px-2.5 py-1 text-xs tracking-normal text-foreground ring-1 ring-gray-800">
+ Datarooms+
+ {isPaused ? (
+ <BadgeTooltip content="Subscription paused">
+ <PauseCircleIcon className="absolute -right-1.5 -top-1.5 h-5 w-5 rounded-full bg-background text-amber-500" />
+ </BadgeTooltip>
+ ) : null}
+ </span>
+ ) : null}
+ {isDataroomsPremium && !isDataroomsUnlimited ? (
+ <span className="relative ml-4 inline-flex items-center rounded-full bg-background px-2.5 py-1 text-xs tracking-normal text-foreground ring-1 ring-gray-800">
+ Premium
+ {isPaused ? (
+ <BadgeTooltip content="Subscription paused">
+ <PauseCircleIcon className="absolute -right-1.5 -top-1.5 h-5 w-5 rounded-full bg-background text-amber-500" />
+ </BadgeTooltip>
+ ) : null}
+ </span>
+ ) : null}
+ {isDataroomsUnlimited ? (
+ <span className="relative ml-4 inline-flex items-center rounded-full bg-background px-2.5 py-1 text-xs tracking-normal text-foreground ring-1 ring-gray-800">
+ Unlimited
+ {isPaused ? (
+ <BadgeTooltip content="Subscription paused">
+ <PauseCircleIcon className="absolute -right-1.5 -top-1.5 h-5 w-5 rounded-full bg-background text-amber-500" />
+ </BadgeTooltip>
+ ) : null}
+ </span>
+ ) : null}
+ {isTrial ? (
+ <span className="ml-2 rounded-sm bg-foreground px-2 py-0.5 text-xs tracking-normal text-background ring-1 ring-gray-800">
+ Trial
+ </span>
+ ) : null}
+ </p>
+ </SidebarHeader>
+ );
+}
+
+export function SidebarPanels() {
+ const router = useRouter();
+ const isDataroom = router.pathname.startsWith("/datarooms/[id]");
+
+ const [animDirection] = useState<"enter" | "leave" | null>(() => {
+ if (lastKnownIsDataroom === null) return null;
+ if (isDataroom && !lastKnownIsDataroom) return "enter";
+ if (!isDataroom && lastKnownIsDataroom) return "leave";
+ return null;
+ });
+
+ useEffect(() => {
+ lastKnownIsDataroom = isDataroom;
+ }, [isDataroom]);
+
+ const [animating, setAnimating] = useState(animDirection !== null);
+
+ if (animDirection) {
+ return (
+ <div className="flex h-full flex-col">
+ <SidebarBrandHeader />
+ <div
+ className={`flex min-h-0 flex-1 flex-col ${animating ? "overflow-hidden" : ""}`}
+ >
+ <motion.div
+ initial={{
+ x: animDirection === "enter" ? "100%" : "-100%",
+ opacity: 0,
+ }}
+ animate={{ x: 0, opacity: 1 }}
+ transition={{ duration: 0.25, ease: "easeOut" }}
+ onAnimationComplete={() => setAnimating(false)}
+ className="flex min-h-0 flex-1 flex-col"
+ >
+ {isDataroom ? <DataroomSidebarContent /> : <AppSidebarContent />}
+ </motion.div>
+ </div>
+ <SidebarFooter>
+ <NavUser />
+ </SidebarFooter>
+ </div>
+ );
+ }
+
+ return (
+ <div className="flex h-full flex-col">
+ <SidebarBrandHeader />
+ {isDataroom ? <DataroomSidebarContent /> : <AppSidebarContent />}
+ <SidebarFooter>
+ <NavUser />
+ </SidebarFooter>
+ </div>
+ );
+}