Skip to content

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

add 'Home' to sidebar folders for easy navigation

Ashish Viradiya7729e0fe1635
diff --git a/components/datarooms/folders/sidebar-tree.tsx b/components/datarooms/folders/sidebar-tree.tsx
index 6b8f5d25..c1dffea2 100644
--- a/components/datarooms/folders/sidebar-tree.tsx
+++ b/components/datarooms/folders/sidebar-tree.tsx
@@ -2,12 +2,15 @@ import { useRouter } from "next/router";
import { memo, useMemo } from "react";
-import { FileTree } from "@/components/ui/nextra-filetree";
+import { HomeIcon } from "lucide-react";
import {
DataroomFolderWithDocuments,
useDataroomFoldersTree,
} from "@/lib/swr/use-dataroom";
+import { cn } from "@/lib/utils";
+
+import { FileTree } from "@/components/ui/nextra-filetree";
import { buildNestedFolderStructure } from "./utils";
@@ -114,3 +117,34 @@ export function SidebarFolderTree({ dataroomId }: { dataroomId: string }) {
return <SidebarFolders dataroomId={dataroomId} folders={folders} />;
}
+
+export const SidebarLink = memo(
+ ({ href, label }: { href: string; label: string }) => {
+ const router = useRouter();
+ const isActive = router.asPath === href;
+
+ return (
+ <li
+ className={cn(
+ "flex list-none",
+ "rounded-md text-foreground transition-all duration-200 ease-in-out",
+ "hover:bg-gray-100 hover:shadow-sm hover:dark:bg-muted",
+ "px-3 py-1.5 leading-6",
+ isActive && "bg-gray-100 font-semibold dark:bg-muted",
+ )}
+ >
+ <span
+ className="ml-5 inline-flex w-full cursor-pointer items-center"
+ onClick={() => router.push(href)}
+ >
+ <HomeIcon className="h-5 w-5 shrink-0" aria-hidden="true" />
+ <span className="ml-2 w-fit truncate" title={label}>
+ {label}
+ </span>
+ </span>
+ </li>
+ );
+ },
+);
+
+SidebarLink.displayName = "SidebarLink";
\ No newline at end of file
diff --git a/components/ui/nextra-filetree.tsx b/components/ui/nextra-filetree.tsx
index 5bcb28bb..2ccdb128 100644
--- a/components/ui/nextra-filetree.tsx
+++ b/components/ui/nextra-filetree.tsx
@@ -53,7 +53,7 @@ interface FileProps {
function Tree({ children }: { children: ReactNode }): ReactElement {
return (
<div className={cn("nextra-filetree !mt-0 w-full select-none text-sm")}>
- <div className="block rounded-lg">{children}</div>
+ <div className="block space-y-1 rounded-lg">{children}</div>
</div>
);
}
@@ -110,7 +110,7 @@ const Folder = memo<FolderProps>(
const isFolderOpen = open === undefined ? isOpen : open;
return (
- <li className="flex w-full list-none flex-col">
+ <li className="flex w-full list-none flex-col space-y-1">
<div
title={name}
className={cn(