Skip to content

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

feat: add branding layouts

Iuliia Shnai9af33b95de0e
diff --git a/components/billing/upgrade-plan-modal.tsx b/components/billing/upgrade-plan-modal.tsx
index 65c6dd9f..282fcc4b 100644
--- a/components/billing/upgrade-plan-modal.tsx
+++ b/components/billing/upgrade-plan-modal.tsx
@@ -167,6 +167,7 @@ export function UpgradePlanModal({
open,
setOpen,
highlightItem,
+ hideItems,
children,
}: {
clickedPlan: PlanEnum;
@@ -174,6 +175,10 @@ export function UpgradePlanModal({
open?: boolean;
setOpen?: React.Dispatch<React.SetStateAction<boolean>>;
highlightItem?: string[];
+ /** Feature ids (or `aliasIds`) to omit from every plan card's feature list.
+ * Use this when the upsell is about a specific feature and a generic line
+ * (e.g. "Unlimited data rooms") would distract from the message. */
+ hideItems?: string[];
children?: React.ReactNode;
}) {
const router = useRouter();
@@ -484,7 +489,20 @@ export function UpgradePlanModal({
</p>
<ul className="mb-6 mt-2 space-y-2 text-sm leading-6 text-gray-600 dark:text-gray-300">
- {planFeatures.features.map((feature, i) => {
+ {planFeatures.features
+ .filter((feature) => {
+ if (!hideItems?.length) return true;
+ if (hideItems.includes(feature.id)) return false;
+ if (
+ feature.aliasIds?.some((alias) =>
+ hideItems.includes(alias),
+ )
+ ) {
+ return false;
+ }
+ return true;
+ })
+ .map((feature, i) => {
const isDataRoomPlan =
effectivePlan === PlanEnum.DataRooms ||
effectivePlan === PlanEnum.DataRoomsPlus ||
@@ -494,7 +512,12 @@ export function UpgradePlanModal({
<FeatureItem
feature={{
...feature,
- isHighlighted: feature.isHighlighted || highlightItem?.includes(feature.id),
+ isHighlighted:
+ feature.isHighlighted ||
+ highlightItem?.includes(feature.id) ||
+ feature.aliasIds?.some((alias) =>
+ highlightItem?.includes(alias),
+ ),
}}
onUnlimitedClick={
feature.isUsers && isDataRoomPlan
diff --git a/components/datarooms/actions/rebuild-index-button.tsx b/components/datarooms/actions/rebuild-index-button.tsx
index a143792e..99056f70 100644
--- a/components/datarooms/actions/rebuild-index-button.tsx
+++ b/components/datarooms/actions/rebuild-index-button.tsx
@@ -21,8 +21,9 @@ import {
import { ResponsiveButton } from "@/components/ui/responsive-button";
interface RebuildIndexButtonProps {
- teamId: string;
- dataroomId: string;
+ /** Team id from context; may be undefined briefly while layout loads. */
+ teamId?: string;
+ dataroomId?: string;
disabled?: boolean;
}
@@ -57,6 +58,11 @@ export default function RebuildIndexButton({
return;
}
+ if (!teamId || !dataroomId) {
+ toast.error("Missing team or data room. Refresh the page and try again.");
+ return;
+ }
+
try {
setIsLoading(true);
@@ -71,8 +77,15 @@ export default function RebuildIndexButton({
);
if (!response.ok) {
- const errorData = await response.json();
- throw new Error(errorData.message || "Failed to rebuild indexes");
+ const raw = await response.text();
+ let message = "Failed to rebuild indexes";
+ try {
+ const parsed = JSON.parse(raw) as { message?: string };
+ if (typeof parsed.message === "string") message = parsed.message;
+ } catch {
+ if (raw) message = raw;
+ }
+ throw new Error(message);
}
const result = await response.json();
@@ -103,7 +116,7 @@ export default function RebuildIndexButton({
text="Rebuild Index"
variant="outline"
size="sm"
- disabled={disabled}
+ disabled={disabled || !teamId || !dataroomId}
/>
</DialogTrigger>
<DialogContent className="sm:max-w-md">
diff --git a/components/datarooms/folders/sidebar-tree.tsx b/components/datarooms/folders/sidebar-tree.tsx
index 7b640f2d..1b472378 100644
--- a/components/datarooms/folders/sidebar-tree.tsx
+++ b/components/datarooms/folders/sidebar-tree.tsx
@@ -149,7 +149,7 @@ const SidebarFolders = ({
<FileTree>
<SidebarLink
href={`/datarooms/${dataroomId}/documents`}
- label={"Dataroom Home"}
+ label={"Home"}
/>
{nestedFolders.map((folder) => (
<FolderComponent
@@ -178,8 +178,8 @@ export const SidebarLink = memo(
return (
<li
className={cn(
- "flex list-none",
- "rounded-md text-foreground transition-all duration-200 ease-in-out",
+ "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",
diff --git a/components/datarooms/folders/view-tree.tsx b/components/datarooms/folders/view-tree.tsx
index 176fe551..cce93063 100644
--- a/components/datarooms/folders/view-tree.tsx
+++ b/components/datarooms/folders/view-tree.tsx
@@ -199,8 +199,8 @@ const HomeLink = memo(
return (
<li
className={cn(
- "flex list-none",
- "rounded-md transition-all duration-200 ease-in-out",
+ "flex list-none rounded-md",
+ "transition-all duration-200 ease-in-out",
usesLightText
? "text-[var(--viewer-text)] hover:bg-[var(--viewer-control-bg)]"
: "text-foreground hover:bg-gray-100 hover:shadow-sm hover:dark:bg-muted",
@@ -228,8 +228,8 @@ const HomeLink = memo(
}}
>
<HomeIcon className="h-5 w-5 shrink-0" aria-hidden="true" />
- <span className="ml-2 min-w-0 flex-1 truncate" title="Dataroom Home">
- Dataroom Home
+ <span className="ml-2 min-w-0 flex-1 truncate" title="Home">
+ Home
</span>
</span>
</li>
diff --git a/components/datarooms/groups/group-permissions.tsx b/components/datarooms/groups/group-permissions.tsx
index a9748eab..9d7c0232 100644
--- a/components/datarooms/groups/group-permissions.tsx
+++ b/components/datarooms/groups/group-permissions.tsx
@@ -38,7 +38,7 @@ import { cn } from "@/lib/utils";
import {
HIERARCHICAL_DISPLAY_STYLE,
getHierarchicalDisplayName,
- useDataroomIndexEnabled,
+ useDataroomIndexDisplayEnabled,
} from "@/lib/utils/hierarchical-display";
import CloudDownloadOff from "@/components/shared/icons/cloud-download-off";
@@ -60,7 +60,7 @@ import {
} from "@/components/ui/tooltip";
const PermissionItemName = ({ item }: { item: FileOrFolder }) => {
- const isDataroomIndexEnabled = useDataroomIndexEnabled();
+ const isDataroomIndexEnabled = useDataroomIndexDisplayEnabled();
const displayName = getHierarchicalDisplayName(
item.name,
@@ -308,7 +308,7 @@ const buildTree = (
const buildTreeWithRoot = (
items: any[],
permissions: ViewerGroupAccessControls[],
- dataroomName: string = "Dataroom Home",
+ dataroomName: string = "Home",
): FileOrFolder[] => {
// Get all items (folders and root documents)
const allItems = buildTree(items, permissions, null);
@@ -576,7 +576,7 @@ export default function ExpandableTable({
// never wipes out unsaved work in this view.
useEffect(() => {
if (folders && !loading && !hasPendingChanges) {
- const treeData = buildTreeWithRoot(folders, permissions, "Dataroom Home");
+ const treeData = buildTreeWithRoot(folders, permissions, "Home");
setData(treeData);
}
}, [folders, loading, permissions, hasPendingChanges]);
@@ -584,7 +584,7 @@ export default function ExpandableTable({
const handleDiscardChanges = useCallback(() => {
if (!folders) return;
setPendingChanges({});
- setData(buildTreeWithRoot(folders, permissions, "Dataroom Home"));
+ setData(buildTreeWithRoot(folders, permissions, "Home"));
}, [folders, permissions]);
const handleSaveChanges = useCallback(async () => {
diff --git a/components/emails/upgrade-plan.tsx b/components/emails/upgrade-plan.tsx
index 09024151..ff4a6d82 100644
--- a/components/emails/upgrade-plan.tsx
+++ b/components/emails/upgrade-plan.tsx
@@ -39,7 +39,8 @@ const UpgradePlanEmail = ({
const planTypeText = PLAN_TYPE_MAP[planType as keyof typeof PLAN_TYPE_MAP];
const features: any = {
pro: [
- "Custom branding",
+ "Remove Papermark branding",
+ "Custom logo, colors & accents",
"Unlimited link views",
"Folder organization",
"1 team member",
diff --git a/components/links/link-sheet/index.tsx b/components/links/link-sheet/index.tsx
index 6c80e592..bb8ab8ec 100644
--- a/components/links/link-sheet/index.tsx
+++ b/components/links/link-sheet/index.tsx
@@ -88,7 +88,7 @@ export const DEFAULT_LINK_PROPS = (
questionType: null,
enableAgreement: false,
agreementId: null,
- showBanner: linkType === LinkType.DOCUMENT_LINK ? showBanner : false,
+ showBanner: showBanner,
enableWatermark: false,
watermarkConfig: null,
audienceType: groupId ? LinkAudienceType.GROUP : LinkAudienceType.GENERAL,
diff --git a/components/links/link-sheet/link-options.tsx b/components/links/link-sheet/link-options.tsx
index 8243c167..0cb5f5f3 100644
--- a/components/links/link-sheet/link-options.tsx
+++ b/components/links/link-sheet/link-options.tsx
@@ -233,7 +233,14 @@ export const LinkOptions = ({
{/* Custom Branding Section */}
<CollapsibleSection title="Custom Branding" defaultOpen={true}>
<div>
- <WelcomeMessageSection {...{ data, setData }} />
+ <WelcomeMessageSection
+ data={data}
+ setData={setData}
+ isAllowed={
+ isTrial || isBusiness || isDatarooms || isDataroomsPlus
+ }
+ handleUpgradeStateChange={handleUpgradeStateChange}
+ />
<OGSection
{...{ data, setData }}
isAllowed={
diff --git a/components/links/link-sheet/welcome-message-section.tsx b/components/links/link-sheet/welcome-message-section.tsx
index 9673b3ba..6ae5bda1 100644
--- a/components/links/link-sheet/welcome-message-section.tsx
+++ b/components/links/link-sheet/welcome-message-section.tsx
@@ -10,15 +10,25 @@ import { Textarea } from "@/components/ui/textarea";
import { DEFAULT_LINK_TYPE } from ".";
import LinkItem from "./link-item";
+import { LinkUpgradeOptions } from "./link-options";
const MAX_WELCOME_MESSAGE_LENGTH = 80;
export function WelcomeMessageSection({
data,
setData,
+ isAllowed,
+ handleUpgradeStateChange,
}: {
data: DEFAULT_LINK_TYPE;
setData: React.Dispatch<React.SetStateAction<DEFAULT_LINK_TYPE>>;
+ isAllowed: boolean;
+ handleUpgradeStateChange: ({
+ state,
+ trigger,
+ plan,
+ highlightItem,
+ }: LinkUpgradeOptions) => void;
}) {
const { welcomeMessage } = data;
const [enabled, setEnabled] = useState<boolean>(!!welcomeMessage);
@@ -33,9 +43,8 @@ export function WelcomeMessageSection({
const handleWelcomeMessageToggle = () => {
const updatedEnabled = !enabled;
setEnabled(updatedEnabled);
-
+
if (!updatedEnabled) {
- // Clear the welcome message when disabled
setData({ ...data, welcomeMessage: null });
setWelcomeMessageError(null);
}
@@ -64,9 +73,19 @@ export function WelcomeMessageSection({
tooltipContent="Override the default welcome message for this link"
enabled={enabled}
action={handleWelcomeMessageToggle}
+ isAllowed={isAllowed}
+ requiredPlan="business"
+ upgradeAction={() =>
+ handleUpgradeStateChange({
+ state: true,
+ trigger: "link_sheet_welcome_message_section",
+ plan: "Business",
+ highlightItem: ["custom-welcome-message", "custom-cta"],
+ })
+ }
/>
- {enabled && (
+ {enabled && isAllowed && (
<motion.div
className="relative mt-4 space-y-3"
{...FADE_IN_ANIMATION_SETTINGS}
@@ -110,4 +129,3 @@ export function WelcomeMessageSection({
</div>
);
}
-
diff --git a/components/providers/posthog-provider.tsx b/components/providers/posthog-provider.tsx
index 1ac10dac..61c0a9bb 100644
--- a/components/providers/posthog-provider.tsx
+++ b/components/providers/posthog-provider.tsx
@@ -4,7 +4,6 @@ import posthog from "posthog-js";
// import { useRouter } from "next/router";
import { PostHogProvider } from "posthog-js/react";
-import { registerLandingVariant } from "@/lib/landing-ab-client";
import { getPostHogConfig } from "@/lib/posthog";
import { CustomUser } from "@/lib/types";
@@ -40,7 +39,6 @@ export const PostHogCustomProvider = ({
} else {
posthog.reset();
}
- registerLandingVariant(posthog);
})
.catch(() => {
// Do nothing.
diff --git a/components/shared/icons/files/cad.tsx b/components/shared/icons/files/cad.tsx
index bd9064cd..e93d78f5 100644
--- a/components/shared/icons/files/cad.tsx
+++ b/components/shared/icons/files/cad.tsx
@@ -24,8 +24,8 @@ export default function CadIcon({
/>
<path
opacity="0.999"
- fill-rule="evenodd"
- clip-rule="evenodd"
+ fillRule="evenodd"
+ clipRule="evenodd"
d="M77.5 31.5H497.5C521.833 37.8333 537.167 53.1667 543.5 77.5V497.5C537.167 521.833 521.833 537.167 497.5 543.5H77.5C53.1667 537.167 37.8333 521.833 31.5 497.5V77.5C37.8333 53.1667 53.1667 37.8333 77.5 31.5ZM168.092 126.004C178.391 115.754 192.33 110 206.861 110C221.392 110 235.331 115.754 245.631 126.004L245.658 126.031L266.605 146.978L266.674 147.047C266.698 147.071 266.721 147.094 266.744 147.117L303.972 184.345L323.411 164.901C323.855 164.314 324.344 163.75 324.88 163.214C325.414 162.68 325.977 162.191 326.564 161.748L360.251 128.053L360.254 128.051C371.802 116.505 387.464 110.02 403.794 110.022C420.123 110.024 435.784 116.513 447.329 128.061C458.874 139.61 465.359 155.272 465.357 171.601C465.355 187.931 458.866 203.591 447.318 215.137L413.652 248.808C413.206 249.4 412.713 249.969 412.173 250.508C411.635 251.047 411.067 251.539 410.476 251.985L391.045 271.418L428.233 308.607L428.289 308.662L428.34 308.712C428.375 308.748 428.41 308.783 428.445 308.819L449.356 329.73C470.801 351.175 470.801 385.878 449.356 407.323L407.323 449.356C385.878 470.801 351.175 470.801 329.73 449.356L271.427 391.054L231.546 430.942L231.527 430.961C225.924 436.545 219.037 440.669 211.468 442.971L211.456 442.975L141.083 464.315L141.046 464.326C136.882 465.578 132.457 465.679 128.241 464.619C124.025 463.559 120.174 461.377 117.097 458.305C114.02 455.234 111.833 451.386 110.766 447.172C109.699 442.957 109.793 438.532 111.038 434.367L111.058 434.301L132.414 363.944L132.427 363.901C134.748 356.331 138.893 349.448 144.497 343.856L144.51 343.843L184.359 303.985L126.031 245.658L126.004 245.631C115.754 235.331 110 221.392 110 206.861C110 192.33 115.754 178.391 126.004 168.092L126.031 168.064L168.064 126.031L168.092 126.004ZM400.748 216.455L424.691 192.509L424.694 192.507C430.24 186.962 433.356 179.44 433.357 171.597C433.358 163.755 430.244 156.233 424.699 150.686C419.154 145.14 411.632 142.023 403.79 142.022C395.947 142.021 388.425 145.136 382.878 150.681L358.929 174.636L400.748 216.455ZM336.304 197.266L378.123 239.084L208.935 408.297L208.924 408.308C207.033 410.19 204.709 411.58 202.157 412.356L145.991 429.388L163.021 373.281L163.026 373.264C163.812 370.711 165.213 368.389 167.104 366.503L167.122 366.485L336.304 197.266ZM255.361 180.989L281.347 206.975L206.983 281.355L148.686 223.058L148.674 223.046C144.399 218.744 142 212.926 142 206.861C142 200.796 144.4 194.977 148.675 190.675L148.686 190.664L190.664 148.686L190.675 148.675C194.977 144.4 200.796 142 206.861 142C212.926 142 218.744 144.399 223.046 148.674L223.058 148.686L232.733 158.361L211.714 179.38C205.466 185.629 205.466 195.759 211.714 202.008C217.962 208.256 228.093 208.256 234.341 202.008L255.361 180.989ZM294.053 368.425L368.419 294.047L394.398 320.027L373.379 341.045C367.131 347.294 367.131 357.424 373.379 363.673C379.628 369.921 389.758 369.921 396.007 363.673L417.026 342.654L426.729 352.357C435.677 361.305 435.677 375.748 426.729 384.696L384.696 426.729C375.748 435.677 361.305 435.677 352.357 426.729L294.053 368.425Z"
fill={isLight ? "#fff" : "#111827"}
/>
diff --git a/components/ui/nextra-filetree.tsx b/components/ui/nextra-filetree.tsx
index 8041f0ff..792a6a84 100644
--- a/components/ui/nextra-filetree.tsx
+++ b/components/ui/nextra-filetree.tsx
@@ -71,7 +71,7 @@ function Tree({
className={cn("nextra-filetree !mt-0 w-full select-none text-sm")}
style={style}
>
- <div className="block space-y-1 rounded-lg">{children}</div>
+ <div className="block space-y-1">{children}</div>
</div>
</prefersLightTextCtx.Provider>
);
@@ -140,8 +140,8 @@ const Folder = memo<FolderProps>(
<div
title={name}
className={cn(
- "flex w-full min-w-0 cursor-pointer items-center",
- "rounded-md duration-100",
+ "flex w-full min-w-0 cursor-pointer items-center rounded-md",
+ "duration-100",
prefersLightText
? "text-[var(--viewer-text)] hover:bg-[var(--viewer-control-bg)]"
: "text-foreground hover:bg-gray-100 hover:dark:bg-muted",
@@ -157,7 +157,7 @@ const Folder = memo<FolderProps>(
>
<Ident />
<div
- className="-m-1 -ml-2 flex h-full shrink-0 items-center justify-center rounded p-2"
+ className="-m-1 -ml-2 flex h-full shrink-0 items-center justify-center p-2"
onClick={handleChevronClick}
>
<ChevronRightIcon
@@ -199,8 +199,8 @@ const File = memo<FileProps>(({ label, name, active, onToggle }) => {
return (
<li
className={cn(
- "flex min-w-0 list-none",
- "rounded-md duration-100",
+ "flex min-w-0 list-none rounded-md",
+ "duration-100",
prefersLightText
? "text-[var(--viewer-muted-text)] hover:bg-[var(--viewer-control-bg)]"
: "text-foreground hover:bg-gray-100 hover:dark:bg-muted",
diff --git a/components/ui/upgrade-button.tsx b/components/ui/upgrade-button.tsx
index c2836d84..4350609d 100644
--- a/components/ui/upgrade-button.tsx
+++ b/components/ui/upgrade-button.tsx
@@ -16,6 +16,7 @@ interface UpgradeButtonProps {
size?: "default" | "sm" | "lg" | "icon";
className?: string;
highlightItem?: string[];
+ hideItems?: string[];
onClick?: () => void;
useModal?: boolean;
customText?: string;
@@ -31,6 +32,7 @@ export function UpgradeButton({
size = "default",
className,
highlightItem,
+ hideItems,
onClick,
useModal = true,
customText,
@@ -74,6 +76,7 @@ export function UpgradeButton({
open={open}
setOpen={setOpen}
highlightItem={highlightItem}
+ hideItems={hideItems}
/>
</>
);
diff --git a/components/view/dataroom/compact-dataroom-list-header.tsx b/components/view/dataroom/compact-dataroom-list-header.tsx
new file mode 100644
index 00000000..df5e9497
--- /dev/null
+++ b/components/view/dataroom/compact-dataroom-list-header.tsx
@@ -0,0 +1,85 @@
+import { cn } from "@/lib/utils";
+
+import { useViewerSurfaceTheme } from "@/components/view/viewer/viewer-surface-theme";
+
+/**
+ * Shared grid template for compact (Strict) table header + rows.
+ *
+ * IMPORTANT: classes must be literal strings so Tailwind's JIT picks them up
+ * during build. Do NOT build `sm:grid-cols-[…]` via string interpolation —
+ * the generated CSS will be missing and the row collapses to a single column.
+ */
+export function compactDataroomListGridClass(
+ showUpdatedColumn: boolean,
+ showSettingsColumn: boolean,
+ showIndexColumn = false,
+): string {
+ if (showIndexColumn && showUpdatedColumn && showSettingsColumn) {
+ return "sm:grid-cols-[minmax(2rem,2.75rem)_minmax(0,1fr)_minmax(7rem,auto)_2.5rem]";
+ }
+ if (showIndexColumn && showUpdatedColumn) {
+ return "sm:grid-cols-[minmax(2rem,2.75rem)_minmax(0,1fr)_minmax(7rem,auto)]";
+ }
+ if (showIndexColumn && showSettingsColumn) {
+ return "sm:grid-cols-[minmax(2rem,2.75rem)_minmax(0,1fr)_2.5rem]";
+ }
+ if (showIndexColumn) {
+ return "sm:grid-cols-[minmax(2rem,2.75rem)_minmax(0,1fr)]";
+ }
+ if (showUpdatedColumn && showSettingsColumn) {
+ return "sm:grid-cols-[minmax(0,1fr)_minmax(7rem,auto)_2.5rem]";
+ }
+ if (showUpdatedColumn) {
+ return "sm:grid-cols-[minmax(0,1fr)_minmax(7rem,auto)]";
+ }
+ if (showSettingsColumn) {
+ return "sm:grid-cols-[minmax(0,1fr)_2.5rem]";
+ }
+ return "sm:grid-cols-[minmax(0,1fr)]";
+}
+
+export function CompactDataroomListHeader({
+ showUpdatedColumn,
+ showSettingsColumn,
+ showIndexColumn = false,
+ className,
+}: {
+ showUpdatedColumn: boolean;
+ showSettingsColumn: boolean;
+ showIndexColumn?: boolean;
+ className?: string;
+}) {
+ const { palette } = useViewerSurfaceTheme();
+
+ return (
+ <div
+ role="row"
+ aria-hidden
+ className={cn(
+ "hidden items-center gap-3 border-b px-2 py-2 text-xs font-medium tabular-nums sm:grid sm:px-3",
+ compactDataroomListGridClass(
+ showUpdatedColumn,
+ showSettingsColumn,
+ showIndexColumn,
+ ),
+ className,
+ )}
+ style={{
+ backgroundColor: palette.controlBgColor,
+ borderColor: palette.panelBorderColor,
+ color: palette.mutedTextColor,
+ }}
+ >
+ {showIndexColumn ? (
+ <div className="text-left tabular-nums opacity-80">#</div>
+ ) : null}
+ <div>Name</div>
+ {showUpdatedColumn ? (
+ <div className="text-right sm:text-right">Updated</div>
+ ) : null}
+ {showSettingsColumn ? (
+ <div className="text-center">Settings</div>
+ ) : null}
+ </div>
+ );
+}
diff --git a/components/view/dataroom/dataroom-banner-media.tsx b/components/view/dataroom/dataroom-banner-media.tsx
new file mode 100644
index 00000000..bd6321ae
--- /dev/null
+++ b/components/view/dataroom/dataroom-banner-media.tsx
@@ -0,0 +1,67 @@
+import { cn } from "@/lib/utils";
+import {
+ classifyDataroomBanner,
+ type DataroomBannerKind,
+} from "@/ee/features/branding/lib/dataroom-banner";
+
+type Props = {
+ src: string | null | undefined;
+ alt?: string;
+ className?: string;
+ /** Aspect ratio: "cover" fills the wrapping box; "intrinsic" lets media set its own height. */
+ fit?: "cover" | "intrinsic";
+ /** Optional onLoad-style ready signal — consumers can rely on initial paint instead. */
+ onKindResolved?: (kind: DataroomBannerKind) => void;
+};
+
+/**
+ * Renders a dataroom banner image / video / YouTube embed based on the saved URL.
+ * Returns null when the banner is hidden ("no-banner") or empty.
+ */
+export function DataroomBannerMedia({
+ src,
+ alt = "Banner",
+ className,
+ fit = "cover",
+}: Props) {
+ const classified = classifyDataroomBanner(src);
+
+ if (classified.kind === "none" || !classified.src) return null;
+
+ const fitClass =
+ fit === "cover" ? "h-full w-full object-cover" : "w-full";
+
+ if (classified.kind === "youtube" && classified.youtubeId) {
+ return (
+ <iframe
+ className={cn(fitClass, "border-0", className)}
+ src={`https://www.youtube.com/embed/${classified.youtubeId}?modestbranding=1&rel=0`}
+ title={alt}
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
+ allowFullScreen
+ />
+ );
+ }
+
+ if (classified.kind === "video") {
+ return (
+ <video
+ className={cn(fitClass, className)}
+ src={classified.src}
+ muted
+ loop
+ playsInline
+ autoPlay
+ controls={false}
+ />
+ );
+ }
+
+ return (
+ <img
+ className={cn(fitClass, className)}
+ src={classified.src}
+ alt={alt}
+ />
+ );
+}
diff --git a/components/view/dataroom/dataroom-folder-picker.tsx b/components/view/dataroom/dataroom-folder-picker.tsx
new file mode 100644
index 00000000..3bcfe0f7
--- /dev/null
+++ b/components/view/dataroom/dataroom-folder-picker.tsx
@@ -0,0 +1,181 @@
+import { useMemo } from "react";
+
+import { DataroomFolder } from "@prisma/client";
+import { ChevronDownIcon } from "lucide-react";
+
+import { buildNestedFolderStructure } from "@/components/datarooms/folders/utils";
+import { cn } from "@/lib/utils";
+import {
+ HIERARCHICAL_DISPLAY_STYLE,
+ getHierarchicalDisplayName,
+} from "@/lib/utils/hierarchical-display";
+import { sortByIndexThenName } from "@/lib/utils/sort-items-by-index-name";
+
+import { Button } from "@/components/ui/button";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from "@/components/ui/dropdown-menu";
+import { useViewerSurfaceTheme } from "@/components/view/viewer/viewer-surface-theme";
+
+type NestedFolder = DataroomFolder & { childFolders: NestedFolder[] };
+
+function sortNestedFolders(nodes: NestedFolder[]): NestedFolder[] {
+ return sortByIndexThenName(nodes).map((n) => ({
+ ...n,
+ childFolders: sortNestedFolders(n.childFolders ?? []),
+ }));
+}
+
+function FolderPickerBranch({
+ nodes,
+ depth,
+ folderId,
+ setFolderId,
+ dataroomIndexEnabled,
+ activeBg,
+ textColor,
+}: {
+ nodes: NestedFolder[];
+ depth: number;
+ folderId: string | null;
+ setFolderId: React.Dispatch<React.SetStateAction<string | null>>;
+ dataroomIndexEnabled?: boolean;
+ activeBg: string;
+ textColor: string;
+}) {
+ return (
+ <>
+ {nodes.map((node) => (
+ <div key={node.id}>
+ <DropdownMenuItem
+ className={cn(
+ "cursor-pointer focus:text-inherit",
+ folderId === node.id && "font-medium",
+ )}
+ style={{
+ paddingLeft: `${0.75 + depth * 0.65}rem`,
+ color: textColor,
+ backgroundColor:
+ folderId === node.id ? activeBg : undefined,
+ ...HIERARCHICAL_DISPLAY_STYLE,
+ }}
+ onClick={() => setFolderId(node.id)}
+ >
+ {getHierarchicalDisplayName(
+ node.name,
+ node.hierarchicalIndex,
+ dataroomIndexEnabled ?? false,
+ )}
+ </DropdownMenuItem>
+ {node.childFolders?.length ? (
+ <FolderPickerBranch
+ nodes={node.childFolders}
+ depth={depth + 1}
+ folderId={folderId}
+ setFolderId={setFolderId}
+ dataroomIndexEnabled={dataroomIndexEnabled}
+ activeBg={activeBg}
+ textColor={textColor}
+ />
+ ) : null}
+ </div>
+ ))}
+ </>
+ );
+}
+
+export function DataroomFolderPicker({
+ folders,
+ folderId,
+ setFolderId,
+ dataroomIndexEnabled,
+ className,
+}: {
+ folders: DataroomFolder[];
+ folderId: string | null;
+ setFolderId: React.Dispatch<React.SetStateAction<string | null>>;
+ dataroomIndexEnabled?: boolean;
+ className?: string;
+}) {
+ const { palette } = useViewerSurfaceTheme();
+
+ const nested = useMemo(() => {
+ const roots = buildNestedFolderStructure(folders as any) as NestedFolder[];
+ return sortNestedFolders(roots);
+ }, [folders]);
+
+ const triggerLabel = useMemo(() => {
+ if (folderId === null) {
+ return "Home";
+ }
+ const current = folders.find((f) => f.id === folderId);
+ if (!current) return "Home";
+ return getHierarchicalDisplayName(
+ current.name,
+ current.hierarchicalIndex,
+ dataroomIndexEnabled ?? false,
+ );
+ }, [folderId, folders, dataroomIndexEnabled]);
+
+ return (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ type="button"
+ variant="outline"
+ className={cn(
+ "h-9 max-w-[min(100%,280px)] shrink-0 justify-between gap-2 px-3 text-left text-sm font-normal shadow-sm",
+ className,
+ )}
+ style={{
+ borderColor: palette.controlBorderColor,
+ backgroundColor: palette.controlBgColor,
+ color: palette.textColor,
+ }}
+ >
+ <span className="truncate">{triggerLabel}</span>
+ <ChevronDownIcon className="size-4 shrink-0 opacity-60" aria-hidden />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent
+ align="start"
+ className="max-h-[min(70vh,360px)] w-[min(calc(100vw-2rem),300px)] overflow-y-auto border"
+ style={{
+ backgroundColor: palette.panelBgColor,
+ borderColor: palette.panelBorderColor,
+ color: palette.textColor,
+ }}
+ >
+ <DropdownMenuItem
+ className={cn(
+ "cursor-pointer focus:text-inherit",
+ folderId === null && "font-medium",
+ )}
+ style={{
+ ...HIERARCHICAL_DISPLAY_STYLE,
+ color: palette.textColor,
+ backgroundColor:
+ folderId === null ? palette.controlBgColor : undefined,
+ }}
+ onClick={() => setFolderId(null)}
+ >
+ Home
+ </DropdownMenuItem>
+ {nested.length > 0 ? <DropdownMenuSeparator /> : null}
+ <FolderPickerBranch
+ nodes={nested}
+ depth={0}
+ folderId={folderId}
+ setFolderId={setFolderId}
+ dataroomIndexEnabled={dataroomIndexEnabled}
+ activeBg={palette.controlBgColor}
+ textColor={palette.textColor}
+ />
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+}
diff --git a/components/view/dataroom/dataroom-no-banner-title.tsx b/components/view/dataroom/dataroom-no-banner-title.tsx
new file mode 100644
index 00000000..96463f2a
--- /dev/null
+++ b/components/view/dataroom/dataroom-no-banner-title.tsx
@@ -0,0 +1,46 @@
+import { formatDate } from "@/lib/utils";
+import { cn } from "@/lib/utils";
+
+import { useViewerSurfaceTheme } from "@/components/view/viewer/viewer-surface-theme";
+
+export function DataroomNoBannerTitle({
+ name,
+ lastUpdatedAt,
+ showLastUpdated,
+ className,
+}: {
+ name: string;
+ lastUpdatedAt?: Date | string | null;
+ showLastUpdated?: boolean;
+ className?: string;
+}) {
+ const { usesLightText, palette } = useViewerSurfaceTheme();
+
+ return (
+ <div className={cn("min-w-0", className)}>
+ <div
+ className={cn(
+ "text-3xl",
+ !usesLightText && "text-foreground",
+ )}
+ style={usesLightText ? { color: palette.textColor } : undefined}
+ >
+ {name}
+ </div>
+ {showLastUpdated && lastUpdatedAt ? (
+ <time
+ className={cn(
+ "mt-0.5 block text-sm",
+ !usesLightText && "text-muted-foreground",
+ )}
+ dateTime={new Date(lastUpdatedAt).toISOString()}
+ style={
+ usesLightText ? { color: palette.mutedTextColor } : undefined
+ }
+ >
+ {`Last updated ${formatDate(new Date(lastUpdatedAt).toISOString())}`}
+ </time>
+ ) : null}
+ </div>
+ );
+}
diff --git a/components/view/dataroom/dataroom-trailing-actions.tsx b/components/view/dataroom/dataroom-trailing-actions.tsx
new file mode 100644
index 00000000..41d1d779
--- /dev/null
+++ b/components/view/dataroom/dataroom-trailing-actions.tsx
@@ -0,0 +1,134 @@
+import { BadgeInfoIcon, Download } from "lucide-react";
+
+import { cn } from "@/lib/utils";
+
+import { ButtonTooltip } from "@/components/ui/tooltip";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipProvider,
+ TooltipTrigger,
+} from "@/components/ui/tooltip";
+
+import { Button } from "../../ui/button";
+
+export type DataroomTrailingActionsVariant = "onBrand" | "onLight";
+
+/**
+ * Trailing action buttons that historically lived in the dataroom navbar
+ * (team-member info badge, CTA, conversations toggle, bulk download).
+ *
+ * Extracted into a standalone component so the Notion preset — which has no
+ * navbar above the cover image — can render the same buttons inside the body
+ * toolbar on the right of the search input.
+ *
+ * Stateful behavior (conversations open/close, download modal) lives in
+ * `nav-dataroom`. To keep this component decoupled, callers pass the click
+ * handlers; from the body toolbar those handlers dispatch CustomEvents that
+ * the nav listens for.
+ */
+export function DataroomTrailingActions({
+ variant = "onBrand",
+ isTeamMember,
+ brand,
+ conversationsEnabled,
+ allowDownload,
+ allowBulkDownload,
+ viewerEmail,
+ onToggleConversations,
+ onOpenDownload,
+}: {
+ variant?: DataroomTrailingActionsVariant;
+ isTeamMember?: boolean;
+ brand?: {
+ ctaLabel?: string | null;
+ ctaUrl?: string | null;
+ brandColor?: string | null;
+ accentButtonColor?: string | null;
+ } | null;
+ conversationsEnabled?: boolean;
+ allowDownload?: boolean;
+ allowBulkDownload?: boolean;
+ viewerEmail?: string | null;
+ onToggleConversations: () => void;
+ onOpenDownload: () => void;
+}) {
+ const showNavCta = !!brand?.ctaLabel && !!brand?.ctaUrl;
+
+ // "onLight" picks up the surface-aware viewer CSS vars so the button blends
+ // with whatever background the dataroom view is rendering against (white,
+ // brand accent, light or dark). "onBrand" stays dark because it sits on
+ // the brand-colored navbar.
+ const chip =
+ variant === "onLight"
+ ? "border border-[var(--viewer-control-border)] bg-[var(--viewer-control-bg)] text-[var(--viewer-text)] hover:bg-[var(--viewer-panel-bg-hover)] hover:text-[var(--viewer-text)]"
+ : "border border-transparent bg-gray-900 text-white hover:bg-gray-900/80";
+
+ return (
+ <>
+ {isTeamMember ? (
+ <TooltipProvider delayDuration={100}>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button className={cn("size-8 sm:size-10", chip)} size="icon">
+ <BadgeInfoIcon className="h-5 w-5" />
+ </Button>
+ </TooltipTrigger>
+ <TooltipContent>
+ <p className="max-w-xs text-wrap text-center">
+ Skipped verification because you are a team member; no analytics
+ will be collected
+ </p>
+ </TooltipContent>
+ </Tooltip>
+ </TooltipProvider>
+ ) : null}
+ {showNavCta && (
+ <a
+ href={brand!.ctaUrl!}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="inline-flex items-center justify-center rounded-md px-4 py-2 text-sm font-medium text-white transition-colors hover:opacity-90"
+ style={{
+ backgroundColor:
+ brand?.accentButtonColor || brand?.brandColor || "#111827",
+ color: "#ffffff",
+ }}
+ >
+ {brand!.ctaLabel}
+ </a>
+ )}
+ {conversationsEnabled && (
+ <Button
+ onClick={onToggleConversations}
+ variant={variant === "onLight" ? "outline" : "default"}
+ className={cn(
+ variant === "onLight" &&
+ "border-[var(--viewer-control-border)] bg-[var(--viewer-control-bg)] text-[var(--viewer-text)] hover:bg-[var(--viewer-panel-bg-hover)] hover:text-[var(--viewer-text)]",
+ variant === "onBrand" &&
+ "bg-gray-900 text-white hover:bg-gray-900/90",
+ )}
+ >
+ View Q&A
+ </Button>
+ )}
+ {allowDownload && allowBulkDownload && viewerEmail ? (
+ <ButtonTooltip content="Download Dataroom">
+ <Button
+ onClick={onOpenDownload}
+ className={cn("m-1 size-9 sm:size-10", chip)}
+ size="icon"
+ >
+ <Download className="h-5 w-5" />
+ </Button>
+ </ButtonTooltip>
+ ) : null}
+ </>
+ );
+}
+
+/** Event names dispatched by external callers (e.g. the body toolbar in
+ * Notion mode) and listened for by `nav-dataroom` to mutate its local
+ * state without prop-drilling. */
+export const VIEWER_TOGGLE_CONVERSATIONS_EVENT = "viewer-conversation-toggle";
+export const VIEWER_OPEN_DOWNLOAD_EVENT = "viewer-download-modal-open";
diff --git a/components/view/dataroom/dataroom-view.tsx b/components/view/dataroom/dataroom-view.tsx
index f81be107..03b1b030 100644
--- a/components/view/dataroom/dataroom-view.tsx
+++ b/components/view/dataroom/dataroom-view.tsx
@@ -309,7 +309,7 @@ export default function DataroomView({
dataroomId={viewData.enableVisitorUpload ? dataroom?.id : undefined}
>
<div
- className="min-h-screen bg-white"
+ className="flex min-h-screen flex-col bg-white"
style={{ backgroundColor: dataroomViewBackgroundColor ?? undefined }}
>
<DataroomViewer
@@ -327,6 +327,7 @@ export default function DataroomView({
viewData={viewData}
isEmbedded={isEmbedded}
dataroomIndexEnabled={dataroomIndexEnabled}
+ showPoweredByBanner={link.showBanner ?? false}
viewerEmail={
viewData.viewerEmail ??
data.email ??
diff --git a/components/view/dataroom/document-card.tsx b/components/view/dataroom/document-card.tsx
index 8d5f548e..33c3ec47 100644
--- a/components/view/dataroom/document-card.tsx
+++ b/components/view/dataroom/document-card.tsx
@@ -3,6 +3,8 @@ import { useRouter } from "next/router";
import React from "react";
import { Download, MoreVerticalIcon } from "lucide-react";
+
+import { type DataroomCardLayout } from "@/ee/features/branding/lib/dataroom-viewer-layout";
import { useTheme } from "next-themes";
import { toast } from "sonner";
@@ -11,10 +13,7 @@ import { cn } from "@/lib/utils";
import { downloadFromLinkEndpoint } from "@/lib/utils/download-document";
import { ensureFileExtension } from "@/lib/utils/get-content-type";
import { fileIcon } from "@/lib/utils/get-file-icon";
-import {
- HIERARCHICAL_DISPLAY_STYLE,
- getHierarchicalDisplayName,
-} from "@/lib/utils/hierarchical-display";
+import { HIERARCHICAL_DISPLAY_STYLE } from "@/lib/utils/hierarchical-display";
import { Button } from "@/components/ui/button";
import {
@@ -24,10 +23,25 @@ import {
DropdownMenuLabel,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
+import { compactDataroomListGridClass } from "@/components/view/dataroom/compact-dataroom-list-header";
import { useViewerSurfaceTheme } from "@/components/view/viewer/viewer-surface-theme";
import { DocumentVersion } from "../viewer/dataroom-viewer";
+function formatEditorialFileSize(bytes?: number | bigint | null): string {
+ if (bytes == null) return "—";
+ const n = Number(bytes);
+ if (!Number.isFinite(n) || n <= 0) return "—";
+ const units = ["B", "KB", "MB", "GB", "TB"];
+ let v = n;
+ let u = 0;
+ while (v >= 1024 && u < units.length - 1) {
+ v /= 1024;
+ u++;
+ }
+ return `${v < 10 && u > 0 ? v.toFixed(1) : Math.round(v)} ${units[u]}`;
+}
+
type DRDocument = {
dataroomDocumentId: string;
id: string;
@@ -47,6 +61,16 @@ type DocumentsCardProps = {
isProcessing?: boolean;
dataroomIndexEnabled?: boolean;
showLastUpdated?: boolean;
+ layout?: DataroomCardLayout;
+ /** Compact table: include Updated column */
+ compactShowUpdatedColumn?: boolean;
+ /** Compact table: reserve Settings column (including spacer when row has no menu) */
+ compactShowActionsColumn?: boolean;
+ /** Strict / compact table: dedicated left column for index */
+ compactShowIndexColumn?: boolean;
+ editorialList?: boolean;
+ editorialIndex?: number;
+ documentFolderLabel?: string | null;
};
export default function DocumentCard({
@@ -58,6 +82,13 @@ export default function DocumentCard({
isProcessing = false,
dataroomIndexEnabled,
showLastUpdated = true,
+ layout = "LIST",
+ compactShowUpdatedColumn = true,
+ compactShowActionsColumn = true,
+ compactShowIndexColumn = false,
+ editorialList = false,
+ editorialIndex = 0,
+ documentFolderLabel = null,
}: DocumentsCardProps) {
const { theme, systemTheme } = useTheme();
const { palette } = useViewerSurfaceTheme();
@@ -67,12 +98,32 @@ export default function DocumentCard({
theme === "light" || (theme === "system" && systemTheme === "light");
const router = useRouter();
- // Get hierarchical display name
- const displayName = getHierarchicalDisplayName(
- document.name,
- document.hierarchicalIndex,
- dataroomIndexEnabled || false,
- );
+ const plainTitle =
+ layout === "COMPACT" || (layout === "LIST" && editorialList);
+ const hierIndex = document.hierarchicalIndex?.trim() || "";
+ const fallbackIndexLabel = String(editorialIndex + 1).padStart(2, "0");
+ // Only the COMPACT layout (UI "List") keeps auto-numbered fallbacks like
+ // 01/02/03 so the table always feels indexed. GRID (Notion) and LIST (UI
+ // "Cards") show numbers only when an admin has set an explicit
+ // hierarchical index.
+ const inlineIndexPrefix = hierIndex
+ ? hierIndex
+ : layout === "COMPACT"
+ ? fallbackIndexLabel
+ : "";
+ // String form kept for accessibility/title attributes.
+ const displayName =
+ plainTitle || !inlineIndexPrefix
+ ? document.name
+ : `${inlineIndexPrefix} ${document.name}`;
+ const displayNameNode =
+ plainTitle || !inlineIndexPrefix ? (
+ document.name
+ ) : (
+ <>
+ <span>{inlineIndexPrefix}</span> {document.name}
+ </>
+ );
const { previewToken, domain, slug } = router.query as {
previewToken?: string;
domain?: string;
@@ -124,6 +175,333 @@ export default function DocumentCard({
});
};
+ const sharedStyle = {
+ "--viewer-panel-bg": palette.panelBgColor,
+ "--viewer-panel-bg-hover": palette.panelHoverBgColor,
+ "--viewer-panel-border": palette.panelBorderColor,
+ "--viewer-panel-border-hover": palette.panelBorderHoverColor,
+ "--viewer-text": palette.textColor,
+ "--viewer-muted-text": palette.mutedTextColor,
+ "--viewer-control-bg": palette.controlBgColor,
+ "--viewer-control-border": palette.controlBorderColor,
+ "--viewer-control-border-strong": palette.controlBorderStrongColor,
+ "--viewer-control-icon": palette.controlIconColor,
+ } as React.CSSProperties;
+
+ const downloadMenuButton = canDownload && !isProcessing && (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ variant="ghost"
+ size="icon"
+ className={cn(
+ "h-8 w-8 border bg-transparent p-0",
+ "text-[var(--viewer-control-icon)] border-[var(--viewer-control-border)] hover:bg-[var(--viewer-control-bg)]",
+ "group-hover/row:text-[var(--viewer-text)] group-hover/row:border-[var(--viewer-control-border-strong)]",
+ )}
+ aria-label="Open menu"
+ >
+ <MoreVerticalIcon className="h-4 w-4" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <DropdownMenuLabel>Actions</DropdownMenuLabel>
+ <DropdownMenuItem
+ onClick={(e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ downloadDocument();
+ }}
+ >
+ <Download className="h-4 w-4" />
+ Download
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+
+ if (layout === "GRID") {
+ // See FolderCard GRID for the click-through pattern: full-surface button
+ // sits behind the content (z-0, pointer-events from default), content
+ // layers use pointer-events-none so clicks pass through to the button,
+ // and the download menu re-enables pointer events only on itself.
+ return (
+ <div
+ className={cn(
+ "group/row relative flex h-full cursor-pointer flex-col overflow-hidden rounded-lg border transition-all",
+ "bg-[var(--viewer-panel-bg)] hover:bg-[var(--viewer-panel-bg-hover)]",
+ "border-[var(--viewer-panel-border)] hover:border-[var(--viewer-panel-border-hover)]",
+ isProcessing && "cursor-not-allowed opacity-60",
+ )}
+ style={sharedStyle}
+ >
+ <button
+ onClick={handleDocumentClick}
+ className="absolute inset-0 z-0 cursor-pointer"
+ disabled={isProcessing}
+ aria-label={`Open document ${document.name}`}
+ />
+
+ {/* Preview area */}
+ <div
+ className={cn(
+ "pointer-events-none relative flex aspect-[4/3] w-full items-center justify-center overflow-hidden border-b",
+ "border-[var(--viewer-panel-border)]",
+ )}
+ style={{
+ backgroundColor: palette.controlBgColor,
+ }}
+ >
+ {fileIcon({
+ fileType: document.versions[0].type ?? "",
+ className: "h-16 w-16 sm:h-20 sm:w-20",
+ isLight,
+ })}
+ </div>
+
+ {/* Info area */}
+ <div className="pointer-events-none relative flex items-center justify-between gap-2 p-3">
+ <div className="flex min-w-0 flex-1 items-center gap-2">
+ <div className="flex h-6 w-6 shrink-0 items-center justify-center">
+ {fileIcon({
+ fileType: document.versions[0].type ?? "",
+ className: "h-5 w-5",
+ isLight,
+ })}
+ </div>
+ <div className="min-w-0 flex-1">
+ <h2
+ className="truncate text-sm font-medium leading-5 text-[var(--viewer-text)]"
+ style={HIERARCHICAL_DISPLAY_STYLE}
+ >
+ {displayNameNode}
+ {isProcessing && (
+ <span className="ml-2 text-xs text-[var(--viewer-muted-text)]">
+ (Processing...)
+ </span>
+ )}
+ </h2>
+ {showLastUpdated && (
+ <p className="truncate text-xs leading-4 text-[var(--viewer-muted-text)]">
+ Updated {timeAgo(document.versions[0].updatedAt)}
+ </p>
+ )}
+ </div>
+ </div>
+ {downloadMenuButton && (
+ <div className="pointer-events-auto relative z-10">
+ {downloadMenuButton}
+ </div>
+ )}
+ </div>
+ </div>
+ );
+ }
+
+ if (layout === "COMPACT") {
+ const indexLabel =
+ document.hierarchicalIndex?.trim() ||
+ String(editorialIndex + 1).padStart(2, "0");
+ const gridClass = compactDataroomListGridClass(
+ compactShowUpdatedColumn && showLastUpdated,
+ compactShowActionsColumn,
+ compactShowIndexColumn,
+ );
+ const showUpdatedCell =
+ compactShowUpdatedColumn && showLastUpdated;
+ const actionsSlot = compactShowActionsColumn ? (
+ downloadMenuButton ? (
+ <div className="z-10 flex justify-end pointer-events-auto">
+ {downloadMenuButton}
+ </div>
+ ) : (
+ <span className="inline-flex h-8 w-8 shrink-0" aria-hidden />
+ )
+ ) : null;
+
+ const nameBlock = (
+ <>
+ <div className="flex h-6 w-6 shrink-0 items-center justify-center">
+ {fileIcon({
+ fileType: document.versions[0].type ?? "",
+ className: "h-5 w-5",
+ isLight,
+ })}
+ </div>
+ <h2
+ className="truncate text-sm font-medium leading-5 text-[var(--viewer-text)]"
+ style={HIERARCHICAL_DISPLAY_STYLE}
+ >
+ {displayNameNode}
+ {isProcessing && (
+ <span className="ml-2 text-xs text-[var(--viewer-muted-text)]">
+ (Processing...)
+ </span>
+ )}
+ </h2>
+ </>
+ );
+
+ return (
+ <div
+ className={cn(
+ "group/row relative border-b transition-colors",
+ "border-[var(--viewer-panel-border)]",
+ "hover:bg-[var(--viewer-panel-bg-hover)]",
+ "px-2 py-2 sm:px-3",
+ isProcessing && "cursor-not-allowed opacity-60",
+ )}
+ style={sharedStyle}
+ >
+ <button
+ type="button"
+ onClick={handleDocumentClick}
+ className="absolute inset-0 z-0 cursor-pointer rounded-none border-0 bg-transparent p-0 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--viewer-control-border-strong)]"
+ disabled={isProcessing}
+ aria-label={`Open document ${compactShowIndexColumn ? `${indexLabel} ` : ""}${document.name}`}
+ />
+ <div className="pointer-events-none relative z-[1] flex items-center justify-between gap-3 sm:hidden">
+ {compactShowIndexColumn ? (
+ <span className="w-9 shrink-0 text-xs tabular-nums text-[var(--viewer-muted-text)]">
+ {indexLabel}
+ </span>
+ ) : null}
+ <div className="flex min-w-0 flex-1 items-center gap-3">{nameBlock}</div>
+ <div className="flex shrink-0 items-center gap-2">
+ {showUpdatedCell ? (
+ <p className="max-w-[38vw] truncate text-xs tabular-nums text-[var(--viewer-muted-text)]">
+ {timeAgo(document.versions[0].updatedAt)}
+ </p>
+ ) : null}
+ {compactShowActionsColumn && downloadMenuButton ? (
+ <div className="z-10 pointer-events-auto">{downloadMenuButton}</div>
+ ) : null}
+ </div>
+ </div>
+ <div
+ className={cn(
+ "pointer-events-none relative z-[1] hidden items-center gap-3 sm:grid",
+ gridClass,
+ )}
+ >
+ {compactShowIndexColumn ? (
+ <span className="text-xs tabular-nums text-[var(--viewer-muted-text)]">
+ {indexLabel}
+ </span>
+ ) : null}
+ <div className="flex min-w-0 items-center gap-3">{nameBlock}</div>
+ {showUpdatedCell ? (
+ <p className="truncate text-right text-xs tabular-nums text-[var(--viewer-muted-text)]">
+ {timeAgo(document.versions[0].updatedAt)}
+ </p>
+ ) : null}
+ {actionsSlot}
+ </div>
+ </div>
+ );
+ }
+
+ if (layout === "LIST" && editorialList) {
+ const idxLabel =
+ document.hierarchicalIndex?.trim() ||
+ String(editorialIndex + 1).padStart(2, "0");
+ const ver = document.versions[0];
+ const sizeLabel = formatEditorialFileSize(ver?.fileSize);
+ const typeLabel =
+ ver?.type === "notion"
+ ? "NOTION"
+ : (ver?.type ?? "").replace(/\./g, "").slice(0, 8).toUpperCase() ||
+ "FILE";
+ const captionLabel = documentFolderLabel || "Documents";
+ const updatedLabel = showLastUpdated
+ ? `Updated ${timeAgo(ver.updatedAt)}`
+ : null;
+
+ return (
+ <div
+ className={cn(
+ "group/row relative border-b transition-colors",
+ "border-[var(--viewer-panel-border)]",
+ "hover:bg-[var(--viewer-panel-bg-hover)]",
+ "py-3 pl-2 pr-1 sm:pl-3 sm:pr-2",
+ isProcessing && "cursor-not-allowed opacity-60",
+ )}
+ style={sharedStyle}
+ >
+ <button
+ onClick={handleDocumentClick}
+ className="absolute inset-0 z-0 cursor-pointer"
+ disabled={isProcessing}
+ aria-label={`Open document ${document.name}`}
+ />
+ <div className="pointer-events-none relative z-[1] flex flex-col gap-2 md:hidden">
+ <div className="flex items-start justify-between gap-3 pl-7">
+ <span className="absolute left-2 top-0 text-xs tabular-nums text-[var(--viewer-muted-text)]">
+ {idxLabel}
+ </span>
+ <div className="min-w-0 flex-1">
+ <h2
+ className="text-sm font-semibold leading-snug text-[var(--viewer-text)]"
+ style={HIERARCHICAL_DISPLAY_STYLE}
+ >
+ {displayNameNode}
+ </h2>
+ <p className="mt-1 text-xs text-[var(--viewer-muted-text)]">
+ {captionLabel}
+ </p>
+ </div>
+ <div className="flex shrink-0 flex-col items-end gap-1 text-[11px] text-[var(--viewer-muted-text)]">
+ {updatedLabel ? <span>{updatedLabel}</span> : null}
+ <span>{sizeLabel}</span>
+ <span className="font-medium">{typeLabel}</span>
+ </div>
+ </div>
+ {downloadMenuButton ? (
+ <div className="pointer-events-auto flex justify-end pr-1">
+ {downloadMenuButton}
+ </div>
+ ) : null}
+ </div>
+
+ <div className="pointer-events-none relative z-[1] hidden md:grid md:grid-cols-[2rem_minmax(0,1fr)_minmax(6rem,8rem)_4rem_3rem_2.25rem] md:items-center md:gap-4 lg:grid-cols-[2.25rem_minmax(0,1fr)_minmax(7rem,9rem)_4.25rem_3rem_2.25rem]">
+ <span className="text-xs tabular-nums text-[var(--viewer-muted-text)]">
+ {idxLabel}
+ </span>
+ <div className="min-w-0">
+ <h2
+ className="truncate text-sm font-semibold text-[var(--viewer-text)]"
+ style={HIERARCHICAL_DISPLAY_STYLE}
+ >
+ {displayNameNode}
+ {isProcessing ? (
+ <span className="ml-2 text-xs font-normal text-[var(--viewer-muted-text)]">
+ (Processing…)
+ </span>
+ ) : null}
+ </h2>
+ <p className="mt-0.5 truncate text-xs text-[var(--viewer-muted-text)]">
+ {captionLabel}
+ </p>
+ </div>
+ <span className="truncate text-right text-xs tabular-nums text-[var(--viewer-muted-text)]">
+ {updatedLabel ?? "—"}
+ </span>
+ <span className="text-right text-xs tabular-nums text-[var(--viewer-muted-text)]">
+ {sizeLabel}
+ </span>
+ <span className="text-center text-[11px] font-medium uppercase tracking-wide text-[var(--viewer-muted-text)]">
+ {typeLabel}
+ </span>
+ <div className="pointer-events-auto flex justify-end">
+ {downloadMenuButton ?? (
+ <span className="inline-flex h-8 w-8" aria-hidden />
+ )}
+ </div>
+ </div>
+ </div>
+ );
+ }
+
return (
<div
className={cn(
@@ -132,22 +510,8 @@ export default function DocumentCard({
"border-[var(--viewer-panel-border)] hover:border-[var(--viewer-panel-border-hover)]",
isProcessing && "cursor-not-allowed opacity-60",
)}
- style={
- {
- "--viewer-panel-bg": palette.panelBgColor,
- "--viewer-panel-bg-hover": palette.panelHoverBgColor,
- "--viewer-panel-border": palette.panelBorderColor,
- "--viewer-panel-border-hover": palette.panelBorderHoverColor,
- "--viewer-text": palette.textColor,
- "--viewer-muted-text": palette.mutedTextColor,
- "--viewer-control-bg": palette.controlBgColor,
- "--viewer-control-border": palette.controlBorderColor,
- "--viewer-control-border-strong": palette.controlBorderStrongColor,
- "--viewer-control-icon": palette.controlIconColor,
- } as React.CSSProperties
- }
+ style={sharedStyle}
>
- {/* Click target - outside of text hierarchy to fix Safari truncation issue */}
<button
onClick={handleDocumentClick}
className="absolute inset-0 z-0 cursor-pointer"
@@ -169,20 +533,16 @@ export default function DocumentCard({
className="truncate text-sm font-semibold leading-6 text-[var(--viewer-text)]"
style={HIERARCHICAL_DISPLAY_STYLE}
>
- {displayName}
+ {displayNameNode}
{isProcessing && (
- <span
- className="ml-2 text-xs text-[var(--viewer-muted-text)]"
- >
+ <span className="ml-2 text-xs text-[var(--viewer-muted-text)]">
(Processing...)
</span>
)}
</h2>
</div>
{showLastUpdated && (
- <div
- className="mt-1 flex items-center space-x-1 text-xs leading-5 text-[var(--viewer-muted-text)]"
- >
+ <div className="mt-1 flex items-center space-x-1 text-xs leading-5 text-[var(--viewer-muted-text)]">
<p className="truncate">
Updated {timeAgo(document.versions[0].updatedAt)}
</p>
@@ -190,39 +550,7 @@ export default function DocumentCard({
)}
</div>
</div>
- {canDownload && !isProcessing && (
- <div className="z-10">
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button
- variant="ghost"
- size="icon"
- className={cn(
- "h-8 w-8 border bg-transparent p-0",
- "text-[var(--viewer-control-icon)] border-[var(--viewer-control-border)] hover:bg-[var(--viewer-control-bg)]",
- "group-hover/row:text-[var(--viewer-text)] group-hover/row:border-[var(--viewer-control-border-strong)]",
- )}
- aria-label="Open menu"
- >
- <MoreVerticalIcon className="h-4 w-4" />
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuLabel>Actions</DropdownMenuLabel>
- <DropdownMenuItem
- onClick={(e) => {
- e.preventDefault();
- e.stopPropagation();
- downloadDocument();
- }}
- >
- <Download className="h-4 w-4" />
- Download
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </div>
- )}
+ {downloadMenuButton && <div className="z-10">{downloadMenuButton}</div>}
</div>
);
}
diff --git a/components/view/dataroom/document-upload-modal.tsx b/components/view/dataroom/document-upload-modal.tsx
index aceb2271..4ef6929e 100644
--- a/components/view/dataroom/document-upload-modal.tsx
+++ b/components/view/dataroom/document-upload-modal.tsx
@@ -7,6 +7,8 @@ import {
UploadIcon,
} from "lucide-react";
+import { cn } from "@/lib/utils";
+
import { Button } from "@/components/ui/button";
import {
Dialog,
@@ -48,6 +50,7 @@ export function DocumentUploadModal({
folderId,
folderName,
allowedFolders,
+ triggerClassName,
}: {
linkId: string;
dataroomId: string;
@@ -61,6 +64,9 @@ export function DocumentUploadModal({
* `undefined` means "no restriction".
*/
allowedFolders?: AllowedFolder[] | null;
+ /** Optional className applied to the trigger button so callers can theme it
+ * to the surrounding surface (e.g. dark viewer background). */
+ triggerClassName?: string;
}) {
const [isOpen, setIsOpen] = useState(false);
const [uploadSuccess, setUploadSuccess] = useState(false);
@@ -122,7 +128,10 @@ export function DocumentUploadModal({
onClick={() => setIsOpen(true)}
size="sm"
variant="outline"
- className="group flex items-center justify-start gap-x-3 px-3 text-left"
+ className={cn(
+ "group flex items-center justify-start gap-x-3 px-3 text-left",
+ triggerClassName,
+ )}
title="Add Document"
>
<PlusIcon className="h-5 w-5 shrink-0" aria-hidden="true" />
diff --git a/components/view/dataroom/folder-card.tsx b/components/view/dataroom/folder-card.tsx
index a95db589..a36b206d 100644
--- a/components/view/dataroom/folder-card.tsx
+++ b/components/view/dataroom/folder-card.tsx
@@ -3,14 +3,13 @@ import type { CSSProperties } from "react";
import { DataroomFolder } from "@prisma/client";
import { Download, MoreVerticalIcon } from "lucide-react";
+
+import { type DataroomCardLayout } from "@/ee/features/branding/lib/dataroom-viewer-layout";
import { toast } from "sonner";
import { getFolderColorClasses, getFolderIcon } from "@/lib/constants/folder-constants";
import { cn, timeAgo } from "@/lib/utils";
-import {
- HIERARCHICAL_DISPLAY_STYLE,
- getHierarchicalDisplayName,
-} from "@/lib/utils/hierarchical-display";
+import { HIERARCHICAL_DISPLAY_STYLE } from "@/lib/utils/hierarchical-display";
import { Button } from "@/components/ui/button";
import {
@@ -20,6 +19,7 @@ import {
DropdownMenuLabel,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
+import { compactDataroomListGridClass } from "@/components/view/dataroom/compact-dataroom-list-header";
import { useViewerSurfaceTheme } from "@/components/view/viewer/viewer-surface-theme";
type FolderCardProps = {
@@ -32,6 +32,14 @@ type FolderCardProps = {
allowDownload: boolean;
dataroomIndexEnabled?: boolean;
showLastUpdated?: boolean;
+ layout?: DataroomCardLayout;
+ hideFolderIcons?: boolean;
+ compactShowUpdatedColumn?: boolean;
+ compactShowActionsColumn?: boolean;
+ /** Strict / compact table: dedicated left column for index */
+ compactShowIndexColumn?: boolean;
+ editorialList?: boolean;
+ editorialIndex?: number;
};
export default function FolderCard({
folder,
@@ -43,16 +51,44 @@ export default function FolderCard({
allowDownload,
dataroomIndexEnabled,
showLastUpdated = true,
+ layout = "LIST",
+ hideFolderIcons = false,
+ compactShowUpdatedColumn = true,
+ compactShowActionsColumn = true,
+ compactShowIndexColumn = false,
+ editorialList = false,
+ editorialIndex = 0,
}: FolderCardProps) {
const [open, setOpen] = useState(false);
const { palette } = useViewerSurfaceTheme();
- // Get hierarchical display name
- const displayName = getHierarchicalDisplayName(
- folder.name,
- folder.hierarchicalIndex,
- dataroomIndexEnabled || false,
- );
+ const plainTitle =
+ layout === "COMPACT" || (layout === "LIST" && editorialList);
+ const hierIndex = folder.hierarchicalIndex?.trim() || "";
+ const fallbackIndexLabel = String(editorialIndex + 1).padStart(2, "0");
+ // Only the COMPACT layout (UI "List") keeps auto-numbered fallbacks like
+ // 01/02/03 so the table always feels indexed. GRID (Notion) and LIST (UI
+ // "Cards") show numbers only when an admin has set an explicit
+ // hierarchical index.
+ const inlineIndexPrefix = hierIndex
+ ? hierIndex
+ : layout === "COMPACT"
+ ? fallbackIndexLabel
+ : "";
+ const displayName =
+ plainTitle || !inlineIndexPrefix
+ ? folder.name
+ : `${inlineIndexPrefix} ${folder.name}`;
+ // Kept as a JSX node so we can render two spans inline without losing the
+ // `truncate` behaviour, even though both spans use the same color.
+ const displayNameNode =
+ plainTitle || !inlineIndexPrefix ? (
+ folder.name
+ ) : (
+ <>
+ <span>{inlineIndexPrefix}</span> {folder.name}
+ </>
+ );
const openFolderDownloadModal = () => {
if (!allowDownload) {
toast.error("Downloading folders is not allowed.");
@@ -70,6 +106,289 @@ export default function FolderCard({
);
};
+ const FolderIconComponent = getFolderIcon(folder.icon);
+ const colorClasses = hideFolderIcons ? null : getFolderColorClasses(folder.color);
+
+ const sharedStyle = {
+ "--viewer-panel-bg": palette.panelBgColor,
+ "--viewer-panel-bg-hover": palette.panelHoverBgColor,
+ "--viewer-panel-border": palette.panelBorderColor,
+ "--viewer-panel-border-hover": palette.panelBorderHoverColor,
+ "--viewer-text": palette.textColor,
+ "--viewer-muted-text": palette.mutedTextColor,
+ "--viewer-control-bg": palette.controlBgColor,
+ "--viewer-control-border": palette.controlBorderColor,
+ "--viewer-control-border-strong": palette.controlBorderStrongColor,
+ "--viewer-control-icon": palette.controlIconColor,
+ } as CSSProperties;
+
+ const downloadMenuButton = allowDownload && (
+ <DropdownMenu open={open} onOpenChange={setOpen}>
+ <DropdownMenuTrigger asChild>
+ <Button
+ variant="ghost"
+ size="icon"
+ className={cn(
+ "h-8 w-8 border bg-transparent p-0",
+ "text-[var(--viewer-control-icon)] border-[var(--viewer-control-border)] hover:bg-[var(--viewer-control-bg)]",
+ "group-hover/row:text-[var(--viewer-text)] group-hover/row:border-[var(--viewer-control-border-strong)]",
+ )}
+ aria-label="Open menu"
+ >
+ <MoreVerticalIcon className="h-4 w-4" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <DropdownMenuLabel>Actions</DropdownMenuLabel>
+ <DropdownMenuItem
+ onClick={(e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ openFolderDownloadModal();
+ setOpen(false);
+ }}
+ disabled={isPreview}
+ >
+ <Download className="h-4 w-4" />
+ Download
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+
+ if (layout === "GRID") {
+ // Compact row tile — folders share the grid with documents but stay short;
+ // the viewer uses a tighter 3-column grid for folder runs only.
+ //
+ // Click-through pattern: the underlying <button> covers the entire card
+ // (absolute inset-0) so the full surface is clickable, including hover
+ // over the icon and name. The content layer uses pointer-events-none so
+ // clicks pass through to the button, and the download menu re-enables
+ // pointer events only on itself.
+ return (
+ <div
+ className={cn(
+ "group/row relative flex min-h-0 cursor-pointer items-center justify-between gap-2 rounded-lg border px-3 py-2 transition-all sm:px-3 sm:py-2.5",
+ "bg-[var(--viewer-panel-bg)] hover:bg-[var(--viewer-panel-bg-hover)]",
+ "border-[var(--viewer-panel-border)] hover:border-[var(--viewer-panel-border-hover)]",
+ )}
+ style={sharedStyle}
+ >
+ <button
+ onClick={() => setFolderId(folder.id)}
+ className="absolute inset-0 z-0 cursor-pointer"
+ aria-label={`Open folder ${folder.name}`}
+ />
+ <div className="pointer-events-none relative flex min-w-0 flex-1 items-center gap-2">
+ {!hideFolderIcons && colorClasses ? (
+ <FolderIconComponent
+ className={`h-7 w-7 shrink-0 sm:h-8 sm:w-8 ${colorClasses.iconClass}`}
+ strokeWidth={1}
+ />
+ ) : null}
+ <div className="min-w-0 flex-1">
+ <h2
+ className="truncate text-sm font-medium leading-tight text-[var(--viewer-text)] sm:leading-5"
+ style={HIERARCHICAL_DISPLAY_STYLE}
+ >
+ {displayNameNode}
+ </h2>
+ {showLastUpdated && (
+ <p className="truncate text-xs leading-4 text-[var(--viewer-muted-text)]">
+ Updated {timeAgo(folder.updatedAt)}
+ </p>
+ )}
+ </div>
+ </div>
+ {downloadMenuButton && (
+ <div className="pointer-events-auto relative z-10 shrink-0">
+ {downloadMenuButton}
+ </div>
+ )}
+ </div>
+ );
+ }
+
+ if (layout === "COMPACT") {
+ const indexLabel =
+ folder.hierarchicalIndex?.trim() ||
+ String(editorialIndex + 1).padStart(2, "0");
+ const gridClass = compactDataroomListGridClass(
+ compactShowUpdatedColumn && showLastUpdated,
+ compactShowActionsColumn,
+ compactShowIndexColumn,
+ );
+ const showUpdatedCell =
+ compactShowUpdatedColumn && showLastUpdated;
+ const actionsSlot = compactShowActionsColumn ? (
+ downloadMenuButton ? (
+ <div className="z-10 flex justify-end pointer-events-auto">
+ {downloadMenuButton}
+ </div>
+ ) : (
+ <span className="inline-flex h-8 w-8 shrink-0" aria-hidden />
+ )
+ ) : null;
+
+ const iconEl =
+ !hideFolderIcons && colorClasses ? (
+ <FolderIconComponent
+ className={`h-5 w-5 shrink-0 ${colorClasses.iconClass}`}
+ strokeWidth={1.5}
+ />
+ ) : null;
+
+ const nameBlock = (
+ <>
+ {iconEl}
+ <h2
+ className="truncate text-sm font-medium leading-5 text-[var(--viewer-text)]"
+ style={HIERARCHICAL_DISPLAY_STYLE}
+ >
+ {displayNameNode}
+ </h2>
+ </>
+ );
+
+ return (
+ <div
+ className={cn(
+ "group/row relative border-b transition-colors",
+ "border-[var(--viewer-panel-border)]",
+ "hover:bg-[var(--viewer-panel-bg-hover)]",
+ "px-2 py-2 sm:px-3",
+ )}
+ style={sharedStyle}
+ >
+ <button
+ type="button"
+ onClick={() => setFolderId(folder.id)}
+ className="absolute inset-0 z-0 cursor-pointer rounded-none border-0 bg-transparent p-0 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--viewer-control-border-strong)]"
+ aria-label={`Open folder ${compactShowIndexColumn ? `${indexLabel} ` : ""}${folder.name}`}
+ />
+ <div className="pointer-events-none relative z-[1] flex items-center justify-between gap-3 sm:hidden">
+ {compactShowIndexColumn ? (
+ <span className="w-9 shrink-0 text-xs tabular-nums text-[var(--viewer-muted-text)]">
+ {indexLabel}
+ </span>
+ ) : null}
+ <div className="flex min-w-0 flex-1 items-center gap-3">{nameBlock}</div>
+ <div className="flex shrink-0 items-center gap-2">
+ {showUpdatedCell ? (
+ <p className="max-w-[38vw] truncate text-xs tabular-nums text-[var(--viewer-muted-text)]">
+ {timeAgo(folder.updatedAt)}
+ </p>
+ ) : null}
+ {compactShowActionsColumn && downloadMenuButton ? (
+ <div className="z-10 pointer-events-auto">{downloadMenuButton}</div>
+ ) : null}
+ </div>
+ </div>
+ <div
+ className={cn(
+ "pointer-events-none relative z-[1] hidden items-center gap-3 sm:grid",
+ gridClass,
+ )}
+ >
+ {compactShowIndexColumn ? (
+ <span className="text-xs tabular-nums text-[var(--viewer-muted-text)]">
+ {indexLabel}
+ </span>
+ ) : null}
+ <div className="flex min-w-0 items-center gap-3">{nameBlock}</div>
+ {showUpdatedCell ? (
+ <p className="truncate text-right text-xs tabular-nums text-[var(--viewer-muted-text)]">
+ {timeAgo(folder.updatedAt)}
+ </p>
+ ) : null}
+ {actionsSlot}
+ </div>
+ </div>
+ );
+ }
+
+ if (layout === "LIST" && editorialList) {
+ const idxLabel =
+ folder.hierarchicalIndex?.trim() ||
+ String(editorialIndex + 1).padStart(2, "0");
+ const updatedLabel = showLastUpdated
+ ? `Updated ${timeAgo(folder.updatedAt)}`
+ : null;
+
+ return (
+ <div
+ className={cn(
+ "group/row relative border-b transition-colors",
+ "border-[var(--viewer-panel-border)]",
+ "hover:bg-[var(--viewer-panel-bg-hover)]",
+ "py-3 pl-2 pr-1 sm:pl-3 sm:pr-2",
+ )}
+ style={sharedStyle}
+ >
+ <button
+ onClick={() => setFolderId(folder.id)}
+ className="absolute inset-0 z-0 cursor-pointer"
+ aria-label={`Open folder ${folder.name}`}
+ />
+ <div className="pointer-events-none relative z-[1] flex flex-col gap-2 md:hidden">
+ <div className="flex items-start justify-between gap-3 pl-7">
+ <span className="absolute left-2 top-0 text-xs tabular-nums text-[var(--viewer-muted-text)]">
+ {idxLabel}
+ </span>
+ <div className="min-w-0 flex-1">
+ <h2
+ className="text-sm font-semibold leading-snug text-[var(--viewer-text)]"
+ style={HIERARCHICAL_DISPLAY_STYLE}
+ >
+ {displayNameNode}
+ </h2>
+ <p className="mt-1 text-xs text-[var(--viewer-muted-text)]">
+ Folder
+ </p>
+ </div>
+ <div className="flex shrink-0 flex-col items-end gap-1 text-[11px] text-[var(--viewer-muted-text)]">
+ {updatedLabel ? <span>{updatedLabel}</span> : null}
+ <span className="font-medium">FOLDER</span>
+ </div>
+ </div>
+ {downloadMenuButton ? (
+ <div className="pointer-events-auto flex justify-end pr-1">
+ {downloadMenuButton}
+ </div>
+ ) : null}
+ </div>
+
+ <div className="pointer-events-none relative z-[1] hidden md:grid md:grid-cols-[2rem_minmax(0,1fr)_minmax(6rem,8rem)_3rem_2.25rem] md:items-center md:gap-4 lg:grid-cols-[2.25rem_minmax(0,1fr)_minmax(7rem,9rem)_3rem_2.25rem]">
+ <span className="text-xs tabular-nums text-[var(--viewer-muted-text)]">
+ {idxLabel}
+ </span>
+ <div className="min-w-0">
+ <h2
+ className="truncate text-sm font-semibold text-[var(--viewer-text)]"
+ style={HIERARCHICAL_DISPLAY_STYLE}
+ >
+ {displayNameNode}
+ </h2>
+ <p className="mt-0.5 truncate text-xs text-[var(--viewer-muted-text)]">
+ Folder
+ </p>
+ </div>
+ <span className="truncate text-right text-xs tabular-nums text-[var(--viewer-muted-text)]">
+ {updatedLabel ?? "—"}
+ </span>
+ <span className="text-center text-[11px] font-medium uppercase tracking-wide text-[var(--viewer-muted-text)]">
+ FOLDER
+ </span>
+ <div className="pointer-events-auto flex justify-end">
+ {downloadMenuButton ?? (
+ <span className="inline-flex h-8 w-8" aria-hidden />
+ )}
+ </div>
+ </div>
+ </div>
+ );
+ }
+
return (
<div
className={cn(
@@ -77,40 +396,22 @@ export default function FolderCard({
"bg-[var(--viewer-panel-bg)] hover:bg-[var(--viewer-panel-bg-hover)]",
"border-[var(--viewer-panel-border)] hover:border-[var(--viewer-panel-border-hover)]",
)}
- style={
- {
- "--viewer-panel-bg": palette.panelBgColor,
- "--viewer-panel-bg-hover": palette.panelHoverBgColor,
- "--viewer-panel-border": palette.panelBorderColor,
- "--viewer-panel-border-hover": palette.panelBorderHoverColor,
- "--viewer-text": palette.textColor,
- "--viewer-muted-text": palette.mutedTextColor,
- "--viewer-control-bg": palette.controlBgColor,
- "--viewer-control-border": palette.controlBorderColor,
- "--viewer-control-border-strong": palette.controlBorderStrongColor,
- "--viewer-control-icon": palette.controlIconColor,
- } as CSSProperties
- }
+ style={sharedStyle}
>
- {/* Click target - outside of text hierarchy to fix Safari truncation issue */}
<button
onClick={() => setFolderId(folder.id)}
className="absolute inset-0 z-0 cursor-pointer"
aria-hidden="true"
/>
<div className="flex min-w-0 shrink items-center space-x-2 sm:space-x-4">
- <div className="mx-0.5 flex w-8 items-center justify-center text-center sm:mx-1">
- {(() => {
- const FolderIconComponent = getFolderIcon(folder.icon);
- const colorClasses = getFolderColorClasses(folder.color);
- return (
- <FolderIconComponent
- className={`h-8 w-8 ${colorClasses.iconClass}`}
- strokeWidth={1}
- />
- );
- })()}
- </div>
+ {!hideFolderIcons && colorClasses ? (
+ <div className="mx-0.5 flex w-8 items-center justify-center text-center sm:mx-1">
+ <FolderIconComponent
+ className={`h-8 w-8 ${colorClasses.iconClass}`}
+ strokeWidth={1}
+ />
+ </div>
+ ) : null}
<div className="min-w-0 flex-1 flex-col">
<div className="flex items-center">
@@ -118,53 +419,17 @@ export default function FolderCard({
className="truncate text-sm font-semibold leading-6 text-[var(--viewer-text)]"
style={HIERARCHICAL_DISPLAY_STYLE}
>
- {displayName}
+ {displayNameNode}
</h2>
</div>
{showLastUpdated && (
- <div
- className="mt-1 flex items-center space-x-1 text-xs leading-5 text-[var(--viewer-muted-text)]"
- >
+ <div className="mt-1 flex items-center space-x-1 text-xs leading-5 text-[var(--viewer-muted-text)]">
<p className="truncate">Updated {timeAgo(folder.updatedAt)}</p>
</div>
)}
</div>
</div>
- {allowDownload ? (
- <div className="z-10">
- <DropdownMenu open={open} onOpenChange={setOpen}>
- <DropdownMenuTrigger asChild>
- <Button
- variant="ghost"
- size="icon"
- className={cn(
- "h-8 w-8 border bg-transparent p-0",
- "text-[var(--viewer-control-icon)] border-[var(--viewer-control-border)] hover:bg-[var(--viewer-control-bg)]",
- "group-hover/row:text-[var(--viewer-text)] group-hover/row:border-[var(--viewer-control-border-strong)]",
- )}
- aria-label="Open menu"
- >
- <MoreVerticalIcon className="h-4 w-4" />
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end">
- <DropdownMenuLabel>Actions</DropdownMenuLabel>
- <DropdownMenuItem
- onClick={(e) => {
- e.preventDefault();
- e.stopPropagation();
- openFolderDownloadModal();
- setOpen(false);
- }}
- disabled={isPreview}
- >
- <Download className="h-4 w-4" />
- Download
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </div>
- ) : null}
+ {downloadMenuButton && <div className="z-10">{downloadMenuButton}</div>}
</div>
);
}
diff --git a/components/view/dataroom/index-file-dialog.tsx b/components/view/dataroom/index-file-dialog.tsx
index 854ee421..ba1c338a 100644
--- a/components/view/dataroom/index-file-dialog.tsx
+++ b/components/view/dataroom/index-file-dialog.tsx
@@ -29,6 +29,9 @@ interface IndexFileDialogProps {
dataroomId: string;
viewerEmail?: string;
viewerId?: string;
+ /** Optional className applied to the trigger button so callers can override
+ * the default outline styling (e.g. theme it to a viewer surface color). */
+ triggerClassName?: string;
}
export default function IndexFileDialog({
@@ -38,6 +41,7 @@ export default function IndexFileDialog({
dataroomId,
viewerEmail,
viewerId,
+ triggerClassName,
}: IndexFileDialogProps) {
const [isLoading, setIsLoading] = useState(false);
const [selectedFormat, setSelectedFormat] =
@@ -119,7 +123,12 @@ export default function IndexFileDialog({
return (
<Dialog open={isOpen} onOpenChange={setIsOpen}>
<DialogTrigger asChild>
- <Button variant="outline" size="sm" disabled={disabled}>
+ <Button
+ variant="outline"
+ size="sm"
+ disabled={disabled}
+ className={triggerClassName}
+ >
<FileSlidersIcon />
Generate Index File
</Button>
diff --git a/components/view/dataroom/introduction-modal.tsx b/components/view/dataroom/introduction-modal.tsx
index f7fe5b77..f2589e3c 100644
--- a/components/view/dataroom/introduction-modal.tsx
+++ b/components/view/dataroom/introduction-modal.tsx
@@ -64,8 +64,8 @@ export function IntroductionInfoButton() {
onClick={openIntroduction}
className={`inline-flex items-center justify-center rounded-full p-1.5 transition-colors ${
hasSeen
- ? "text-muted-foreground hover:bg-muted hover:text-foreground"
- : "border-2 border-gray-900 text-gray-900 hover:bg-gray-100 dark:border-white dark:text-white dark:hover:bg-gray-800"
+ ? "text-[var(--viewer-muted-text)] hover:bg-[var(--viewer-panel-bg-hover)] hover:text-[var(--viewer-text)]"
+ : "border-2 border-[var(--viewer-control-border-strong)] text-[var(--viewer-text)] hover:bg-[var(--viewer-panel-bg-hover)]"
}`}
aria-label="View introduction"
>
diff --git a/components/view/dataroom/nav-dataroom.tsx b/components/view/dataroom/nav-dataroom.tsx
index ea775e12..d2a8eb3f 100644
--- a/components/view/dataroom/nav-dataroom.tsx
+++ b/components/view/dataroom/nav-dataroom.tsx
@@ -3,25 +3,85 @@ import Link from "next/link";
import React, { useEffect, useMemo, useState } from "react";
import { DataroomBrand } from "@prisma/client";
-import { BadgeInfoIcon, Download } from "lucide-react";
import { toast } from "sonner";
-import { formatDate } from "@/lib/utils";
-
import {
- ButtonTooltip,
- Tooltip,
- TooltipContent,
- TooltipTrigger,
-} from "@/components/ui/tooltip";
-import { TooltipProvider } from "@/components/ui/tooltip";
-
-import { Button } from "../../ui/button";
+ asDataroomViewerHeaderStyle,
+ type DataroomViewerHeaderStyle,
+} from "@/ee/features/branding/lib/dataroom-viewer-layout";
+
+import { cn, formatDate } from "@/lib/utils";
+import { useLogoTone } from "@/ee/features/branding/lib/use-logo-tone";
+
+import { classifyDataroomBanner } from "@/ee/features/branding/lib/dataroom-banner";
+
import { ConversationSidebar } from "../conversations/sidebar";
+import { DataroomBannerMedia } from "./dataroom-banner-media";
+import {
+ DataroomTrailingActions,
+ VIEWER_OPEN_DOWNLOAD_EVENT,
+ VIEWER_TOGGLE_CONVERSATIONS_EVENT,
+} from "./dataroom-trailing-actions";
+import { createViewerSurfaceTheme } from "../viewer/viewer-surface-theme";
import { ViewerDownloadProgressModal } from "./viewer-download-progress-modal";
const DEFAULT_BANNER_IMAGE = "/_static/papermark-banner.png";
+/** Matches dataroom viewer main column padding so headers align with the
+ * document area below (see dataroom-viewer.tsx main content padding). */
+const DATAROOM_NAV_PAGE_FRAME =
+ "mx-auto w-full px-3 md:px-6 lg:px-8 xl:px-14";
+
+/**
+ * Notion-preset cover logo chip. Picks a contrasting background behind the
+ * logo based on the logo's averaged pixel luminance: dark logo → white box,
+ * light/white logo → black box. Falls back to a white box while the image is
+ * still loading or when the image host doesn't allow CORS pixel reads.
+ */
+function NotionLogoChip({
+ src,
+ usesSurfaceBackground,
+ surfacePanelBorderColor,
+}: {
+ src: string;
+ usesSurfaceBackground: boolean;
+ surfacePanelBorderColor: string;
+}) {
+ const { tone, imgProps } = useLogoTone(src);
+ // Default to "dark" (i.e. white chip) so the chip is white before analysis
+ // completes — most logos are designed for white backgrounds, so this avoids
+ // a black flash on first load.
+ const isLightLogo = tone === "light";
+ return (
+ <div
+ className={cn(
+ "flex size-16 items-center justify-center overflow-hidden rounded-xl border p-2 shadow-sm sm:size-20",
+ isLightLogo
+ ? "border-neutral-800 bg-neutral-950"
+ : "border-neutral-200 bg-white",
+ )}
+ style={
+ usesSurfaceBackground
+ ? { borderColor: surfacePanelBorderColor }
+ : undefined
+ }
+ >
+ {/* The display <img> doubles as the source for `useLogoTone`'s canvas
+ analysis — `crossOrigin` keeps the canvas read untainted and lets
+ the hook reuse this single decode instead of fetching a second
+ Image() over the wire. */}
+ <img
+ className="h-full w-full object-contain"
+ src={src}
+ alt=""
+ crossOrigin="anonymous"
+ referrerPolicy="no-referrer"
+ {...imgProps}
+ />
+ </div>
+ );
+}
+
export default function DataroomNav({
allowDownload,
allowBulkDownload,
@@ -35,6 +95,11 @@ export default function DataroomNav({
viewerEmail,
conversationsEnabled,
isTeamMember,
+ viewerHeaderStyle: viewerHeaderStyleProp,
+ topBarBreadcrumb,
+ topBarSearch,
+ topBarTrailingActions,
+ surfaceBackgroundColor,
}: {
allowDownload?: boolean;
allowBulkDownload?: boolean;
@@ -48,6 +113,18 @@ export default function DataroomNav({
viewerEmail?: string | null;
conversationsEnabled?: boolean;
isTeamMember?: boolean;
+ viewerHeaderStyle?: DataroomViewerHeaderStyle;
+ /** Modern (SPLIT) header: optional breadcrumb rendered above the inner separator. */
+ topBarBreadcrumb?: React.ReactNode;
+ /** Modern (SPLIT) header: optional search box rendered alongside the breadcrumb. */
+ topBarSearch?: React.ReactNode;
+ /** Modern (SPLIT) header: optional action buttons (Generate Index, Add
+ * Document, etc.) rendered next to the search input on the same line so
+ * the toolbar mirrors what Standard renders in its body toolbar. */
+ topBarTrailingActions?: React.ReactNode;
+ /** Optional surface bg color (e.g. brand accent) applied to SPLIT / NOTION
+ * header so it matches the body when accent color is enabled. */
+ surfaceBackgroundColor?: string | null;
}) {
const [showConversations, setShowConversations] = useState<boolean>(false);
const [showDownloadModal, setShowDownloadModal] = useState<boolean>(false);
@@ -71,12 +148,29 @@ export default function DataroomNav({
setShowDownloadModal(true);
};
window.addEventListener(
- "viewer-download-modal-open" as any,
+ VIEWER_OPEN_DOWNLOAD_EVENT as any,
handler as EventListener,
);
return () =>
window.removeEventListener(
- "viewer-download-modal-open" as any,
+ VIEWER_OPEN_DOWNLOAD_EVENT as any,
+ handler as EventListener,
+ );
+ }, []);
+
+ // Notion preset has no navbar, so its trailing buttons live in the body
+ // toolbar (next to the search). The body toolbar dispatches this event when
+ // the user clicks the conversations button; we honor it here so the
+ // sidebar state stays owned by the nav and we don't need to lift it.
+ useEffect(() => {
+ const handler = () => setShowConversations((prev) => !prev);
+ window.addEventListener(
+ VIEWER_TOGGLE_CONVERSATIONS_EVENT as any,
+ handler as EventListener,
+ );
+ return () =>
+ window.removeEventListener(
+ VIEWER_TOGGLE_CONVERSATIONS_EVENT as any,
handler as EventListener,
);
}, []);
@@ -122,99 +216,334 @@ export default function DataroomNav({
return () => window.removeEventListener("keydown", handleKeyDown);
}, [conversationsEnabled, showConversations]);
+ const hasBanner = brand?.banner !== "no-banner";
+ const viewerHeaderStyle: DataroomViewerHeaderStyle =
+ asDataroomViewerHeaderStyle(
+ (brand as { viewerHeaderStyle?: string } | undefined)
+ ?.viewerHeaderStyle ?? viewerHeaderStyleProp,
+ );
+ const headerMode: "DEFAULT" | "SPLIT" | "NOTION" =
+ hasBanner && dataroom?.name
+ ? viewerHeaderStyle === "SPLIT" || viewerHeaderStyle === "NOTION"
+ ? viewerHeaderStyle
+ : "DEFAULT"
+ : "DEFAULT";
+
+ const bannerSrc = brand?.banner || DEFAULT_BANNER_IMAGE;
+
+ // Video / YouTube banners only play inside Modern's boxed banner slot. The
+ // Default and Notion banners stretch full-width which makes inline video
+ // playback awkward (the player gets distorted across very wide aspect
+ // ratios), so for those layouts we substitute the brand's default banner
+ // image. Modern keeps the original `bannerSrc` to actually play the video.
+ const bannerKind = classifyDataroomBanner(bannerSrc).kind;
+ const fullBleedBannerSrc =
+ bannerKind === "video" || bannerKind === "youtube"
+ ? DEFAULT_BANNER_IMAGE
+ : bannerSrc;
+
+ // The brand logo is rendered without a wrapper card so it sits naturally on
+ // the surface — uploaded logos are typically designed to read on the brand's
+ // chosen background and shouldn't be boxed in a contrasting chip.
+ const renderPrimaryLogo = (forLightBackground?: boolean) =>
+ brand && brand.logo ? (
+ <img
+ className="h-10 w-28 object-contain sm:h-12 sm:w-32"
+ src={brand.logo}
+ alt="Logo"
+ />
+ ) : (
+ <Link
+ href={`https://www.papermark.com?utm_campaign=navbar&utm_medium=navbar&utm_source=papermark-${linkId}`}
+ target="_blank"
+ className={cn(
+ "text-2xl font-bold tracking-tighter",
+ forLightBackground
+ ? "text-neutral-900 dark:text-white"
+ : "text-white",
+ )}
+ >
+ Papermark
+ </Link>
+ );
+
+ const welcomeMessage =
+ (brand as { welcomeMessage?: string | null })?.welcomeMessage?.trim() ||
+ null;
+
+ const eyebrowLine = useMemo(() => {
+ const parts = ["Data room"];
+ if (dataroom?.showLastUpdated && dataroom?.lastUpdatedAt) {
+ parts.push(`Updated ${formatDate(dataroom.lastUpdatedAt)}`);
+ }
+ return parts.join(" · ").toUpperCase();
+ }, [dataroom?.showLastUpdated, dataroom?.lastUpdatedAt]);
+
+ const renderToolbarTrailing = (
+ variant: "onBrand" | "onLight" = "onBrand",
+ ) => (
+ <DataroomTrailingActions
+ variant={variant}
+ isTeamMember={isTeamMember}
+ brand={
+ brand
+ ? {
+ ctaLabel: brand.ctaLabel ?? null,
+ ctaUrl: brand.ctaUrl ?? null,
+ brandColor: brand.brandColor ?? null,
+ accentButtonColor:
+ (brand as { accentButtonColor?: string | null })
+ ?.accentButtonColor ?? null,
+ }
+ : null
+ }
+ conversationsEnabled={conversationsEnabled}
+ allowDownload={allowDownload}
+ allowBulkDownload={allowBulkDownload}
+ viewerEmail={viewerEmail}
+ onToggleConversations={() => setShowConversations(!showConversations)}
+ onOpenDownload={openDownloadModal}
+ />
+ );
+
+ const usesSurfaceBackground =
+ !!surfaceBackgroundColor && surfaceBackgroundColor !== "#ffffff";
+
+ // Adaptive palette mirrors the body so SPLIT (Modern) header text reads
+ // correctly on any accent color picked in branding.
+ const surfaceTheme = useMemo(
+ () => createViewerSurfaceTheme(surfaceBackgroundColor ?? null),
+ [surfaceBackgroundColor],
+ );
+ const surfaceTextStyle = usesSurfaceBackground
+ ? { color: surfaceTheme.palette.textColor }
+ : undefined;
+ const surfaceMutedTextStyle = usesSurfaceBackground
+ ? { color: surfaceTheme.palette.mutedTextColor }
+ : undefined;
+ // Expose the adaptive palette as CSS vars so children that consume the same
+ // `--viewer-*` tokens as the body (breadcrumb, search, separators) adapt to
+ // the accent color in Modern (SPLIT) just like the DEFAULT body does.
+ const splitSurfaceVars = useMemo<React.CSSProperties>(
+ () =>
+ ({
+ "--viewer-text": surfaceTheme.palette.textColor,
+ "--viewer-muted-text": surfaceTheme.palette.mutedTextColor,
+ "--viewer-subtle-text": surfaceTheme.palette.subtleTextColor,
+ "--viewer-panel-bg": surfaceTheme.palette.panelBgColor,
+ "--viewer-panel-bg-hover": surfaceTheme.palette.panelHoverBgColor,
+ "--viewer-panel-border": surfaceTheme.palette.panelBorderColor,
+ "--viewer-panel-border-hover":
+ surfaceTheme.palette.panelBorderHoverColor,
+ "--viewer-control-bg": surfaceTheme.palette.controlBgColor,
+ "--viewer-control-border": surfaceTheme.palette.controlBorderColor,
+ "--viewer-control-border-strong":
+ surfaceTheme.palette.controlBorderStrongColor,
+ "--viewer-control-icon": surfaceTheme.palette.controlIconColor,
+ "--viewer-placeholder":
+ surfaceTheme.palette.controlPlaceholderColor,
+ // Brand accent passes through to nav children (breadcrumb leaf renders
+ // inside the nav in Modern, so we surface the var here too).
+ "--viewer-accent":
+ (brand as any)?.accentButtonColor ||
+ brand?.brandColor ||
+ surfaceTheme.palette.textColor,
+ }) as React.CSSProperties,
+ [surfaceTheme, brand],
+ );
+
return (
<nav
- className="bg-black"
- style={{
- backgroundColor: brand && brand.brandColor ? brand.brandColor : "black",
- }}
+ className={cn(
+ headerMode === "SPLIT"
+ ? cn(
+ "border-b border-[var(--viewer-panel-border)] text-neutral-900 dark:text-neutral-100",
+ usesSurfaceBackground
+ ? ""
+ : "bg-white dark:bg-neutral-950",
+ )
+ : "bg-black",
+ )}
+ style={
+ headerMode === "SPLIT"
+ ? {
+ ...splitSurfaceVars,
+ ...(usesSurfaceBackground
+ ? { backgroundColor: surfaceBackgroundColor as string }
+ : {}),
+ }
+ : {
+ backgroundColor:
+ brand && brand.brandColor ? brand.brandColor : "black",
+ }
+ }
>
- <div className="mx-auto px-2 sm:px-6 lg:px-8">
- <div className="relative flex h-16 items-center justify-between">
- <div className="flex flex-1 items-center justify-start">
- <div className="relative flex h-16 w-36 flex-shrink-0 items-center">
- {brand && brand.logo ? (
- <img
- className="h-16 w-36 object-contain"
- src={brand.logo}
- alt="Logo"
+ {headerMode === "NOTION" && hasBanner ? (
+ <>
+ {/* Notion layout: no brand-colored navbar above the cover — the
+ banner is the top of the page (Notion convention). The nav's
+ trailing buttons (CTA, conversations, download) are hoisted into
+ the body toolbar (right of the search input) by
+ `dataroom-viewer.tsx` and reach back here via the
+ `viewer-conversation-toggle` and `viewer-download-modal-open`
+ custom events. */}
+ <div className="relative h-[20vh] w-full overflow-hidden bg-neutral-100 dark:bg-neutral-900 sm:h-auto sm:max-h-80">
+ <DataroomBannerMedia
+ src={fullBleedBannerSrc}
+ className="h-full w-full object-cover sm:max-h-80 sm:object-contain xl:object-cover"
+ />
+ </div>
+ <div
+ className={cn(
+ "text-black dark:text-white",
+ usesSurfaceBackground
+ ? ""
+ : "bg-white dark:bg-neutral-950",
+ )}
+ style={
+ usesSurfaceBackground
+ ? {
+ ...splitSurfaceVars,
+ backgroundColor: surfaceBackgroundColor as string,
+ }
+ : splitSurfaceVars
+ }
+ >
+ <div className={cn(DATAROOM_NAV_PAGE_FRAME, "pb-10 pt-2")}>
+ <div className="-mt-10 relative z-10 flex w-full flex-col items-start text-left sm:-mt-12">
+ <NotionLogoChip
+ src={brand?.logo ?? "/_static/papermark-p.svg"}
+ usesSurfaceBackground={usesSurfaceBackground}
+ surfacePanelBorderColor={
+ surfaceTheme.palette.panelBorderColor
+ }
/>
- ) : (
- <Link
- href={`https://www.papermark.com?utm_campaign=navbar&utm_medium=navbar&utm_source=papermark-${linkId}`}
- target="_blank"
- className="text-2xl font-bold tracking-tighter text-white"
+ <div
+ className="mt-4 max-w-3xl text-3xl"
+ style={surfaceTextStyle}
>
- Papermark
- </Link>
- )}
+ {dataroom.name}
+ </div>
+ {dataroom.showLastUpdated ? (
+ <time
+ className="mt-0.5 block text-sm text-neutral-600 dark:text-neutral-400"
+ style={surfaceMutedTextStyle}
+ dateTime={new Date(dataroom.lastUpdatedAt).toISOString()}
+ >
+ {`Last updated ${formatDate(dataroom.lastUpdatedAt)}`}
+ </time>
+ ) : null}
+ </div>
</div>
</div>
- <div className="absolute inset-y-0 right-0 flex items-center space-x-4 pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0">
- {isTeamMember ? (
- <TooltipProvider delayDuration={100}>
- <Tooltip defaultOpen>
- <TooltipTrigger asChild>
- <Button
- className="size-8 bg-gray-900 text-white hover:bg-gray-900/80 sm:size-10"
- size="icon"
- >
- <BadgeInfoIcon className="h-5 w-5" />
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- <p className="max-w-xs text-wrap text-center">
- Skipped verification because you are a team member; no
- analytics will be collected
- </p>
- </TooltipContent>
- </Tooltip>
- </TooltipProvider>
- ) : null}
- {conversationsEnabled && (
- <Button onClick={() => setShowConversations(!showConversations)}>
- View FAQ
- </Button>
- )}
- {allowDownload && allowBulkDownload && viewerEmail ? (
- <ButtonTooltip content="Download Dataroom">
- <Button
- onClick={openDownloadModal}
- className="m-1 bg-gray-900 text-white hover:bg-gray-900/80"
- size="icon"
+ </>
+ ) : headerMode === "SPLIT" && hasBanner ? (
+ <>
+ <div
+ className={cn(DATAROOM_NAV_PAGE_FRAME, "pt-4")}
+ style={splitSurfaceVars}
+ >
+ <div className="flex items-center justify-between gap-2 border-b border-[var(--viewer-panel-border)] pb-2">
+ <div className="relative flex min-h-14 min-w-0 shrink-0 items-center overflow-y-hidden">
+ {renderPrimaryLogo(true)}
+ </div>
+ <div className="flex min-w-0 shrink items-center justify-end gap-2">
+ {renderToolbarTrailing("onLight")}
+ </div>
+ </div>
+
+ <div className="grid gap-4 py-4 lg:grid-cols-[minmax(0,1fr)_minmax(220px,40%)] lg:items-center lg:gap-8 lg:py-6">
+ <div className="min-w-0 space-y-2">
+ <p
+ className="text-[11px] font-medium uppercase tracking-[0.2em] text-neutral-500 dark:text-neutral-400"
+ style={surfaceMutedTextStyle}
>
- <Download className="h-5 w-5" />
- </Button>
- </ButtonTooltip>
+ {eyebrowLine}
+ </p>
+ <h1
+ className="text-balance text-3xl text-neutral-950 dark:text-white"
+ style={surfaceTextStyle}
+ >
+ {dataroom.name}
+ </h1>
+ {welcomeMessage ? (
+ <p
+ className="max-w-2xl text-pretty text-sm leading-relaxed text-neutral-600 dark:text-neutral-300"
+ style={surfaceMutedTextStyle}
+ >
+ {welcomeMessage}
+ </p>
+ ) : null}
+ </div>
+ <div className="relative aspect-[16/7] w-full overflow-hidden rounded-xl border border-neutral-200/90 bg-neutral-200/30 shadow-sm dark:border-neutral-800 dark:bg-neutral-900 lg:aspect-[16/9]">
+ <div className="absolute inset-0">
+ <DataroomBannerMedia src={bannerSrc} alt="" />
+ </div>
+ </div>
+ </div>
+
+ {(topBarBreadcrumb || topBarSearch || topBarTrailingActions) ? (
+ <div className="flex flex-col gap-3 py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4">
+ <div className="min-w-0 flex-1 overflow-hidden">
+ {topBarBreadcrumb}
+ </div>
+ {/* Right cluster: search + trailing actions live on the same
+ line so Modern's toolbar mirrors the Standard body toolbar
+ (search + Generate Index + Add Document together). On
+ mobile, this wraps so the buttons drop below the search
+ instead of overflowing the row. */}
+ {(topBarSearch || topBarTrailingActions) ? (
+ <div className="flex w-full min-w-0 flex-wrap items-center gap-2 sm:w-auto sm:shrink-0 sm:flex-nowrap sm:gap-x-2">
+ {topBarSearch ? (
+ <div className="w-full min-w-0 sm:w-72 sm:min-w-[12rem] sm:max-w-sm sm:flex-none">
+ {topBarSearch}
+ </div>
+ ) : null}
+ {topBarTrailingActions}
+ </div>
+ ) : null}
+ </div>
) : null}
</div>
- </div>
- </div>
-
- {/* Banner section */}
- {brand?.banner !== "no-banner" && (
- <div className="relative h-[20vh] sm:h-auto sm:max-h-80">
- <img
- className="h-full w-full object-cover sm:max-h-80 sm:object-contain xl:object-cover"
- src={brand?.banner || DEFAULT_BANNER_IMAGE}
- alt="Banner"
- width={1920}
- height={320}
- />
- <div className="absolute bottom-5 w-fit rounded-r-md bg-white/30 backdrop-blur-md">
- <div className="px-5 py-2 sm:px-10">
- <div className="text-3xl">{dataroom.name}</div>
- {dataroom.showLastUpdated ? (
- <time
- className="mt-1 block text-sm"
- dateTime={new Date(dataroom.lastUpdatedAt).toISOString()}
- >
- {`Last updated ${formatDate(dataroom.lastUpdatedAt)}`}
- </time>
- ) : null}
+ </>
+ ) : (
+ <>
+ <div className={DATAROOM_NAV_PAGE_FRAME}>
+ <div className="relative flex h-16 items-center justify-between">
+ <div className="flex flex-1 items-center justify-start">
+ <div className="relative flex h-16 w-36 flex-shrink-0 items-center">
+ {renderPrimaryLogo()}
+ </div>
+ </div>
+ <div className="absolute inset-y-0 right-0 flex items-center space-x-4 pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0">
+ {renderToolbarTrailing("onBrand")}
+ </div>
</div>
</div>
- </div>
+
+ {hasBanner ? (
+ <div className="relative h-[20vh] sm:h-auto sm:max-h-80">
+ <DataroomBannerMedia
+ src={fullBleedBannerSrc}
+ alt="Banner"
+ className="h-full w-full object-cover sm:max-h-80 sm:object-contain xl:object-cover"
+ />
+ <div className="absolute bottom-5 w-fit rounded-r-md bg-white/30 backdrop-blur-md">
+ <div className="px-5 py-2 sm:px-10">
+ <div className="text-3xl">{dataroom.name}</div>
+ {dataroom.showLastUpdated ? (
+ <time
+ className="mt-0.5 block text-sm"
+ dateTime={new Date(dataroom.lastUpdatedAt).toISOString()}
+ >
+ {`Last updated ${formatDate(dataroom.lastUpdatedAt)}`}
+ </time>
+ ) : null}
+ </div>
+ </div>
+ </div>
+ ) : null}
+ </>
)}
{linkId && viewId && viewerEmail && (
diff --git a/components/view/nav.tsx b/components/view/nav.tsx
index bfabbec3..30522b6b 100644
--- a/components/view/nav.tsx
+++ b/components/view/nav.tsx
@@ -250,7 +250,7 @@ export default function Nav({
<div className="absolute inset-y-0 right-0 flex items-center space-x-2 pr-2 sm:static sm:inset-auto sm:ml-6 sm:space-x-4 sm:pr-0">
{isTeamMember && (
<TooltipProvider delayDuration={100}>
- <Tooltip defaultOpen>
+ <Tooltip>
<TooltipTrigger asChild>
<Button
className="size-8 bg-gray-900 text-white hover:bg-gray-900/80 sm:size-10"
@@ -274,7 +274,7 @@ export default function Nav({
onClick={() => setShowConversations(!showConversations)}
className="bg-gray-900 text-white hover:bg-gray-900/80"
>
- View FAQ
+ View Q&A
</Button>
)}
{/* Annotations toggle button */}
diff --git a/components/view/viewer/dataroom-viewer.tsx b/components/view/viewer/dataroom-viewer.tsx
index 5901f35d..d1b9cbcf 100644
--- a/components/view/viewer/dataroom-viewer.tsx
+++ b/components/view/viewer/dataroom-viewer.tsx
@@ -15,6 +15,13 @@ import {
PermissionGroupAccessControls,
ViewerGroupAccessControls,
} from "@prisma/client";
+
+import {
+ asDataroomCardLayout,
+ asDataroomViewerHeaderStyle,
+ type DataroomCardLayout,
+ type DataroomViewerHeaderStyle,
+} from "@/ee/features/branding/lib/dataroom-viewer-layout";
import * as SheetPrimitive from "@radix-ui/react-dialog";
import { PanelLeftIcon, UploadIcon, XIcon } from "lucide-react";
@@ -36,7 +43,6 @@ import {
BreadcrumbPage,
BreadcrumbSeparator,
} from "@/components/ui/breadcrumb";
-import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
import {
Sheet,
SheetOverlay,
@@ -46,13 +52,20 @@ import {
import { DEFAULT_DATAROOM_VIEW_TYPE } from "../dataroom/dataroom-view";
import DocumentCard from "../dataroom/document-card";
+import { DataroomNoBannerTitle } from "../dataroom/dataroom-no-banner-title";
import { DocumentUploadModal } from "../dataroom/document-upload-modal";
+import {
+ DataroomTrailingActions,
+ VIEWER_OPEN_DOWNLOAD_EVENT,
+ VIEWER_TOGGLE_CONVERSATIONS_EVENT,
+} from "../dataroom/dataroom-trailing-actions";
import FolderCard from "../dataroom/folder-card";
import IndexFileDialog from "../dataroom/index-file-dialog";
import {
IntroductionInfoButton,
IntroductionProvider,
} from "../dataroom/introduction-modal";
+import { CompactDataroomListHeader } from "../dataroom/compact-dataroom-list-header";
import DataroomNav from "../dataroom/nav-dataroom";
import PendingDocumentCard from "../dataroom/pending-document-card";
import {
@@ -80,7 +93,7 @@ const ViewerBreadcrumbItem = ({
if (isLast) {
return (
<BreadcrumbPage
- className="capitalize text-[var(--viewer-text)]"
+ className="font-medium capitalize text-[var(--viewer-text)]"
style={HIERARCHICAL_DISPLAY_STYLE}
>
{displayName}
@@ -91,7 +104,7 @@ const ViewerBreadcrumbItem = ({
return (
<BreadcrumbLink
onClick={() => setFolderId(folder.id)}
- className="cursor-pointer capitalize text-[var(--viewer-muted-text)] hover:text-[var(--viewer-text)]"
+ className="-mx-1.5 cursor-pointer rounded-md px-1.5 py-0.5 capitalize text-[var(--viewer-muted-text)] transition-colors hover:bg-[var(--viewer-panel-bg-hover)] hover:text-[var(--viewer-text)]"
style={HIERARCHICAL_DISPLAY_STYLE}
>
{displayName}
@@ -110,6 +123,7 @@ export type DocumentVersion = {
hasPages: boolean;
isVertical: boolean;
updatedAt: Date;
+ fileSize?: number | bigint | null;
};
type DataroomDocument = {
@@ -125,6 +139,24 @@ type DataroomDocument = {
hierarchicalIndex: string | null;
};
+type GridRun = { kind: "folder" | "document"; items: FolderOrDocument[] };
+
+/** Preserve sort order but split into runs so folder vs document grids can differ. */
+function segmentMixedItemsForGrid(items: FolderOrDocument[]): GridRun[] {
+ const segments: GridRun[] = [];
+ for (const item of items) {
+ const kind: "folder" | "document" =
+ "versions" in item ? "document" : "folder";
+ const last = segments[segments.length - 1];
+ if (last?.kind === kind) {
+ last.items.push(item);
+ } else {
+ segments.push({ kind, items: [item] });
+ }
+ }
+ return segments;
+}
+
const getParentFolders = (
folderId: string | null,
folders: DataroomFolder[],
@@ -158,6 +190,7 @@ export default function DataroomViewer({
isEmbedded,
viewerEmail,
dataroomIndexEnabled,
+ showPoweredByBanner,
}: {
brand: Partial<DataroomBrand>;
viewId?: string;
@@ -174,6 +207,7 @@ export default function DataroomViewer({
isEmbedded?: boolean;
viewerEmail?: string;
dataroomIndexEnabled?: boolean;
+ showPoweredByBanner?: boolean;
}) {
const { documents, folders, allowBulkDownload } = dataroom as {
documents: DataroomDocument[];
@@ -204,6 +238,40 @@ export default function DataroomViewer({
[folderId, folders],
);
+ const toolbarBreadcrumbEl = useMemo(
+ () => (
+ <Breadcrumb>
+ <BreadcrumbList className="text-[var(--viewer-muted-text)]">
+ <BreadcrumbItem key="root">
+ <BreadcrumbLink
+ onClick={() => setFolderId(null)}
+ className="-mx-1.5 cursor-pointer rounded-md px-1.5 py-0.5 text-[var(--viewer-muted-text)] transition-colors hover:bg-[var(--viewer-panel-bg-hover)] hover:text-[var(--viewer-text)]"
+ >
+ Home
+ </BreadcrumbLink>
+ </BreadcrumbItem>
+
+ {breadcrumbFolders.map((folder, index) => (
+ <React.Fragment key={folder.id}>
+ <BreadcrumbSeparator
+ className="text-[var(--viewer-subtle-text)]"
+ />
+ <BreadcrumbItem>
+ <ViewerBreadcrumbItem
+ folder={folder}
+ setFolderId={setFolderId}
+ isLast={index === breadcrumbFolders.length - 1}
+ dataroomIndexEnabled={dataroomIndexEnabled}
+ />
+ </BreadcrumbItem>
+ </React.Fragment>
+ ))}
+ </BreadcrumbList>
+ </Breadcrumb>
+ ),
+ [breadcrumbFolders, dataroomIndexEnabled, setFolderId],
+ );
+
// Index access controls by `itemId` once per change so the per-document
// lookups below are O(1) instead of O(A). Without this, the descendant
// walk and the per-render `mixedItems` build each do an N×M scan over
@@ -353,6 +421,25 @@ export default function DataroomViewer({
return effectiveUpdatedAt;
}, [folders, documents]);
+ const cardLayout: DataroomCardLayout = asDataroomCardLayout(
+ (brand as any)?.cardLayout,
+ );
+
+ const viewerHeaderStyle: DataroomViewerHeaderStyle =
+ asDataroomViewerHeaderStyle(
+ (brand as { viewerHeaderStyle?: string }).viewerHeaderStyle,
+ );
+
+ const isModernLayout = viewerHeaderStyle === "SPLIT";
+
+ // Notion preset hides the dataroom navbar entirely (just a cover image +
+ // title). The nav's trailing buttons (CTA, conversations, download) get
+ // hoisted into the body toolbar so they sit on the right of the search.
+ const notionHasBanner =
+ (brand?.banner ?? null) !== "no-banner" && !!brand?.banner;
+ const isNotionLayout =
+ viewerHeaderStyle === "NOTION" && notionHasBanner;
+
// create a mixedItems array with folders and documents of the current folder and memoize it
const mixedItems = useMemo(() => {
// If there's a search query, filter documents by name across all folders
@@ -375,47 +462,56 @@ export default function DataroomViewer({
.sort((a, b) => (a.orderIndex || 0) - (b.orderIndex || 0));
}
- const mixedItems: FolderOrDocument[] = [
- ...(folders || [])
- .filter((folder) => folder.parentId === folderId)
- .map((folder) => {
- // Get pre-calculated effective updatedAt
- const effectiveUpdatedAt =
- folderEffectiveUpdatedAt.get(folder.id) ||
- new Date(folder.updatedAt);
-
- // Show the download action when any descendant doc is downloadable
- // — including the partial case where some are and some aren't, and
- // the deeply-nested case where the only downloadable doc lives
- // several levels below this folder.
- const hasDownloadableDescendant =
- folderHasDownloadableDescendant.get(folder.id) ?? false;
+ const folderItems: FolderOrDocument[] = (folders || [])
+ .filter((folder) => folder.parentId === folderId)
+ .map((folder) => {
+ // Get pre-calculated effective updatedAt
+ const effectiveUpdatedAt =
+ folderEffectiveUpdatedAt.get(folder.id) ||
+ new Date(folder.updatedAt);
+
+ // Show the download action when any descendant doc is downloadable
+ // — including the partial case where some are and some aren't, and
+ // the deeply-nested case where the only downloadable doc lives
+ // several levels below this folder.
+ const hasDownloadableDescendant =
+ folderHasDownloadableDescendant.get(folder.id) ?? false;
+
+ return {
+ ...folder,
+ updatedAt: effectiveUpdatedAt,
+ itemType: "folder",
+ allowDownload: allowDownload && hasDownloadableDescendant,
+ };
+ });
- return {
- ...folder,
- updatedAt: effectiveUpdatedAt,
- itemType: "folder",
- allowDownload: allowDownload && hasDownloadableDescendant,
- };
- }),
- ...(documents || [])
- .filter((doc) => doc.folderId === folderId)
- .map((doc) => {
- const accessControl = accessControlByItemId.get(
- doc.dataroomDocumentId,
- );
+ const documentItems: FolderOrDocument[] = (documents || [])
+ .filter((doc) => doc.folderId === folderId)
+ .map((doc) => {
+ const accessControl = accessControlByItemId.get(
+ doc.dataroomDocumentId,
+ );
- return {
- ...doc,
- itemType: "document",
- canDownload:
- (accessControl?.canDownload ?? true) &&
- doc.versions[0].type !== "notion",
- };
- }),
- ];
+ return {
+ ...doc,
+ itemType: "document",
+ canDownload:
+ (accessControl?.canDownload ?? true) &&
+ doc.versions[0].type !== "notion",
+ };
+ });
+
+ // Notion design always groups folders above documents in a clean two-row
+ // grid; other layouts keep the legacy interleaved order so admins can mix
+ // folders/docs by orderIndex.
+ if (isNotionLayout) {
+ return [
+ ...sortByIndexThenName(folderItems),
+ ...sortByIndexThenName(documentItems),
+ ];
+ }
- return sortByIndexThenName(mixedItems);
+ return sortByIndexThenName([...folderItems, ...documentItems]);
}, [
folders,
documents,
@@ -425,8 +521,19 @@ export default function DataroomViewer({
folderEffectiveUpdatedAt,
folderHasDownloadableDescendant,
searchQuery,
+ isNotionLayout,
]);
+ const compactListShowsActionsColumn = useMemo(() => {
+ if (cardLayout !== "COMPACT" || !allowDownload) return false;
+ return mixedItems.some((item) =>
+ "versions" in item ? item.canDownload : item.allowDownload,
+ );
+ }, [cardLayout, allowDownload, mixedItems]);
+
+ const compactTableShowUpdated =
+ cardLayout === "COMPACT" && (dataroom?.showLastUpdated ?? true);
+
const filteredPendingUploads = useMemo(
() =>
pendingUploadsForFolder.filter((u) => {
@@ -461,7 +568,7 @@ export default function DataroomViewer({
});
}, [allUploads, documents, updatePendingUpload]);
- const renderItem = (item: FolderOrDocument) => {
+ const renderItem = (item: FolderOrDocument, editorialIndex = 0) => {
if ("versions" in item) {
const isProcessing =
["docs", "slides", "pdf"].includes(item.versions[0].type) &&
@@ -478,6 +585,11 @@ export default function DataroomViewer({
isProcessing={isProcessing}
dataroomIndexEnabled={dataroomIndexEnabled}
showLastUpdated={dataroom?.showLastUpdated ?? true}
+ layout={cardLayout}
+ compactShowUpdatedColumn={compactTableShowUpdated}
+ compactShowActionsColumn={compactListShowsActionsColumn}
+ compactShowIndexColumn={cardLayout === "COMPACT"}
+ editorialIndex={editorialIndex}
/>
);
}
@@ -494,6 +606,12 @@ export default function DataroomViewer({
allowDownload={item.allowDownload}
dataroomIndexEnabled={dataroomIndexEnabled}
showLastUpdated={dataroom?.showLastUpdated ?? true}
+ layout={cardLayout}
+ hideFolderIcons={hideFolderIconsInMain}
+ compactShowUpdatedColumn={compactTableShowUpdated}
+ compactShowActionsColumn={compactListShowsActionsColumn}
+ compactShowIndexColumn={cardLayout === "COMPACT"}
+ editorialIndex={editorialIndex}
/>
);
};
@@ -507,6 +625,36 @@ export default function DataroomViewer({
),
[brand],
);
+
+ const showFolderTree = (brand as any)?.showFolderTree !== false;
+ const showLeftColumnDesktop = showFolderTree;
+ const showNoBannerTitle = brand?.banner === "no-banner";
+ const hideFolderIconsInMain =
+ (brand as { hideFolderIconsInMain?: boolean }).hideFolderIconsInMain ===
+ true;
+
+ const itemListClassName = cn(
+ "overflow-auto",
+ cardLayout === "GRID"
+ ? "" // GRID uses segmented lists below
+ : cardLayout === "COMPACT"
+ ? ""
+ : "-mx-4 space-y-4 p-4",
+ );
+
+ const folderGridListClassName = cn(
+ "grid grid-cols-2 gap-3 sm:grid-cols-3 sm:gap-4",
+ );
+ const documentGridListClassName = cn(
+ "grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5",
+ );
+
+ // Shared className for body-toolbar trigger buttons (Generate Index, Add
+ // Document) so they blend with the dataroom's current surface — light on
+ // white backgrounds, dark on accent-colored backgrounds, etc. Mirrors the
+ // search input's adaptive styling.
+ const viewerThemedTriggerClass =
+ "border-[var(--viewer-control-border)] bg-[var(--viewer-control-bg)] text-[var(--viewer-text)] hover:bg-[var(--viewer-panel-bg-hover)] hover:text-[var(--viewer-text)]";
const mobileTreeTheme = useMemo(
() => ({
...viewerSurfaceTheme,
@@ -549,11 +697,58 @@ export default function DataroomViewer({
viewerEmail={viewerEmail}
conversationsEnabled={viewData.conversationsEnabled}
isTeamMember={viewData.isTeamMember}
+ topBarBreadcrumb={isModernLayout ? toolbarBreadcrumbEl : undefined}
+ topBarSearch={
+ isModernLayout ? (
+ <SearchBoxPersisted
+ inputClassName="h-9 border-[var(--viewer-control-border)] bg-[var(--viewer-control-bg)] text-[var(--viewer-text)] placeholder:text-[var(--viewer-placeholder)] shadow-sm hover:border-[var(--viewer-control-border-strong)] focus:border-[var(--viewer-control-border-strong)]"
+ leftIconClassName="text-[var(--viewer-control-icon)]"
+ clearIconClassName="text-[var(--viewer-control-icon)] hover:text-[var(--viewer-text)]"
+ />
+ ) : undefined
+ }
+ topBarTrailingActions={
+ isModernLayout ? (
+ <>
+ <IntroductionInfoButton />
+ {enableIndexFile && viewId && viewerId && (
+ <IndexFileDialog
+ linkId={linkId}
+ viewId={viewId}
+ dataroomId={dataroom?.id}
+ viewerId={viewerId}
+ viewerEmail={viewerEmail}
+ triggerClassName={viewerThemedTriggerClass}
+ />
+ )}
+ {viewData?.enableVisitorUpload && viewerId && (
+ <DocumentUploadModal
+ linkId={linkId}
+ dataroomId={dataroom?.id}
+ viewerId={viewerId}
+ folderId={folderId ?? undefined}
+ folderName={
+ folderId
+ ? folders.find((f) => f.id === folderId)?.name
+ : undefined
+ }
+ allowedFolders={viewData?.uploadFolderAllowList}
+ triggerClassName={viewerThemedTriggerClass}
+ />
+ )}
+ </>
+ ) : undefined
+ }
+ surfaceBackgroundColor={
+ (brand as any)?.applyAccentColorToDataroomView
+ ? brand?.accentColor ?? null
+ : null
+ }
/>
<ViewerSurfaceThemeProvider value={viewerSurfaceTheme}>
<ViewerChatLayout>
<div
- className="relative flex flex-1 items-center overflow-hidden bg-white dark:bg-black"
+ className="relative flex flex-1 flex-col bg-white dark:bg-black"
style={
viewerSurfaceTheme.palette.backgroundColor
? { backgroundColor: viewerSurfaceTheme.palette.backgroundColor }
@@ -561,7 +756,7 @@ export default function DataroomViewer({
}
>
<div
- className="relative mx-auto flex h-full w-full items-start justify-center"
+ className="relative mx-auto flex w-full flex-1 flex-col"
style={
{
"--viewer-text": viewerSurfaceTheme.palette.textColor,
@@ -584,144 +779,204 @@ export default function DataroomViewer({
viewerSurfaceTheme.palette.controlIconColor,
"--viewer-placeholder":
viewerSurfaceTheme.palette.controlPlaceholderColor,
+ // Brand accent — opt-in highlights for index prefix, breadcrumb
+ // leaf, etc. Falls back to brand color, then the surface text
+ // color so it always reads on the current surface.
+ "--viewer-accent":
+ (brand as any)?.accentButtonColor ||
+ brand?.brandColor ||
+ viewerSurfaceTheme.palette.textColor,
} as React.CSSProperties
}
>
- {/* Tree view */}
+ <div className="flex w-full flex-1 items-start justify-center">
+ {showLeftColumnDesktop && (
<div
- className="hidden h-full shrink-0 overflow-y-auto overflow-x-hidden px-3 pb-4 pt-4 md:block md:px-4 md:pt-6 lg:px-6 lg:pt-9 xl:px-8"
+ className="sticky top-0 hidden max-h-screen shrink-0 self-start overflow-y-auto overflow-x-hidden px-3 pb-4 pt-4 md:block md:px-4 md:pt-6 lg:px-6 lg:pt-9 xl:px-8"
style={{
- // Fluid sidebar: grows with viewport but clamped to sensible
- // bounds so the tree fills available space without feeling
- // cramped on narrow screens or stretched on ultra-wide ones.
width: "clamp(260px, 28vw, 440px)",
}}
>
- <ViewFolderTree
- folders={folders}
- documents={documents}
- setFolderId={setFolderId}
- folderId={folderId}
- dataroomIndexEnabled={dataroomIndexEnabled}
- />
+ {showNoBannerTitle ? (
+ <DataroomNoBannerTitle
+ name={dataroom.name}
+ lastUpdatedAt={dataroom.lastUpdatedAt}
+ showLastUpdated={dataroom.showLastUpdated}
+ className="mb-3"
+ />
+ ) : null}
+ {showFolderTree && (
+ <ViewFolderTree
+ folders={folders}
+ documents={documents}
+ setFolderId={setFolderId}
+ folderId={folderId}
+ dataroomIndexEnabled={dataroomIndexEnabled}
+ />
+ )}
</div>
+ )}
- {/* Detail view */}
- <ScrollArea
- showScrollbar
- className="h-full flex-grow overflow-auto"
- >
+ {/* Detail view — scrolls with the page, not in its own viewport */}
+ <div className="min-w-0 flex-grow">
<div
- className="h-full px-3 pb-4 pt-4 md:px-6 md:pt-6 lg:px-8 lg:pt-9 xl:px-14"
+ className="px-3 pb-4 pt-4 md:px-6 md:pt-6 lg:px-8 lg:pt-9 xl:px-14"
>
- <div className="flex items-center gap-x-2">
- {/* sidebar for mobile */}
- <div className="flex md:hidden">
- <Sheet>
- <SheetTrigger asChild>
- <button className={cn(
- "lg:hidden",
- "text-[var(--viewer-subtle-text)]",
- )}>
- <PanelLeftIcon
- className="h-5 w-5"
- aria-hidden="true"
+ {showNoBannerTitle && !showLeftColumnDesktop ? (
+ <DataroomNoBannerTitle
+ name={dataroom.name}
+ lastUpdatedAt={dataroom.lastUpdatedAt}
+ showLastUpdated={dataroom.showLastUpdated}
+ className="mb-2 md:mb-3"
+ />
+ ) : null}
+ {/* Modern (SPLIT + LIST) renders its toolbar (breadcrumb,
+ search, action buttons) inside the nav top-row so the
+ body skips this section entirely. All other layouts use
+ the in-body toolbar below. */}
+ {!isModernLayout ? (
+ <div className="flex items-center gap-x-2">
+ {/* Mobile folder tree drawer — only when folder navigation is enabled */}
+ {showFolderTree ? (
+ <div className="flex md:hidden">
+ <Sheet>
+ <SheetTrigger asChild>
+ <button
+ className={cn(
+ "lg:hidden",
+ "text-[var(--viewer-subtle-text)]",
+ )}
+ >
+ <PanelLeftIcon
+ className="h-5 w-5"
+ aria-hidden="true"
+ />
+ </button>
+ </SheetTrigger>
+ <SheetPortal>
+ <SheetOverlay className="fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0" />
+ <SheetPrimitive.Content
+ className={cn(
+ "fixed inset-y-0 left-0 z-50 gap-4 bg-background shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",
+ "border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-lg",
+ "m-0 w-[280px] p-0 sm:w-[300px] lg:hidden",
+ )}
+ >
+ <div className="mt-8 h-full space-y-8 overflow-auto px-2 py-3">
+ <ViewerSurfaceThemeProvider
+ value={mobileTreeTheme}
+ >
+ {showNoBannerTitle ? (
+ <DataroomNoBannerTitle
+ name={dataroom.name}
+ lastUpdatedAt={dataroom.lastUpdatedAt}
+ showLastUpdated={
+ dataroom.showLastUpdated
+ }
+ className="mb-3 px-1"
+ />
+ ) : null}
+ <ViewFolderTree
+ folders={folders}
+ documents={documents}
+ setFolderId={setFolderId}
+ folderId={folderId}
+ dataroomIndexEnabled={
+ dataroomIndexEnabled
+ }
+ />
+ </ViewerSurfaceThemeProvider>
+ </div>
+ <SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary">
+ <XIcon className="h-4 w-4" />
+ <span className="sr-only">Close</span>
+ </SheetPrimitive.Close>
+ </SheetPrimitive.Content>
+ </SheetPortal>
+ </Sheet>
+ </div>
+ ) : null}
+
+ <div className="flex min-w-0 flex-1 items-center justify-between gap-x-2">
+ {toolbarBreadcrumbEl}
+
+ {/* Right cluster: search + buttons. Single inline row on
+ sm+ (matches the historical layout). On narrow
+ mobile we allow wrapping so the buttons drop to a
+ new line instead of overflowing the row — this is
+ the only mobile concession; sm+ is unchanged. */}
+ <div className="flex flex-wrap items-center justify-end gap-2 sm:flex-nowrap sm:gap-x-2">
+ <IntroductionInfoButton />
+ <SearchBoxPersisted
+ inputClassName="h-9 border-[var(--viewer-control-border)] bg-[var(--viewer-control-bg)] text-[var(--viewer-text)] placeholder:text-[var(--viewer-placeholder)] shadow-sm hover:border-[var(--viewer-control-border-strong)] focus:border-[var(--viewer-control-border-strong)]"
+ leftIconClassName="text-[var(--viewer-control-icon)]"
+ clearIconClassName="text-[var(--viewer-control-icon)] hover:text-[var(--viewer-text)]"
/>
- </button>
- </SheetTrigger>
- <SheetPortal>
- <SheetOverlay className="fixed top-[35dvh] z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0" />
- <SheetPrimitive.Content
- className={cn(
- "fixed top-[35dvh] z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",
- "left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-lg",
- "m-0 w-[280px] p-0 sm:w-[300px] lg:hidden",
+ {enableIndexFile && viewId && viewerId && (
+ <IndexFileDialog
+ linkId={linkId}
+ viewId={viewId}
+ dataroomId={dataroom?.id}
+ viewerId={viewerId}
+ viewerEmail={viewerEmail}
+ triggerClassName={viewerThemedTriggerClass}
+ />
)}
- >
- <div className="mt-8 h-full space-y-8 overflow-auto px-2 py-3">
- <ViewerSurfaceThemeProvider value={mobileTreeTheme}>
- <ViewFolderTree
- folders={folders}
- documents={documents}
- setFolderId={setFolderId}
- folderId={folderId}
- dataroomIndexEnabled={dataroomIndexEnabled}
- />
- </ViewerSurfaceThemeProvider>
- </div>
- <SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary">
- <XIcon className="h-4 w-4" />
- <span className="sr-only">Close</span>
- </SheetPrimitive.Close>
- </SheetPrimitive.Content>
- </SheetPortal>
- </Sheet>
- </div>
- <div className="flex flex-1 items-center justify-between gap-x-2">
- <Breadcrumb>
- <BreadcrumbList className="text-[var(--viewer-muted-text)]">
- <BreadcrumbItem key={"root"}>
- <BreadcrumbLink
- onClick={() => setFolderId(null)}
- className="cursor-pointer text-[var(--viewer-muted-text)] hover:text-[var(--viewer-text)]"
- >
- Home
- </BreadcrumbLink>
- </BreadcrumbItem>
-
- {breadcrumbFolders.map((folder, index) => (
- <React.Fragment key={folder.id}>
- <BreadcrumbSeparator
- className="text-[var(--viewer-subtle-text)]"
+ {viewData?.enableVisitorUpload && viewerId && (
+ <DocumentUploadModal
+ linkId={linkId}
+ dataroomId={dataroom?.id}
+ viewerId={viewerId}
+ folderId={folderId ?? undefined}
+ folderName={
+ folderId
+ ? folders.find((f) => f.id === folderId)?.name
+ : undefined
+ }
+ allowedFolders={viewData?.uploadFolderAllowList}
+ triggerClassName={viewerThemedTriggerClass}
/>
- <BreadcrumbItem>
- <ViewerBreadcrumbItem
- folder={folder}
- setFolderId={setFolderId}
- isLast={index === breadcrumbFolders.length - 1}
- dataroomIndexEnabled={dataroomIndexEnabled}
- />
- </BreadcrumbItem>
- </React.Fragment>
- ))}
- </BreadcrumbList>
- </Breadcrumb>
-
- <div className="flex items-center gap-x-2">
- <IntroductionInfoButton />
- <SearchBoxPersisted
- inputClassName="h-9 border-[var(--viewer-control-border)] bg-[var(--viewer-control-bg)] text-[var(--viewer-text)] placeholder:text-[var(--viewer-placeholder)] shadow-sm hover:border-[var(--viewer-control-border-strong)] focus:border-[var(--viewer-control-border-strong)]"
- leftIconClassName="text-[var(--viewer-control-icon)]"
- clearIconClassName="text-[var(--viewer-control-icon)] hover:text-[var(--viewer-text)]"
- />
- {enableIndexFile && viewId && viewerId && (
- <IndexFileDialog
- linkId={linkId}
- viewId={viewId}
- dataroomId={dataroom?.id}
- viewerId={viewerId}
- viewerEmail={viewerEmail}
- />
- )}
-
- {viewData?.enableVisitorUpload && viewerId && (
- <DocumentUploadModal
- linkId={linkId}
- dataroomId={dataroom?.id}
- viewerId={viewerId}
- folderId={folderId ?? undefined}
- folderName={
- folderId
- ? folders.find((f) => f.id === folderId)?.name
- : undefined
- }
- allowedFolders={viewData?.uploadFolderAllowList}
- />
- )}
+ )}
+ {isNotionLayout ? (
+ <DataroomTrailingActions
+ variant="onLight"
+ isTeamMember={viewData?.isTeamMember}
+ brand={{
+ ctaLabel: (brand as any)?.ctaLabel ?? null,
+ ctaUrl: (brand as any)?.ctaUrl ?? null,
+ brandColor: brand?.brandColor ?? null,
+ accentButtonColor:
+ (brand as any)?.accentButtonColor ?? null,
+ }}
+ conversationsEnabled={
+ viewData?.conversationsEnabled
+ }
+ allowDownload={allowDownload}
+ allowBulkDownload={allowBulkDownload}
+ viewerEmail={viewerEmail}
+ onToggleConversations={() =>
+ window.dispatchEvent(
+ new CustomEvent(
+ VIEWER_TOGGLE_CONVERSATIONS_EVENT,
+ ),
+ )
+ }
+ onOpenDownload={() => {
+ if (isPreview) return;
+ if (!allowDownload || !allowBulkDownload)
+ return;
+ if (!viewerEmail) return;
+ window.dispatchEvent(
+ new CustomEvent(VIEWER_OPEN_DOWNLOAD_EVENT),
+ );
+ }}
+ />
+ ) : null}
+ </div>
+ </div>
</div>
- </div>
- </div>
+ ) : null}
{/* Tabs: Documents / My Uploads */}
{viewData?.enableVisitorUpload && hasUploads && (
@@ -781,10 +1036,7 @@ export default function DataroomViewer({
{activeTab === "my-uploads" ? (
/* My Uploads tab - show all uploads across all folders */
- <ul
- role="list"
- className="-mx-4 space-y-4 overflow-auto p-4"
- >
+ <ul role="list" className="-mx-4 space-y-4 overflow-auto p-4">
{allUploads.length === 0 ? (
<li className="py-6 text-center text-[var(--viewer-subtle-text)]">
No uploads yet. Upload documents using the &quot;Add
@@ -807,40 +1059,117 @@ export default function DataroomViewer({
))
)}
</ul>
- ) : (
- /* Documents tab - normal folder view */
- <ul
- role="list"
- className="-mx-4 space-y-4 overflow-auto p-4"
- >
+ ) : cardLayout === "GRID" ? (
+ <div className="-mx-4 space-y-4 overflow-auto p-4">
{!searchQuery &&
filteredPendingUploads.map((pendingUpload) => (
- <li key={pendingUpload.id}>
+ <div key={pendingUpload.id}>
<PendingDocumentCard
pendingUpload={pendingUpload}
linkId={linkId}
/>
- </li>
+ </div>
))}
{mixedItems.length === 0 &&
filteredPendingUploads.length === 0 ? (
- <li className="py-6 text-center text-[var(--viewer-subtle-text)]">
+ <div className="py-6 text-center text-[var(--viewer-subtle-text)]">
{searchQuery
? "No documents match your search."
: "No items available."}
- </li>
+ </div>
) : (
- mixedItems.map((item) => (
- <li key={item.id}>{renderItem(item)}</li>
+ segmentMixedItemsForGrid(mixedItems).map((run, runIdx) => (
+ <ul
+ key={runIdx}
+ role="list"
+ className={
+ run.kind === "folder"
+ ? folderGridListClassName
+ : documentGridListClassName
+ }
+ >
+ {run.items.map((item) => (
+ <li key={item.id}>{renderItem(item)}</li>
+ ))}
+ </ul>
))
)}
- </ul>
+ </div>
+ ) : (
+ /* Documents tab — list / compact layouts */
+ <div
+ className={cn(
+ cardLayout === "COMPACT" &&
+ "mt-4 border-t border-[var(--viewer-panel-border)]",
+ )}
+ >
+ {cardLayout === "COMPACT" ? (
+ <CompactDataroomListHeader
+ showUpdatedColumn={compactTableShowUpdated}
+ showSettingsColumn={compactListShowsActionsColumn}
+ showIndexColumn
+ />
+ ) : null}
+ <ul role="list" className={itemListClassName}>
+ {!searchQuery &&
+ filteredPendingUploads.map((pendingUpload) => (
+ <li key={pendingUpload.id}>
+ <PendingDocumentCard
+ pendingUpload={pendingUpload}
+ linkId={linkId}
+ />
+ </li>
+ ))}
+
+ {mixedItems.length === 0 &&
+ filteredPendingUploads.length === 0 ? (
+ <li className="py-6 text-center text-[var(--viewer-subtle-text)]">
+ {searchQuery
+ ? "No documents match your search."
+ : "No items available."}
+ </li>
+ ) : (
+ mixedItems.map((item, idx) => (
+ <li key={item.id}>{renderItem(item, idx)}</li>
+ ))
+ )}
+ </ul>
+ </div>
)}
+
+ </div>
+ </div>
+ </div>
+ {showPoweredByBanner ? (
+ <footer className="shrink-0 px-3 md:px-6 lg:px-8 xl:px-14">
+ <div
+ className="border-t py-3"
+ style={{
+ borderColor:
+ viewerSurfaceTheme.palette.panelBorderColor,
+ }}
+ >
+ <div className="flex items-center justify-between gap-4 text-xs text-[var(--viewer-subtle-text)]">
+ <span className="truncate">
+ &copy; {new Date().getFullYear()}
+ {dataroom?.name ? ` ${dataroom.name}` : ""}
+ </span>
+ <a
+ href={`https://www.papermark.com?utm_campaign=poweredby&utm_medium=poweredby&utm_source=papermark-${linkId}`}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="whitespace-nowrap transition-colors hover:text-[var(--viewer-text)]"
+ >
+ Secured by{" "}
+ <span className="font-semibold tracking-tight">
+ Papermark
+ </span>
+ </a>
+ </div>
</div>
- <ScrollBar orientation="vertical" />
- <ScrollBar orientation="horizontal" />
- </ScrollArea>
+ </footer>
+ ) : null}
</div>
</div>
</ViewerChatLayout>
diff --git a/lib/api/links/link-data.ts b/lib/api/links/link-data.ts
index 13923d7b..e237319b 100644
--- a/lib/api/links/link-data.ts
+++ b/lib/api/links/link-data.ts
@@ -11,6 +11,9 @@ import {
import { getFeatureFlags } from "@/lib/featureFlags";
import prisma from "@/lib/prisma";
+import { resolveDataroomIndexEnabledForViewer } from "@/lib/featureFlags/dataroom-index-viewer";
+import { resolvePublicLinkMeta } from "@/ee/features/branding/lib/resolve-public-link-meta";
+import type { ResolvedPublicLinkMeta } from "@/ee/features/branding/lib/resolve-public-link-meta";
import { sortItemsByIndexAndName } from "@/lib/utils/sort-items-by-index-name";
// ============================================================================
@@ -25,6 +28,8 @@ type LinkFetchStatus =
| "free"
| "frozen";
+export type { ResolvedPublicLinkMeta };
+
export type LinkFetchResult =
| {
status: "ok";
@@ -32,7 +37,9 @@ export type LinkFetchResult =
link: any;
brand: Partial<Brand> | Partial<DataroomBrand> | null;
linkId?: string;
- dataroomIndexEnabled?: boolean;
+ publicMeta: ResolvedPublicLinkMeta;
+ /** Server-only resolved flag for dataroom visitor views (not serialized onto link). */
+ dataroomIndexEnabledForViewer?: boolean;
}
| {
status: Exclude<LinkFetchStatus, "ok">;
@@ -309,8 +316,16 @@ export async function fetchDataroomLinkData({
banner: true,
brandColor: true,
accentColor: true,
+ accentButtonColor: true,
applyAccentColorToDataroomView: true,
welcomeMessage: true,
+ cardLayout: true,
+ showFolderTree: true,
+ viewerLayoutPreset: true,
+ viewerHeaderStyle: true,
+ hideFolderIconsInMain: true,
+ ctaLabel: true,
+ ctaUrl: true,
},
});
@@ -321,8 +336,16 @@ export async function fetchDataroomLinkData({
banner: true,
brandColor: true,
accentColor: true,
+ accentButtonColor: true,
applyAccentColorToDataroomView: true,
welcomeMessage: true,
+ ctaLabel: true,
+ ctaUrl: true,
+ cardLayout: true,
+ showFolderTree: true,
+ viewerLayoutPreset: true,
+ viewerHeaderStyle: true,
+ hideFolderIconsInMain: true,
},
});
@@ -331,11 +354,35 @@ export async function fetchDataroomLinkData({
banner: dataroomBrand?.banner || teamBrand?.banner || null,
brandColor: dataroomBrand?.brandColor || teamBrand?.brandColor,
accentColor: dataroomBrand?.accentColor || teamBrand?.accentColor,
+ accentButtonColor:
+ dataroomBrand?.accentButtonColor || teamBrand?.accentButtonColor || null,
applyAccentColorToDataroomView:
dataroomBrand?.applyAccentColorToDataroomView ??
teamBrand?.applyAccentColorToDataroomView ??
false,
welcomeMessage: dataroomBrand?.welcomeMessage || teamBrand?.welcomeMessage,
+ // Layout fields cascade: dataroom override → team default → enum default.
+ // Per-dataroom rows always win once present (matches accentColor pattern).
+ cardLayout:
+ dataroomBrand?.cardLayout ?? (teamBrand as any)?.cardLayout ?? "LIST",
+ showFolderTree:
+ dataroomBrand?.showFolderTree ??
+ (teamBrand as any)?.showFolderTree ??
+ true,
+ viewerLayoutPreset:
+ dataroomBrand?.viewerLayoutPreset ??
+ (teamBrand as any)?.viewerLayoutPreset ??
+ "STANDARD",
+ viewerHeaderStyle:
+ dataroomBrand?.viewerHeaderStyle ??
+ (teamBrand as any)?.viewerHeaderStyle ??
+ "DEFAULT",
+ hideFolderIconsInMain:
+ dataroomBrand?.hideFolderIconsInMain ??
+ (teamBrand as any)?.hideFolderIconsInMain ??
+ false,
+ ctaLabel: dataroomBrand?.ctaLabel ?? teamBrand?.ctaLabel ?? null,
+ ctaUrl: dataroomBrand?.ctaUrl ?? teamBrand?.ctaUrl ?? null,
};
// Extract access controls from either ViewerGroup or PermissionGroup
@@ -468,8 +515,16 @@ export async function fetchDataroomDocumentLinkData({
banner: true,
brandColor: true,
accentColor: true,
+ accentButtonColor: true,
applyAccentColorToDataroomView: true,
welcomeMessage: true,
+ cardLayout: true,
+ showFolderTree: true,
+ viewerLayoutPreset: true,
+ viewerHeaderStyle: true,
+ hideFolderIconsInMain: true,
+ ctaLabel: true,
+ ctaUrl: true,
},
});
@@ -480,8 +535,16 @@ export async function fetchDataroomDocumentLinkData({
banner: true,
brandColor: true,
accentColor: true,
+ accentButtonColor: true,
applyAccentColorToDataroomView: true,
welcomeMessage: true,
+ ctaLabel: true,
+ ctaUrl: true,
+ cardLayout: true,
+ showFolderTree: true,
+ viewerLayoutPreset: true,
+ viewerHeaderStyle: true,
+ hideFolderIconsInMain: true,
},
});
@@ -490,11 +553,33 @@ export async function fetchDataroomDocumentLinkData({
banner: dataroomBrand?.banner || teamBrand?.banner || null,
brandColor: dataroomBrand?.brandColor || teamBrand?.brandColor,
accentColor: dataroomBrand?.accentColor || teamBrand?.accentColor,
+ accentButtonColor:
+ dataroomBrand?.accentButtonColor || teamBrand?.accentButtonColor || null,
applyAccentColorToDataroomView:
dataroomBrand?.applyAccentColorToDataroomView ??
teamBrand?.applyAccentColorToDataroomView ??
false,
welcomeMessage: dataroomBrand?.welcomeMessage || teamBrand?.welcomeMessage,
+ cardLayout:
+ dataroomBrand?.cardLayout ?? (teamBrand as any)?.cardLayout ?? "LIST",
+ showFolderTree:
+ dataroomBrand?.showFolderTree ??
+ (teamBrand as any)?.showFolderTree ??
+ true,
+ viewerLayoutPreset:
+ dataroomBrand?.viewerLayoutPreset ??
+ (teamBrand as any)?.viewerLayoutPreset ??
+ "STANDARD",
+ viewerHeaderStyle:
+ dataroomBrand?.viewerHeaderStyle ??
+ (teamBrand as any)?.viewerHeaderStyle ??
+ "DEFAULT",
+ hideFolderIconsInMain:
+ dataroomBrand?.hideFolderIconsInMain ??
+ (teamBrand as any)?.hideFolderIconsInMain ??
+ false,
+ ctaLabel: dataroomBrand?.ctaLabel ?? teamBrand?.ctaLabel ?? null,
+ ctaUrl: dataroomBrand?.ctaUrl ?? teamBrand?.ctaUrl ?? null,
};
return { linkData, brand };
@@ -613,6 +698,13 @@ async function processLinkData(
brand: serializedBrand,
linkId: link.id,
link: serializedLink,
+ publicMeta: {
+ enableCustomMetatag: false,
+ metaTitle: null,
+ metaDescription: null,
+ metaImage: null,
+ metaFavicon: "/favicon.ico",
+ },
};
}
@@ -748,33 +840,92 @@ async function processLinkData(
dataroomDocument: linkData?.dataroom?.documents?.[0] || undefined,
};
- // Serialize to convert Date objects to strings (required for Next.js getStaticProps)
- const serializedLink = JSON.parse(JSON.stringify(returnLink));
- const serializedBrand = brand ? JSON.parse(JSON.stringify(brand)) : null;
+ let publicMeta: ResolvedPublicLinkMeta = {
+ enableCustomMetatag: false,
+ metaTitle: null,
+ metaDescription: null,
+ metaImage: null,
+ metaFavicon: "/favicon.ico",
+ };
- // Mirrors the rebuild gate in `calculate-indexes.ts`. Computed here
- // because `link.team` is stripped from the payload below.
- let dataroomIndexEnabled: boolean | undefined;
- if (linkType === "DATAROOM_LINK" && link.teamId) {
- const hasDataroomsPlusPlan =
- teamPlan === "datarooms-plus" ||
- teamPlan === "datarooms-plus+old" ||
- teamPlan === "datarooms-premium" ||
- teamPlan === "datarooms-unlimited";
- if (hasDataroomsPlusPlan) {
- dataroomIndexEnabled = true;
- } else {
- const featureFlags = await getFeatureFlags({ teamId: link.teamId });
- dataroomIndexEnabled = featureFlags.dataroomIndex;
+ if (
+ link.teamId &&
+ (linkType === "DOCUMENT_LINK" || linkType === "DATAROOM_LINK")
+ ) {
+ const [teamBrandLp, dataroomBrandLp] = await Promise.all([
+ prisma.brand.findFirst({
+ where: { teamId: link.teamId },
+ select: {
+ customLinkPreviewEnabled: true,
+ linkPreviewTitle: true,
+ linkPreviewDescription: true,
+ linkPreviewImage: true,
+ linkPreviewFavicon: true,
+ },
+ }),
+ linkType === "DATAROOM_LINK" && link.dataroomId
+ ? prisma.dataroomBrand.findFirst({
+ where: { dataroomId: link.dataroomId },
+ select: {
+ customLinkPreviewEnabled: true,
+ linkPreviewTitle: true,
+ linkPreviewDescription: true,
+ linkPreviewImage: true,
+ linkPreviewFavicon: true,
+ },
+ })
+ : Promise.resolve(null),
+ ]);
+
+ let defaultTitle = "Shared link | Powered by Papermark";
+ if (linkType === "DOCUMENT_LINK" && linkData?.document?.name) {
+ defaultTitle = `${linkData.document.name} | Powered by Papermark`;
+ } else if (linkType === "DATAROOM_LINK") {
+ const docName =
+ linkData?.dataroom?.documents?.[0]?.document?.name ?? null;
+ if (docName) {
+ defaultTitle = `${docName} | Powered by Papermark`;
+ } else if (linkData?.dataroom?.name) {
+ defaultTitle = `${linkData.dataroom.name} | Powered by Papermark`;
+ }
}
+
+ publicMeta = resolvePublicLinkMeta({
+ link: {
+ enableCustomMetatag: !!link.enableCustomMetatag,
+ metaTitle: link.metaTitle,
+ metaDescription: link.metaDescription,
+ metaImage: link.metaImage,
+ metaFavicon: link.metaFavicon,
+ },
+ teamBrand: teamBrandLp,
+ dataroomBrand: dataroomBrandLp,
+ defaultTitle,
+ });
+ }
+
+ let dataroomIndexEnabledForViewer: boolean | undefined;
+ if (linkType === "DATAROOM_LINK" && link.teamId) {
+ dataroomIndexEnabledForViewer =
+ await resolveDataroomIndexEnabledForViewer({
+ teamId: link.teamId,
+ teamPlan,
+ });
}
+ // Serialize to convert Date objects to strings (required for Next.js getStaticProps)
+ const serializedLink = JSON.parse(JSON.stringify(returnLink));
+ const serializedBrand = brand ? JSON.parse(JSON.stringify(brand)) : null;
+
return {
status: "ok",
linkType,
link: serializedLink,
brand: serializedBrand,
- dataroomIndexEnabled,
+ publicMeta: JSON.parse(JSON.stringify(publicMeta)),
+ ...(dataroomIndexEnabledForViewer !== undefined && {
+ dataroomIndexEnabledForViewer,
+ }),
};
}
diff --git a/lib/billing/team-plan-custom-messaging.ts b/lib/billing/team-plan-custom-messaging.ts
new file mode 100644
index 00000000..548eaa3f
--- /dev/null
+++ b/lib/billing/team-plan-custom-messaging.ts
@@ -0,0 +1,73 @@
+/**
+ * Custom welcome message + CTA (team & dataroom branding) require Business or
+ * Data Rooms plans. Trial teams that include drtrial may use these features.
+ */
+export function teamPlanAllowsCustomWelcomeAndCta(
+ plan: string | null | undefined,
+): boolean {
+ if (!plan || plan === "free") return false;
+ if (plan.includes("drtrial")) return true;
+ const base = plan.split("+")[0];
+ return (
+ base === "business" ||
+ base === "datarooms" ||
+ base === "datarooms-plus" ||
+ base === "datarooms-premium" ||
+ base === "datarooms-unlimited"
+ );
+}
+
+/** Matches client `usePlan().isDataroomsPlus` (base segment before +drtrial / +old / etc.). */
+export function teamPlanIsDataroomPlusTier(
+ plan: string | null | undefined,
+): boolean {
+ if (!plan || plan === "free") return false;
+ const base = plan.split("+")[0];
+ return (
+ base === "datarooms-plus" ||
+ base === "datarooms-premium" ||
+ base === "datarooms-unlimited"
+ );
+}
+
+/**
+ * Saving custom dataroom *layout* settings (preset, folder tree, card layout,
+ * header style, …) is gated to the Data Rooms tier or active dataroom trials.
+ *
+ * Visibility (whether the Layouts UI even renders) is a looser check —
+ * Business plans see and configure the controls, but the Save action triggers
+ * the upgrade modal until the team is on a Data Rooms plan.
+ */
+export function teamPlanAllowsLayoutCustomization(
+ plan: string | null | undefined,
+): boolean {
+ if (!plan || plan === "free") return false;
+ if (plan.includes("drtrial")) return true;
+ const base = plan.split("+")[0];
+ return (
+ base === "datarooms" ||
+ base === "datarooms-plus" ||
+ base === "datarooms-premium" ||
+ base === "datarooms-unlimited"
+ );
+}
+
+/**
+ * Whether the Layouts UI should be rendered at all in the global branding /
+ * dataroom branding screens. Free plans have no exposure to it; Business and
+ * higher (or any dataroom trial) can see and tweak the controls.
+ */
+export function teamPlanShowsLayoutUi(
+ plan: string | null | undefined,
+): boolean {
+ if (!plan || plan === "free") return false;
+ if (plan.includes("drtrial")) return true;
+ const base = plan.split("+")[0];
+ return (
+ base === "business" ||
+ base === "datarooms" ||
+ base === "datarooms-plus" ||
+ base === "datarooms-premium" ||
+ base === "datarooms-unlimited"
+ );
+}
diff --git a/lib/featureFlags/dataroom-index-viewer.ts b/lib/featureFlags/dataroom-index-viewer.ts
new file mode 100644
index 00000000..1e8e57b4
--- /dev/null
+++ b/lib/featureFlags/dataroom-index-viewer.ts
@@ -0,0 +1,18 @@
+import { teamPlanIsDataroomPlusTier } from "@/lib/billing/team-plan-custom-messaging";
+
+import { getFeatureFlags } from "@/lib/featureFlags";
+
+/**
+ * Visitor-facing hierarchical numbering (prefixes in breadcrumb, cards, tree).
+ * Matches rebuild-index eligibility: Edge Config `dataroomIndex` OR Plus-tier plan.
+ */
+export async function resolveDataroomIndexEnabledForViewer(opts: {
+ teamId: string | null | undefined;
+ teamPlan: string | null | undefined;
+}): Promise<boolean> {
+ const flags = await getFeatureFlags({ teamId: opts.teamId || undefined });
+ return Boolean(
+ flags.dataroomIndex ||
+ teamPlanIsDataroomPlusTier(opts.teamPlan ?? undefined),
+ );
+}
diff --git a/lib/featureFlags/index.ts b/lib/featureFlags/index.ts
index 5e51526f..ce9232ac 100644
--- a/lib/featureFlags/index.ts
+++ b/lib/featureFlags/index.ts
@@ -54,7 +54,15 @@ export const getFeatureFlags = async ({ teamId }: { teamId?: string }) => {
try {
betaFeatures = await get("betaFeatures");
} catch (e) {
- console.error(`Error getting beta features: ${e}`);
+ const msg = e instanceof Error ? e.message : String(e);
+ // Invalid or local EDGE_CONFIG tokens surface as Unauthorized; flags stay off.
+ if (msg.includes("Unauthorized") || msg.includes("403")) {
+ console.warn(
+ "[featureFlags] Edge Config unavailable; beta flags default to off. Fix EDGE_CONFIG or unset it for local dev.",
+ );
+ } else {
+ console.error(`Error getting beta features: ${e}`);
+ }
}
if (betaFeatures) {
diff --git a/lib/utils/hierarchical-display.ts b/lib/utils/hierarchical-display.ts
index 616cf700..d1860739 100644
--- a/lib/utils/hierarchical-display.ts
+++ b/lib/utils/hierarchical-display.ts
@@ -1,19 +1,25 @@
import { useFeatureFlags } from "@/lib/hooks/use-feature-flags";
import { usePlan } from "@/lib/swr/use-billing";
-export function useDataroomIndexEnabled(): boolean {
+/**
+ * Admin-side gate for showing hierarchical index prefixes.
+ * Mirrors the viewer rule in `lib/featureFlags/dataroom-index-viewer.ts` and
+ * the API gate in `pages/api/teams/[teamId]/datarooms/[id]/calculate-indexes.ts`:
+ * Edge Config `dataroomIndex` flag OR Datarooms-Plus tier (incl. premium/unlimited).
+ */
+export function useDataroomIndexDisplayEnabled(): boolean {
const { isFeatureEnabled } = useFeatureFlags();
const { isDataroomsPlus } = usePlan();
- return isDataroomsPlus || isFeatureEnabled("dataroomIndex");
+ return isFeatureEnabled("dataroomIndex") || isDataroomsPlus;
}
export function useHierarchicalDisplayName(
name: string,
hierarchicalIndex?: string | null,
): string {
- const isEnabled = useDataroomIndexEnabled();
+ const enabled = useDataroomIndexDisplayEnabled();
- if (isEnabled && hierarchicalIndex) {
+ if (enabled && hierarchicalIndex) {
return `${hierarchicalIndex} ${name}`;
}
diff --git a/pages/api/teams/[teamId]/branding.ts b/pages/api/teams/[teamId]/branding.ts
index 46cf3920..24ab838a 100644
--- a/pages/api/teams/[teamId]/branding.ts
+++ b/pages/api/teams/[teamId]/branding.ts
@@ -2,7 +2,21 @@ import { NextApiRequest, NextApiResponse } from "next";
import { del } from "@vercel/blob";
import { getServerSession } from "next-auth";
+import { z } from "zod";
+import {
+ DataroomCardLayoutSchema,
+ DataroomViewerHeaderStyleSchema,
+ DataroomViewerLayoutPresetSchema,
+ type DataroomCardLayout,
+ type DataroomViewerHeaderStyle,
+ type DataroomViewerLayoutPreset,
+} from "@/ee/features/branding/lib/dataroom-viewer-layout";
+import {
+ teamPlanAllowsCustomWelcomeAndCta,
+ teamPlanAllowsLayoutCustomization,
+} from "@/lib/billing/team-plan-custom-messaging";
+import { validateRedirectUrl } from "@/lib/api/domains/validate-redirect-url";
import { errorhandler } from "@/lib/errorHandler";
import prisma from "@/lib/prisma";
import { redis } from "@/lib/redis";
@@ -10,6 +24,78 @@ import { CustomUser } from "@/lib/types";
import { authOptions } from "../../auth/[...nextauth]";
+const updateBrandingSchema = z.object({
+ logo: z.string().nullable().optional(),
+ banner: z.string().nullable().optional(),
+ brandColor: z.string().nullable().optional(),
+ accentColor: z.string().nullable().optional(),
+ accentButtonColor: z.string().nullable().optional(),
+ applyAccentColorToDataroomView: z.boolean().optional(),
+ welcomeMessage: z.string().nullable().optional(),
+ customLinkPreviewEnabled: z.boolean().optional(),
+ linkPreviewTitle: z.string().nullable().optional(),
+ linkPreviewDescription: z.string().nullable().optional(),
+ linkPreviewImage: z.string().nullable().optional(),
+ linkPreviewFavicon: z.string().nullable().optional(),
+ ctaLabel: z.string().nullable().optional(),
+ ctaUrl: z.string().nullable().optional(),
+ cardLayout: DataroomCardLayoutSchema.optional(),
+ showFolderTree: z.boolean().optional(),
+ viewerLayoutPreset: DataroomViewerLayoutPresetSchema.optional(),
+ viewerHeaderStyle: DataroomViewerHeaderStyleSchema.optional(),
+ hideFolderIconsInMain: z.boolean().optional(),
+});
+
+type LayoutPayload = {
+ cardLayout?: DataroomCardLayout;
+ showFolderTree?: boolean;
+ viewerLayoutPreset?: DataroomViewerLayoutPreset;
+ viewerHeaderStyle?: DataroomViewerHeaderStyle;
+ hideFolderIconsInMain?: boolean;
+};
+
+/**
+ * Re-validate the layout payload at the persistence boundary. The route-level
+ * Zod parse already rejects unknown values, but we re-narrow here because
+ * `sanitizeLayoutPayload` is the single sink that writes layout fields and we
+ * want a defense-in-depth guard against future callers that bypass the
+ * top-level schema.
+ */
+function sanitizeLayoutPayload(input: LayoutPayload): LayoutPayload {
+ const out: LayoutPayload = {};
+ if (
+ input.cardLayout &&
+ DataroomCardLayoutSchema.safeParse(input.cardLayout).success
+ ) {
+ out.cardLayout = input.cardLayout;
+ }
+ if (typeof input.showFolderTree === "boolean") {
+ out.showFolderTree = input.showFolderTree;
+ }
+ if (
+ input.viewerLayoutPreset &&
+ DataroomViewerLayoutPresetSchema.safeParse(input.viewerLayoutPreset).success
+ ) {
+ out.viewerLayoutPreset = input.viewerLayoutPreset;
+ }
+ if (
+ input.viewerHeaderStyle &&
+ DataroomViewerHeaderStyleSchema.safeParse(input.viewerHeaderStyle).success
+ ) {
+ out.viewerHeaderStyle = input.viewerHeaderStyle;
+ }
+ if (typeof input.hideFolderIconsInMain === "boolean") {
+ out.hideFolderIconsInMain = input.hideFolderIconsInMain;
+ }
+ return out;
+}
+
+function maybeDeleteBlobAsset(url: string | null | undefined): Promise<void> {
+ if (!url || url === "no-banner") return Promise.resolve();
+ if (url.startsWith("/") || url.startsWith("data:")) return Promise.resolve();
+ return del(url).catch(() => {});
+}
+
export default async function handle(
req: NextApiRequest,
res: NextApiResponse,
@@ -59,86 +145,244 @@ export default async function handle(
return res.status(200).json(brand);
} else if (req.method === "POST") {
// POST /api/teams/:teamId/branding
- const {
- logo,
- banner,
- brandColor,
- accentColor,
- applyAccentColorToDataroomView,
- welcomeMessage,
- } = req.body as {
- logo?: string;
- banner?: string;
- brandColor?: string;
- accentColor?: string;
- applyAccentColorToDataroomView?: boolean;
- welcomeMessage?: string;
- };
-
- // update team with new branding
- const brand = await prisma.brand.create({
- data: {
- logo: logo,
- banner,
- brandColor,
- accentColor,
- applyAccentColorToDataroomView: !!applyAccentColorToDataroomView,
- welcomeMessage,
+ const teamAuth = await prisma.team.findFirst({
+ where: {
+ id: teamId,
+ users: {
+ some: { userId: (session.user as CustomUser).id },
+ },
+ },
+ select: { plan: true },
+ });
+ if (!teamAuth) {
+ return res.status(403).end("Unauthorized to access this team");
+ }
+ const messagingAllowed = teamPlanAllowsCustomWelcomeAndCta(teamAuth.plan);
+ const layoutAllowed = teamPlanAllowsLayoutCustomization(teamAuth.plan);
+
+ const parsed = updateBrandingSchema.safeParse(req.body);
+ if (!parsed.success) {
+ return res.status(400).json({
+ message: "Invalid request body",
+ errors: parsed.error.flatten().fieldErrors,
+ });
+ }
+ const body = parsed.data;
+
+ const layoutData = layoutAllowed
+ ? sanitizeLayoutPayload({
+ cardLayout: body.cardLayout,
+ showFolderTree: body.showFolderTree,
+ viewerLayoutPreset: body.viewerLayoutPreset,
+ viewerHeaderStyle: body.viewerHeaderStyle,
+ hideFolderIconsInMain: body.hideFolderIconsInMain,
+ })
+ : {};
+
+ // Run the CTA URL through the shared validator (HTTPS, SSRF guard,
+ // Edge Config keyword blocklist with trusted-team bypass). Only run
+ // when the plan permits messaging, since otherwise the value is
+ // ignored at the persistence step anyway.
+ let validatedCtaUrl: string | null | undefined = body.ctaUrl;
+ if (messagingAllowed && typeof body.ctaUrl === "string") {
+ const ctaValidation = await validateRedirectUrl(body.ctaUrl, teamId);
+ if (!ctaValidation.valid) {
+ return res.status(400).json({ message: ctaValidation.message });
+ }
+ validatedCtaUrl = ctaValidation.url;
+ }
+
+ // Use upsert so POST is idempotent: clients can hit POST even when a
+ // Brand row already exists (e.g. SWR cache is stale and `brand` is
+ // falsy on the client) without tripping the unique-teamId constraint.
+ const brand = await prisma.brand.upsert({
+ where: { teamId },
+ create: {
+ logo: body.logo,
+ banner: body.banner,
+ brandColor: body.brandColor,
+ accentColor: body.accentColor,
+ accentButtonColor: body.accentButtonColor ?? undefined,
+ applyAccentColorToDataroomView:
+ body.applyAccentColorToDataroomView ?? false,
+ welcomeMessage: messagingAllowed ? body.welcomeMessage ?? null : null,
+ customLinkPreviewEnabled: messagingAllowed
+ ? body.customLinkPreviewEnabled ?? false
+ : false,
+ linkPreviewTitle: messagingAllowed
+ ? body.linkPreviewTitle ?? undefined
+ : undefined,
+ linkPreviewDescription: messagingAllowed
+ ? body.linkPreviewDescription ?? undefined
+ : undefined,
+ linkPreviewImage: messagingAllowed
+ ? body.linkPreviewImage ?? undefined
+ : undefined,
+ linkPreviewFavicon: messagingAllowed
+ ? body.linkPreviewFavicon ?? undefined
+ : undefined,
+ ctaLabel: messagingAllowed ? body.ctaLabel ?? undefined : undefined,
+ ctaUrl: messagingAllowed ? validatedCtaUrl ?? undefined : undefined,
+ ...layoutData,
teamId: teamId,
},
+ update: {
+ logo: body.logo,
+ banner: body.banner,
+ brandColor: body.brandColor,
+ accentColor: body.accentColor,
+ accentButtonColor: body.accentButtonColor ?? null,
+ applyAccentColorToDataroomView:
+ body.applyAccentColorToDataroomView ?? false,
+ welcomeMessage: messagingAllowed ? body.welcomeMessage ?? null : undefined,
+ customLinkPreviewEnabled: messagingAllowed
+ ? body.customLinkPreviewEnabled
+ : undefined,
+ linkPreviewTitle: messagingAllowed ? body.linkPreviewTitle : undefined,
+ linkPreviewDescription: messagingAllowed
+ ? body.linkPreviewDescription
+ : undefined,
+ linkPreviewImage: messagingAllowed ? body.linkPreviewImage : undefined,
+ linkPreviewFavicon: messagingAllowed
+ ? body.linkPreviewFavicon
+ : undefined,
+ ctaLabel: messagingAllowed ? body.ctaLabel : undefined,
+ ctaUrl: messagingAllowed ? validatedCtaUrl : undefined,
+ ...layoutData,
+ },
});
- // Cache the logo URL in Redis if logo exists
- if (logo) {
- await redis.set(`brand:logo:${teamId}`, logo);
+ if (body.logo) {
+ await redis.set(`brand:logo:${teamId}`, body.logo);
+ } else if (body.logo === null) {
+ await redis.del(`brand:logo:${teamId}`);
}
return res.status(200).json(brand);
} else if (req.method === "PUT") {
// PUT /api/teams/:teamId/branding
- const {
- logo,
- banner,
- brandColor,
- accentColor,
- applyAccentColorToDataroomView,
- welcomeMessage,
- } = req.body as {
- logo?: string;
- banner?: string;
- brandColor?: string;
- accentColor?: string;
- applyAccentColorToDataroomView?: boolean;
- welcomeMessage?: string;
- };
-
- // Use upsert to handle both create and update cases
+ const teamAuth = await prisma.team.findFirst({
+ where: {
+ id: teamId,
+ users: {
+ some: { userId: (session.user as CustomUser).id },
+ },
+ },
+ select: { plan: true },
+ });
+ if (!teamAuth) {
+ return res.status(403).end("Unauthorized to access this team");
+ }
+ const messagingAllowed = teamPlanAllowsCustomWelcomeAndCta(teamAuth.plan);
+ const layoutAllowed = teamPlanAllowsLayoutCustomization(teamAuth.plan);
+
+ const parsed = updateBrandingSchema.safeParse(req.body);
+ if (!parsed.success) {
+ return res.status(400).json({
+ message: "Invalid request body",
+ errors: parsed.error.flatten().fieldErrors,
+ });
+ }
+ const body = parsed.data;
+
+ const existingBrand = await prisma.brand.findUnique({
+ where: { teamId },
+ });
+
+ let validatedCtaUrl: string | null | undefined = body.ctaUrl;
+ if (messagingAllowed && typeof body.ctaUrl === "string") {
+ const ctaValidation = await validateRedirectUrl(body.ctaUrl, teamId);
+ if (!ctaValidation.valid) {
+ return res.status(400).json({ message: ctaValidation.message });
+ }
+ validatedCtaUrl = ctaValidation.url;
+ }
+
+ const resolvedWelcome = messagingAllowed
+ ? body.welcomeMessage ?? null
+ : (existingBrand?.welcomeMessage ?? null);
+ const resolvedCtaLabel = messagingAllowed
+ ? body.ctaLabel ?? null
+ : (existingBrand?.ctaLabel ?? null);
+ const resolvedCtaUrl = messagingAllowed
+ ? validatedCtaUrl ?? null
+ : (existingBrand?.ctaUrl ?? null);
+
+ const layoutData = layoutAllowed
+ ? sanitizeLayoutPayload({
+ cardLayout: body.cardLayout,
+ showFolderTree: body.showFolderTree,
+ viewerLayoutPreset: body.viewerLayoutPreset,
+ viewerHeaderStyle: body.viewerHeaderStyle,
+ hideFolderIconsInMain: body.hideFolderIconsInMain,
+ })
+ : {};
+
const brand = await prisma.brand.upsert({
where: {
teamId: teamId,
},
create: {
- logo,
- banner,
- brandColor,
- accentColor,
- applyAccentColorToDataroomView: !!applyAccentColorToDataroomView,
- welcomeMessage,
+ logo: body.logo,
+ banner: body.banner,
+ brandColor: body.brandColor,
+ accentColor: body.accentColor,
+ accentButtonColor: body.accentButtonColor ?? undefined,
+ applyAccentColorToDataroomView: !!body.applyAccentColorToDataroomView,
+ welcomeMessage: messagingAllowed ? body.welcomeMessage ?? null : null,
+ customLinkPreviewEnabled: messagingAllowed
+ ? !!body.customLinkPreviewEnabled
+ : false,
+ linkPreviewTitle: messagingAllowed
+ ? body.linkPreviewTitle ?? undefined
+ : undefined,
+ linkPreviewDescription: messagingAllowed
+ ? body.linkPreviewDescription ?? undefined
+ : undefined,
+ linkPreviewImage: messagingAllowed
+ ? body.linkPreviewImage ?? undefined
+ : undefined,
+ linkPreviewFavicon: messagingAllowed
+ ? body.linkPreviewFavicon ?? undefined
+ : undefined,
+ ctaLabel: messagingAllowed ? body.ctaLabel ?? undefined : undefined,
+ ctaUrl: messagingAllowed ? validatedCtaUrl ?? undefined : undefined,
+ ...layoutData,
teamId: teamId,
},
update: {
- logo,
- banner,
- brandColor,
- accentColor,
- applyAccentColorToDataroomView: !!applyAccentColorToDataroomView,
- welcomeMessage,
+ logo: body.logo,
+ banner: body.banner,
+ brandColor: body.brandColor,
+ accentColor: body.accentColor,
+ accentButtonColor: body.accentButtonColor ?? null,
+ applyAccentColorToDataroomView: !!body.applyAccentColorToDataroomView,
+ welcomeMessage: resolvedWelcome,
+ // Preserve stored link-preview settings on partial PUTs: only write
+ // these fields when they're explicitly present in the payload.
+ // Prisma skips updates for `undefined` values. Plans without messaging
+ // access cannot mutate any link-preview fields, so the stored value
+ // is preserved as-is.
+ customLinkPreviewEnabled: messagingAllowed
+ ? body.customLinkPreviewEnabled
+ : undefined,
+ linkPreviewTitle: messagingAllowed ? body.linkPreviewTitle : undefined,
+ linkPreviewDescription: messagingAllowed
+ ? body.linkPreviewDescription
+ : undefined,
+ linkPreviewImage: messagingAllowed ? body.linkPreviewImage : undefined,
+ linkPreviewFavicon: messagingAllowed
+ ? body.linkPreviewFavicon
+ : undefined,
+ ctaLabel: resolvedCtaLabel,
+ ctaUrl: resolvedCtaUrl,
+ ...layoutData,
},
});
// Update logo in Redis cache
- if (logo) {
- await redis.set(`brand:logo:${teamId}`, logo);
+ if (body.logo) {
+ await redis.set(`brand:logo:${teamId}`, body.logo);
} else {
// If logo is null or undefined, delete the cache
await redis.del(`brand:logo:${teamId}`);
@@ -151,25 +395,20 @@ export default async function handle(
where: {
teamId: teamId,
},
- select: { id: true, logo: true, banner: true },
+ select: { id: true, logo: true, banner: true, linkPreviewImage: true, linkPreviewFavicon: true },
});
if (brand) {
- // delete the logo from vercel blob
- if (brand.logo) {
- await del(brand.logo);
- }
- // delete the banner from vercel blob
- if (brand.banner) {
- await del(brand.banner);
- }
+ await Promise.all([
+ maybeDeleteBlobAsset(brand.logo),
+ maybeDeleteBlobAsset(brand.banner),
+ maybeDeleteBlobAsset((brand as any).linkPreviewImage),
+ maybeDeleteBlobAsset((brand as any).linkPreviewFavicon),
+ ]);
}
- // delete the branding from database
- await prisma.brand.delete({
- where: {
- id: brand?.id,
- },
+ await prisma.brand.deleteMany({
+ where: { teamId },
});
// Remove logo from Redis cache
diff --git a/pages/api/teams/[teamId]/datarooms/[id]/branding.ts b/pages/api/teams/[teamId]/datarooms/[id]/branding.ts
index ef6962bd..cf328f9b 100644
--- a/pages/api/teams/[teamId]/datarooms/[id]/branding.ts
+++ b/pages/api/teams/[teamId]/datarooms/[id]/branding.ts
@@ -3,11 +3,97 @@ import { NextApiRequest, NextApiResponse } from "next";
import { authOptions } from "@/pages/api/auth/[...nextauth]";
import { del } from "@vercel/blob";
import { getServerSession } from "next-auth";
+import { z } from "zod";
+import {
+ DataroomCardLayoutSchema,
+ DataroomViewerHeaderStyleSchema,
+ DataroomViewerLayoutPresetSchema,
+ type DataroomCardLayout,
+ type DataroomViewerHeaderStyle,
+ type DataroomViewerLayoutPreset,
+} from "@/ee/features/branding/lib/dataroom-viewer-layout";
+import { validateRedirectUrl } from "@/lib/api/domains/validate-redirect-url";
+import {
+ teamPlanAllowsCustomWelcomeAndCta,
+ teamPlanAllowsLayoutCustomization,
+} from "@/lib/billing/team-plan-custom-messaging";
import { errorhandler } from "@/lib/errorHandler";
import prisma from "@/lib/prisma";
import { CustomUser } from "@/lib/types";
+const updateDataroomBrandingSchema = z.object({
+ logo: z.string().nullable().optional(),
+ banner: z.string().nullable().optional(),
+ brandColor: z.string().nullable().optional(),
+ accentColor: z.string().nullable().optional(),
+ accentButtonColor: z.string().nullable().optional(),
+ applyAccentColorToDataroomView: z.boolean().optional(),
+ welcomeMessage: z.string().nullable().optional(),
+ ctaLabel: z.string().nullable().optional(),
+ ctaUrl: z.string().nullable().optional(),
+ customLinkPreviewEnabled: z.boolean().optional(),
+ linkPreviewTitle: z.string().nullable().optional(),
+ linkPreviewDescription: z.string().nullable().optional(),
+ linkPreviewImage: z.string().nullable().optional(),
+ linkPreviewFavicon: z.string().nullable().optional(),
+ cardLayout: DataroomCardLayoutSchema.optional(),
+ showFolderTree: z.boolean().optional(),
+ viewerLayoutPreset: DataroomViewerLayoutPresetSchema.optional(),
+ viewerHeaderStyle: DataroomViewerHeaderStyleSchema.optional(),
+ hideFolderIconsInMain: z.boolean().optional(),
+});
+
+type LayoutFields = {
+ cardLayout?: DataroomCardLayout;
+ showFolderTree?: boolean;
+ viewerLayoutPreset?: DataroomViewerLayoutPreset;
+ viewerHeaderStyle?: DataroomViewerHeaderStyle;
+ hideFolderIconsInMain?: boolean;
+};
+
+/**
+ * Strip any layout fields whose value is missing or not in the allow-list.
+ * Mirrors the team-level branding API so dataroom branding cannot be used to
+ * bypass plan gating from the UI by hand-crafting an API request. Allowed
+ * values are sourced from `ee/features/branding/lib/dataroom-viewer-layout`.
+ */
+function sanitizeLayoutPayload(input: LayoutFields): LayoutFields {
+ const out: LayoutFields = {};
+ if (
+ input.cardLayout &&
+ DataroomCardLayoutSchema.safeParse(input.cardLayout).success
+ ) {
+ out.cardLayout = input.cardLayout;
+ }
+ if (typeof input.showFolderTree === "boolean") {
+ out.showFolderTree = input.showFolderTree;
+ }
+ if (
+ input.viewerLayoutPreset &&
+ DataroomViewerLayoutPresetSchema.safeParse(input.viewerLayoutPreset).success
+ ) {
+ out.viewerLayoutPreset = input.viewerLayoutPreset;
+ }
+ if (
+ input.viewerHeaderStyle &&
+ DataroomViewerHeaderStyleSchema.safeParse(input.viewerHeaderStyle).success
+ ) {
+ out.viewerHeaderStyle = input.viewerHeaderStyle;
+ }
+ if (typeof input.hideFolderIconsInMain === "boolean") {
+ out.hideFolderIconsInMain = input.hideFolderIconsInMain;
+ }
+ return out;
+}
+
+/** Vercel Blob `del` only accepts URLs we uploaded there; skip sentinels & local paths */
+function maybeDeleteBlobAsset(url: string | null | undefined): Promise<void> {
+ if (!url || url === "no-banner") return Promise.resolve();
+ if (url.startsWith("/") || url.startsWith("data:")) return Promise.resolve();
+ return del(url).catch(() => {});
+}
+
export default async function handle(
req: NextApiRequest,
res: NextApiResponse,
@@ -70,31 +156,78 @@ export default async function handle(
return res.status(200).json(brand);
} else if (req.method === "POST") {
// POST /api/teams/:teamId/datarooms/:id/branding
- const {
- logo,
- banner,
- brandColor,
- accentColor,
- applyAccentColorToDataroomView,
- welcomeMessage,
- } = req.body as {
- logo?: string;
- banner?: string;
- brandColor?: string;
- accentColor?: string;
- applyAccentColorToDataroomView?: boolean;
- welcomeMessage?: string;
- };
-
- // update team with new branding
+ const teamAuth = await prisma.team.findFirst({
+ where: {
+ id: teamId,
+ users: { some: { userId: (session.user as CustomUser).id } },
+ },
+ select: { plan: true },
+ });
+ if (!teamAuth) {
+ return res.status(403).end("Unauthorized to access this team");
+ }
+ const messagingAllowed = teamPlanAllowsCustomWelcomeAndCta(teamAuth.plan);
+ const layoutAllowed = teamPlanAllowsLayoutCustomization(teamAuth.plan);
+
+ const parsed = updateDataroomBrandingSchema.safeParse(req.body);
+ if (!parsed.success) {
+ return res.status(400).json({
+ message: "Invalid request body",
+ errors: parsed.error.flatten().fieldErrors,
+ });
+ }
+ const body = parsed.data;
+
+ const layoutData = layoutAllowed
+ ? sanitizeLayoutPayload({
+ cardLayout: body.cardLayout,
+ showFolderTree: body.showFolderTree,
+ viewerLayoutPreset: body.viewerLayoutPreset,
+ viewerHeaderStyle: body.viewerHeaderStyle,
+ hideFolderIconsInMain: body.hideFolderIconsInMain,
+ })
+ : {};
+
+ let validatedCtaUrl: string | null | undefined = body.ctaUrl;
+ if (messagingAllowed && typeof body.ctaUrl === "string") {
+ const ctaValidation = await validateRedirectUrl(body.ctaUrl, teamId);
+ if (!ctaValidation.valid) {
+ return res.status(400).json({ message: ctaValidation.message });
+ }
+ validatedCtaUrl = ctaValidation.url;
+ }
+
const brand = await prisma.dataroomBrand.create({
data: {
- logo,
- banner,
- brandColor,
- accentColor,
- applyAccentColorToDataroomView: !!applyAccentColorToDataroomView,
- welcomeMessage,
+ logo: body.logo ?? undefined,
+ banner: body.banner ?? undefined,
+ brandColor: body.brandColor ?? undefined,
+ accentColor: body.accentColor ?? undefined,
+ accentButtonColor: body.accentButtonColor ?? undefined,
+ applyAccentColorToDataroomView:
+ typeof body.applyAccentColorToDataroomView === "boolean"
+ ? body.applyAccentColorToDataroomView
+ : undefined,
+ welcomeMessage: messagingAllowed ? body.welcomeMessage : null,
+ ctaLabel: messagingAllowed ? body.ctaLabel ?? undefined : undefined,
+ ctaUrl: messagingAllowed ? validatedCtaUrl ?? undefined : undefined,
+ customLinkPreviewEnabled:
+ messagingAllowed && typeof body.customLinkPreviewEnabled === "boolean"
+ ? body.customLinkPreviewEnabled
+ : false,
+ linkPreviewTitle: messagingAllowed
+ ? body.linkPreviewTitle ?? undefined
+ : undefined,
+ linkPreviewDescription: messagingAllowed
+ ? body.linkPreviewDescription ?? undefined
+ : undefined,
+ linkPreviewImage: messagingAllowed
+ ? body.linkPreviewImage ?? undefined
+ : undefined,
+ linkPreviewFavicon: messagingAllowed
+ ? body.linkPreviewFavicon ?? undefined
+ : undefined,
+ ...layoutData,
dataroomId,
},
});
@@ -102,33 +235,94 @@ export default async function handle(
return res.status(200).json(brand);
} else if (req.method === "PUT") {
// PUT /api/teams/:teamId/datarooms/:id/branding
- const {
- logo,
- banner,
- brandColor,
- accentColor,
- applyAccentColorToDataroomView,
- welcomeMessage,
- } = req.body as {
- logo?: string;
- banner?: string;
- brandColor?: string;
- accentColor?: string;
- applyAccentColorToDataroomView?: boolean;
- welcomeMessage?: string;
- };
+ const teamAuth = await prisma.team.findFirst({
+ where: {
+ id: teamId,
+ users: { some: { userId: (session.user as CustomUser).id } },
+ },
+ select: { plan: true },
+ });
+ if (!teamAuth) {
+ return res.status(403).end("Unauthorized to access this team");
+ }
+ const messagingAllowed = teamPlanAllowsCustomWelcomeAndCta(teamAuth.plan);
+ const layoutAllowed = teamPlanAllowsLayoutCustomization(teamAuth.plan);
+
+ const parsed = updateDataroomBrandingSchema.safeParse(req.body);
+ if (!parsed.success) {
+ return res.status(400).json({
+ message: "Invalid request body",
+ errors: parsed.error.flatten().fieldErrors,
+ });
+ }
+ const body = parsed.data;
+
+ const existingBrand = await prisma.dataroomBrand.findUnique({
+ where: { dataroomId },
+ });
+
+ let validatedCtaUrl: string | null | undefined = body.ctaUrl;
+ if (messagingAllowed && typeof body.ctaUrl === "string") {
+ const ctaValidation = await validateRedirectUrl(body.ctaUrl, teamId);
+ if (!ctaValidation.valid) {
+ return res.status(400).json({ message: ctaValidation.message });
+ }
+ validatedCtaUrl = ctaValidation.url;
+ }
+
+ const resolvedWelcome = messagingAllowed
+ ? body.welcomeMessage
+ : (existingBrand?.welcomeMessage ?? null);
+ const resolvedCtaLabel = messagingAllowed
+ ? body.ctaLabel
+ : (existingBrand?.ctaLabel ?? null);
+ const resolvedCtaUrl = messagingAllowed
+ ? validatedCtaUrl
+ : (existingBrand?.ctaUrl ?? null);
+
+ const layoutData = layoutAllowed
+ ? sanitizeLayoutPayload({
+ cardLayout: body.cardLayout,
+ showFolderTree: body.showFolderTree,
+ viewerLayoutPreset: body.viewerLayoutPreset,
+ viewerHeaderStyle: body.viewerHeaderStyle,
+ hideFolderIconsInMain: body.hideFolderIconsInMain,
+ })
+ : {};
const brand = await prisma.dataroomBrand.update({
where: {
dataroomId,
},
data: {
- logo,
- banner,
- brandColor,
- accentColor,
- applyAccentColorToDataroomView: !!applyAccentColorToDataroomView,
- welcomeMessage,
+ logo: body.logo,
+ banner: body.banner,
+ brandColor: body.brandColor,
+ accentColor: body.accentColor,
+ accentButtonColor: body.accentButtonColor,
+ applyAccentColorToDataroomView:
+ typeof body.applyAccentColorToDataroomView === "boolean"
+ ? body.applyAccentColorToDataroomView
+ : undefined,
+ welcomeMessage: resolvedWelcome,
+ ctaLabel: resolvedCtaLabel,
+ ctaUrl: resolvedCtaUrl,
+ // Plans without messaging access cannot mutate any link-preview
+ // fields, so the stored value is preserved as-is. Prisma skips
+ // updates for `undefined` values.
+ customLinkPreviewEnabled:
+ messagingAllowed && typeof body.customLinkPreviewEnabled === "boolean"
+ ? body.customLinkPreviewEnabled
+ : undefined,
+ linkPreviewTitle: messagingAllowed ? body.linkPreviewTitle : undefined,
+ linkPreviewDescription: messagingAllowed
+ ? body.linkPreviewDescription
+ : undefined,
+ linkPreviewImage: messagingAllowed ? body.linkPreviewImage : undefined,
+ linkPreviewFavicon: messagingAllowed
+ ? body.linkPreviewFavicon
+ : undefined,
+ ...layoutData,
},
});
@@ -139,23 +333,26 @@ export default async function handle(
where: {
dataroomId,
},
- select: { id: true, logo: true, banner: true },
+ select: {
+ id: true,
+ logo: true,
+ banner: true,
+ linkPreviewImage: true,
+ linkPreviewFavicon: true,
+ },
});
- if (brand && brand.logo) {
- // delete the logo from vercel blob
- await del(brand.logo);
- }
- if (brand && brand.banner) {
- // delete the logo from vercel blob
- await del(brand.banner);
+ if (brand) {
+ await Promise.all([
+ maybeDeleteBlobAsset(brand.logo),
+ maybeDeleteBlobAsset(brand.banner),
+ maybeDeleteBlobAsset(brand.linkPreviewImage),
+ maybeDeleteBlobAsset(brand.linkPreviewFavicon),
+ ]);
}
- // delete the branding from database
- await prisma.dataroomBrand.delete({
- where: {
- id: brand?.id,
- },
+ await prisma.dataroomBrand.deleteMany({
+ where: { dataroomId },
});
return res.status(204).end();
diff --git a/pages/api/teams/[teamId]/datarooms/[id]/calculate-indexes.ts b/pages/api/teams/[teamId]/datarooms/[id]/calculate-indexes.ts
index 77eb4f53..3ce7ac62 100644
--- a/pages/api/teams/[teamId]/datarooms/[id]/calculate-indexes.ts
+++ b/pages/api/teams/[teamId]/datarooms/[id]/calculate-indexes.ts
@@ -3,6 +3,7 @@ import type { NextApiRequest, NextApiResponse } from "next";
import { authOptions } from "@/pages/api/auth/[...nextauth]";
import { getServerSession } from "next-auth/next";
+import { teamPlanIsDataroomPlusTier } from "@/lib/billing/team-plan-custom-messaging";
import { getFeatureFlags } from "@/lib/featureFlags";
import prisma from "@/lib/prisma";
import { CustomUser } from "@/lib/types";
@@ -70,13 +71,9 @@ export default async function handler(
// Check if user has access: feature flag enabled OR datarooms-plus plan
const featureFlags = await getFeatureFlags({ teamId });
- const hasDataroomsPlusPlan =
- dataroom.team.plan === "datarooms-plus" ||
- dataroom.team.plan === "datarooms-plus+old" ||
- dataroom.team.plan === "datarooms-premium" ||
- dataroom.team.plan === "datarooms-premium+old" ||
- dataroom.team.plan === "datarooms-unlimited" ||
- dataroom.team.plan === "datarooms-unlimited+old";
+ const hasDataroomsPlusPlan = teamPlanIsDataroomPlusTier(
+ dataroom.team.plan,
+ );
if (!featureFlags.dataroomIndex && !hasDataroomsPlusPlan) {
return res.status(403).json({
diff --git a/pages/api/teams/[teamId]/datarooms/[id]/duplicate.ts b/pages/api/teams/[teamId]/datarooms/[id]/duplicate.ts
index 1600061c..859186b3 100644
--- a/pages/api/teams/[teamId]/datarooms/[id]/duplicate.ts
+++ b/pages/api/teams/[teamId]/datarooms/[id]/duplicate.ts
@@ -229,17 +229,39 @@ export default async function handle(
folders: {
create: [],
},
- brand: {
- create: {
- banner: dataroomContents.brand?.banner,
- logo: dataroomContents.brand?.logo,
- accentColor: dataroomContents.brand?.accentColor,
- applyAccentColorToDataroomView:
- (dataroomContents.brand as any)?.applyAccentColorToDataroomView ??
- false,
- brandColor: dataroomContents.brand?.brandColor,
- },
- },
+ brand: dataroomContents.brand
+ ? {
+ create: {
+ logo: dataroomContents.brand.logo,
+ banner: dataroomContents.brand.banner,
+ brandColor: dataroomContents.brand.brandColor,
+ accentColor: dataroomContents.brand.accentColor,
+ accentButtonColor: dataroomContents.brand.accentButtonColor,
+ applyAccentColorToDataroomView:
+ dataroomContents.brand.applyAccentColorToDataroomView ??
+ false,
+ welcomeMessage: dataroomContents.brand.welcomeMessage,
+ cardLayout: dataroomContents.brand.cardLayout ?? undefined,
+ showFolderTree:
+ dataroomContents.brand.showFolderTree ?? undefined,
+ viewerLayoutPreset:
+ dataroomContents.brand.viewerLayoutPreset ?? undefined,
+ viewerHeaderStyle:
+ dataroomContents.brand.viewerHeaderStyle ?? undefined,
+ hideFolderIconsInMain:
+ dataroomContents.brand.hideFolderIconsInMain ?? undefined,
+ ctaLabel: dataroomContents.brand.ctaLabel,
+ ctaUrl: dataroomContents.brand.ctaUrl,
+ customLinkPreviewEnabled:
+ dataroomContents.brand.customLinkPreviewEnabled ?? false,
+ linkPreviewTitle: dataroomContents.brand.linkPreviewTitle,
+ linkPreviewDescription:
+ dataroomContents.brand.linkPreviewDescription,
+ linkPreviewImage: dataroomContents.brand.linkPreviewImage,
+ linkPreviewFavicon: dataroomContents.brand.linkPreviewFavicon,
+ },
+ }
+ : undefined,
},
});
diff --git a/pages/branding.tsx b/pages/branding.tsx
index 31910003..9fd2b0c5 100644
--- a/pages/branding.tsx
+++ b/pages/branding.tsx
@@ -1,10 +1,13 @@
-import { useRouter } from "next/router";
-
-import { useCallback, useEffect, useState } from "react";
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useTeam } from "@/context/team-context";
import { PlanEnum } from "@/ee/stripe/constants";
-import { Check, CircleHelpIcon, UploadIcon } from "lucide-react";
+import {
+ Check,
+ CircleHelpIcon,
+ CrownIcon,
+ UploadIcon,
+} from "lucide-react";
import { HexColorInput, HexColorPicker } from "react-colorful";
import sanitizeHtml from "sanitize-html";
import { toast } from "sonner";
@@ -13,15 +16,35 @@ import { useDebounce } from "use-debounce";
import { usePlan } from "@/lib/swr/use-billing";
import { useBrand } from "@/lib/swr/use-brand";
+import {
+ CARD_LAYOUT_OPTIONS,
+ asDataroomCardLayout,
+ asDataroomViewerHeaderStyle,
+ inferDataroomViewerLayoutPreset,
+ type DataroomCardLayout,
+ type DataroomLayoutCardId,
+ type DataroomViewerHeaderStyle,
+} from "@/ee/features/branding/lib/dataroom-viewer-layout";
import { cn, convertDataUrlToFile, uploadImage } from "@/lib/utils";
import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { BannerEditor } from "@/ee/features/branding/components/banner-editor";
+import { BrandingLinkPreviewForm } from "@/ee/features/branding/components/branding-link-preview-form";
+import { CollapsibleBrandingSection } from "@/ee/features/branding/components/collapsible-branding-section";
+import { DataroomLayoutPresetCards } from "@/ee/features/branding/components/dataroom-layout-preset-cards";
import AppLayout from "@/components/layouts/app";
+import { DataroomBannerMedia } from "@/components/view/dataroom/dataroom-banner-media";
import { NavMenu } from "@/components/navigation-menu";
import { Button } from "@/components/ui/button";
import { Card, CardContent, CardFooter } from "@/components/ui/card";
import { Checkbox } from "@/components/ui/checkbox";
+import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
+import {
+ RadioGroup,
+ RadioGroupItem,
+} from "@/components/ui/radio-group";
+import { Switch } from "@/components/ui/switch";
import LoadingSpinner from "@/components/ui/loading-spinner";
import {
Popover,
@@ -35,26 +58,34 @@ import { UpgradeButton } from "@/components/ui/upgrade-button";
export default function Branding() {
const teamInfo = useTeam();
- const router = useRouter();
const { brand } = useBrand();
const { plan, isTrial, isBusiness, isDatarooms, isDataroomsPlus } = usePlan();
const [brandColor, setBrandColor] = useState<string>("#000000");
const [accentColor, setAccentColor] = useState<string>("#030712");
+ const [accentButtonColor, setAccentButtonColor] = useState<string>("#000000");
+ const [ctaEnabled, setCtaEnabled] = useState<boolean>(false);
+ const [ctaLabel, setCtaLabel] = useState<string>("");
+ const [ctaUrl, setCtaUrl] = useState<string>("");
const [logo, setLogo] = useState<string | null>(null);
const [blobUrl, setBlobUrl] = useState<string | null>(null);
const [banner, setBanner] = useState<string | null>(null);
const [bannerBlobUrl, setBannerBlobUrl] = useState<string | null>(null);
+ const DEFAULT_WELCOME_MESSAGE = "Your action is requested to continue";
const [welcomeMessage, setWelcomeMessage] = useState<string>(
- "Your action is requested to continue",
+ DEFAULT_WELCOME_MESSAGE,
);
+ const [welcomeEnabled, setWelcomeEnabled] = useState<boolean>(false);
+ const [previewTab, setPreviewTab] = useState<string>("document-view");
+ const [settingsTab, setSettingsTab] = useState<string>("branding");
const [applyAccentColorToDataroomView, setApplyAccentColorToDataroomView] =
useState<boolean>(false);
const [debouncedBrandColor] = useDebounce(brandColor, 300);
const [debouncedAccentColor] = useDebounce(accentColor, 300);
+ const [debouncedAccentButtonColor] = useDebounce(accentButtonColor, 300);
const [debouncedWelcomeMessage] = useDebounce(welcomeMessage, 500);
-
- const [isLoading, setIsLoading] = useState<boolean>(false);
+ const [debouncedCtaLabel] = useDebounce(ctaLabel, 400);
+ const [debouncedCtaUrl] = useDebounce(ctaUrl, 400);
const [fileError, setFileError] = useState<string | null>(null);
const [bannerError, setBannerError] = useState<string | null>(null);
const [dragActive, setDragActive] = useState(false);
@@ -63,9 +94,176 @@ export default function Branding() {
null,
);
- // Check if user has access to dataroom branding features
+ // Custom Link Preview (Open Graph meta defaults). Inherits down to each
+ // dataroom and link; per-link / per-dataroom values can still override.
+ const [linkPreviewEnabled, setLinkPreviewEnabled] = useState<boolean>(false);
+ const [linkPreviewTitle, setLinkPreviewTitle] = useState<string>("");
+ const [linkPreviewDescription, setLinkPreviewDescription] = useState<string>(
+ "",
+ );
+ const [linkPreviewImage, setLinkPreviewImage] = useState<string | null>(null);
+ const [linkPreviewFavicon, setLinkPreviewFavicon] = useState<string | null>(
+ null,
+ );
+
+ // Auto-fill from website (brand lookup)
+ const [autoFillUrl, setAutoFillUrl] = useState<string>("");
+ const [autoFillLoading, setAutoFillLoading] = useState<boolean>(false);
+
+ // Custom welcome message + CTA require Business, Data Rooms, or trial
const hasDataroomAccess =
isBusiness || isDatarooms || isDataroomsPlus || isTrial;
+ const hasBusinessMessagingAccess =
+ isBusiness || isDatarooms || isDataroomsPlus || isTrial;
+
+ // Layouts visibility: Business+ or any dataroom trial sees the Layouts tab.
+ // Layouts save: only Trial / DataRooms plans can persist — Business gets the
+ // "Upgrade to save" path that opens the DataRooms upgrade modal.
+ const hasLayoutVisibility =
+ isBusiness || isDatarooms || isDataroomsPlus || isTrial;
+ const hasLayoutSaveAccess = isDatarooms || isDataroomsPlus || isTrial;
+
+ // Dataroom layout state (mirrors per-dataroom branding shape)
+ const [cardLayout, setCardLayout] = useState<DataroomCardLayout>("LIST");
+ const [showFolderTree, setShowFolderTree] = useState<boolean>(true);
+ const [viewerHeaderStyle, setViewerHeaderStyle] =
+ useState<DataroomViewerHeaderStyle>("DEFAULT");
+ const [hideFolderIconsInMain, setHideFolderIconsInMain] =
+ useState<boolean>(false);
+ const [upgradeLayoutsModalOpen, setUpgradeLayoutsModalOpen] =
+ useState<boolean>(false);
+ const [upgradeMessagingModalOpen, setUpgradeMessagingModalOpen] =
+ useState<boolean>(false);
+
+ // Snapshot of the loaded layout values so we can detect "dirty" changes the
+ // current plan isn't allowed to persist.
+ const initialLayoutSnapshotRef = useRef<{
+ cardLayout: DataroomCardLayout;
+ showFolderTree: boolean;
+ viewerHeaderStyle: DataroomViewerHeaderStyle;
+ hideFolderIconsInMain: boolean;
+ } | null>(null);
+
+ const derivedLayoutPreset = useMemo(
+ () =>
+ inferDataroomViewerLayoutPreset({
+ cardLayout,
+ showFolderTree,
+ hideFolderIconsInMain,
+ viewerHeaderStyle,
+ }),
+ [cardLayout, showFolderTree, hideFolderIconsInMain, viewerHeaderStyle],
+ );
+
+ const layoutHasUnsavedChanges = useMemo(() => {
+ const initial = initialLayoutSnapshotRef.current;
+ if (!initial) return false;
+ return (
+ initial.cardLayout !== cardLayout ||
+ initial.showFolderTree !== showFolderTree ||
+ initial.viewerHeaderStyle !== viewerHeaderStyle ||
+ initial.hideFolderIconsInMain !== hideFolderIconsInMain
+ );
+ }, [cardLayout, showFolderTree, viewerHeaderStyle, hideFolderIconsInMain]);
+
+ const layoutBlocksSave = !hasLayoutSaveAccess && layoutHasUnsavedChanges;
+
+ const applyLayoutPreset = (id: DataroomLayoutCardId) => {
+ switch (id) {
+ case "STANDARD":
+ setCardLayout("LIST");
+ setShowFolderTree(true);
+ setViewerHeaderStyle("DEFAULT");
+ setHideFolderIconsInMain(false);
+ break;
+ case "STRICT":
+ setCardLayout("COMPACT");
+ setShowFolderTree(false);
+ setViewerHeaderStyle("DEFAULT");
+ setHideFolderIconsInMain(true);
+ break;
+ case "MODERN":
+ setCardLayout("COMPACT");
+ setShowFolderTree(false);
+ setViewerHeaderStyle("SPLIT");
+ setHideFolderIconsInMain(true);
+ break;
+ case "NOTION":
+ setCardLayout("GRID");
+ setShowFolderTree(false);
+ setViewerHeaderStyle("NOTION");
+ setHideFolderIconsInMain(false);
+ break;
+ }
+ };
+
+ // Front-page preview mirrors viewer behaviour: when toggle is off, the
+ // viewer falls back to the default message regardless of saved value.
+ const previewWelcomeMessage =
+ hasBusinessMessagingAccess && welcomeEnabled
+ ? debouncedWelcomeMessage
+ : DEFAULT_WELCOME_MESSAGE;
+ const previewCtaLabel =
+ hasBusinessMessagingAccess && ctaEnabled
+ ? debouncedCtaLabel.trim() || "Book a call"
+ : "";
+ const previewCtaUrl =
+ hasBusinessMessagingAccess && ctaEnabled
+ ? debouncedCtaUrl.trim() || "#"
+ : "";
+
+ const [isLoading, setIsLoading] = useState<boolean>(false);
+
+ const handleAutoFill = async () => {
+ if (!autoFillUrl.trim()) return;
+ setAutoFillLoading(true);
+ try {
+ const res = await fetch("/api/branding/auto-fill", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ url: autoFillUrl.trim() }),
+ });
+ const data = await res.json();
+ if (!res.ok) {
+ toast.error(data.error || "Could not load brand");
+ return;
+ }
+ let applied = 0;
+ if (data.logo) {
+ setLogo(data.logo);
+ setBlobUrl(null);
+ applied++;
+ }
+ if (hasDataroomAccess && data.banner) {
+ setBanner(data.banner);
+ setBannerBlobUrl(null);
+ applied++;
+ }
+ if (data.brandColor) {
+ setBrandColor(data.brandColor);
+ applied++;
+ }
+ if (data.accentColor) {
+ setAccentColor(data.accentColor);
+ applied++;
+ }
+ if (data.accentButtonColor) {
+ setAccentButtonColor(data.accentButtonColor);
+ applied++;
+ }
+ if (applied === 0) {
+ toast.warning("No brand data found for that website");
+ } else {
+ toast.success(
+ `Loaded ${data.name ?? data.domain}. Review and click Save changes.`,
+ );
+ }
+ } catch (err) {
+ toast.error("Lookup failed");
+ } finally {
+ setAutoFillLoading(false);
+ }
+ };
// Welcome message validation
const MAX_WELCOME_MESSAGE_LENGTH = 80; // Roughly 2 lines of text
@@ -144,22 +342,111 @@ export default function Branding() {
[setBanner],
);
+ // Revoke object URLs whenever they're replaced or the component unmounts to
+ // avoid leaking blob storage across re-uploads and navigations.
useEffect(() => {
+ if (!blobUrl) return;
+ return () => {
+ URL.revokeObjectURL(blobUrl);
+ };
+ }, [blobUrl]);
+
+ useEffect(() => {
+ if (!bannerBlobUrl) return;
+ return () => {
+ URL.revokeObjectURL(bannerBlobUrl);
+ };
+ }, [bannerBlobUrl]);
+
+ useEffect(() => {
+ // undefined = SWR still loading; null = no Brand row (treat as reset defaults)
+ if (brand === undefined) return;
+
if (brand) {
setBrandColor(brand.brandColor || "#000000");
setAccentColor(brand.accentColor || "#FFFFFF");
+ setAccentButtonColor(
+ (brand as any)?.accentButtonColor || brand.brandColor || "#000000",
+ );
setLogo(brand.logo || null);
setBanner(brand.banner || null);
setApplyAccentColorToDataroomView(
(brand as any)?.applyAccentColorToDataroomView ?? false,
);
- const message =
- brand.welcomeMessage || "Your action is requested to continue";
+ const initialCtaLabel = (brand as any)?.ctaLabel ?? "";
+ const initialCtaUrl = (brand as any)?.ctaUrl ?? "";
+ setCtaLabel(initialCtaLabel);
+ setCtaUrl(initialCtaUrl);
+ setCtaEnabled(!!(initialCtaLabel || initialCtaUrl));
+ const savedMessage = brand.welcomeMessage ?? null;
+ const message = savedMessage || DEFAULT_WELCOME_MESSAGE;
setWelcomeMessage(message);
+ setWelcomeEnabled(
+ !!savedMessage && savedMessage !== DEFAULT_WELCOME_MESSAGE,
+ );
// Validate existing message
const error = validateWelcomeMessage(message);
setWelcomeMessageError(error);
+ setLinkPreviewEnabled(
+ (brand as any)?.customLinkPreviewEnabled === true,
+ );
+ setLinkPreviewTitle((brand as any)?.linkPreviewTitle ?? "");
+ setLinkPreviewDescription(
+ (brand as any)?.linkPreviewDescription ?? "",
+ );
+ setLinkPreviewImage((brand as any)?.linkPreviewImage ?? null);
+ setLinkPreviewFavicon((brand as any)?.linkPreviewFavicon ?? null);
+
+ const loadedCardLayout = asDataroomCardLayout(
+ (brand as any)?.cardLayout,
+ );
+ const loadedShowFolderTree =
+ ((brand as any)?.showFolderTree as boolean | undefined) ?? true;
+ const loadedHeaderStyle = asDataroomViewerHeaderStyle(
+ (brand as any)?.viewerHeaderStyle,
+ );
+ const loadedHideFolderIcons =
+ ((brand as any)?.hideFolderIconsInMain as boolean | undefined) ?? false;
+ setCardLayout(loadedCardLayout);
+ setShowFolderTree(loadedShowFolderTree);
+ setViewerHeaderStyle(loadedHeaderStyle);
+ setHideFolderIconsInMain(loadedHideFolderIcons);
+ initialLayoutSnapshotRef.current = {
+ cardLayout: loadedCardLayout,
+ showFolderTree: loadedShowFolderTree,
+ viewerHeaderStyle: loadedHeaderStyle,
+ hideFolderIconsInMain: loadedHideFolderIcons,
+ };
+ return;
}
+
+ setBrandColor("#000000");
+ setAccentColor("#030712");
+ setAccentButtonColor("#000000");
+ setLogo(null);
+ setBanner(null);
+ setApplyAccentColorToDataroomView(false);
+ setCtaEnabled(false);
+ setCtaLabel("");
+ setCtaUrl("");
+ setWelcomeMessage(DEFAULT_WELCOME_MESSAGE);
+ setWelcomeEnabled(false);
+ setWelcomeMessageError(null);
+ setLinkPreviewEnabled(false);
+ setLinkPreviewTitle("");
+ setLinkPreviewDescription("");
+ setLinkPreviewImage(null);
+ setLinkPreviewFavicon(null);
+ setCardLayout("LIST");
+ setShowFolderTree(true);
+ setViewerHeaderStyle("DEFAULT");
+ setHideFolderIconsInMain(false);
+ initialLayoutSnapshotRef.current = {
+ cardLayout: "LIST",
+ showFolderTree: true,
+ viewerHeaderStyle: "DEFAULT",
+ hideFolderIconsInMain: false,
+ };
}, [brand]);
// Handle welcome message change with validation
@@ -172,14 +459,24 @@ export default function Branding() {
const saveBranding = async (e: any) => {
e.preventDefault();
- // Validate welcome message before saving
- const welcomeError = validateWelcomeMessage(welcomeMessage);
- if (welcomeError) {
- setWelcomeMessageError(welcomeError);
- toast.error("Please fix the validation errors before saving");
+ // Block the save when the user has dirty layout changes but no save tier.
+ // The dataroom-branding page uses the exact same pattern; opens the same
+ // upgrade modal so the cross-sell highlights the "Dataroom viewer layouts"
+ // line on the Data Rooms plan card.
+ if (layoutBlocksSave) {
+ setUpgradeLayoutsModalOpen(true);
return;
}
+ if (hasBusinessMessagingAccess) {
+ const welcomeError = validateWelcomeMessage(welcomeMessage);
+ if (welcomeError) {
+ setWelcomeMessageError(welcomeError);
+ toast.error("Please fix the validation errors before saving");
+ return;
+ }
+ }
+
setIsLoading(true);
let logoBlobUrl: string | null =
logo && logo.startsWith("data:") ? null : logo;
@@ -197,15 +494,92 @@ export default function Branding() {
setBanner(bannerBlobUrl);
}
+ // Persist Custom Link Preview assets the same way as logo/banner: when the
+ // user is on a tier that can write them and has the toggle on, swap any
+ // data: URL for a uploaded blob URL before sending to the API.
+ let linkPreviewImageUrl: string | null = linkPreviewImage;
+ if (
+ hasBusinessMessagingAccess &&
+ linkPreviewEnabled &&
+ linkPreviewImage &&
+ linkPreviewImage.startsWith("data:")
+ ) {
+ const blob = convertDataUrlToFile({ dataUrl: linkPreviewImage });
+ linkPreviewImageUrl = await uploadImage(blob);
+ setLinkPreviewImage(linkPreviewImageUrl);
+ }
+
+ let linkPreviewFaviconUrl: string | null = linkPreviewFavicon;
+ if (
+ hasBusinessMessagingAccess &&
+ linkPreviewEnabled &&
+ linkPreviewFavicon &&
+ linkPreviewFavicon.startsWith("data:")
+ ) {
+ const blob = convertDataUrlToFile({ dataUrl: linkPreviewFavicon });
+ linkPreviewFaviconUrl = await uploadImage(blob);
+ setLinkPreviewFavicon(linkPreviewFaviconUrl);
+ }
+
const data = {
- welcomeMessage:
- welcomeMessage.trim() || "Your action is requested to continue",
+ welcomeMessage: hasBusinessMessagingAccess
+ ? welcomeEnabled
+ ? welcomeMessage.trim() || DEFAULT_WELCOME_MESSAGE
+ : null
+ : ((brand as any)?.welcomeMessage ?? null),
brandColor: brandColor,
accentColor: accentColor,
+ accentButtonColor: accentButtonColor,
applyAccentColorToDataroomView,
logo: logoBlobUrl,
+ ctaLabel: hasBusinessMessagingAccess
+ ? ctaEnabled
+ ? ctaLabel.trim() || null
+ : null
+ : ((brand as any)?.ctaLabel ?? null),
+ ctaUrl: hasBusinessMessagingAccess
+ ? ctaEnabled
+ ? ctaUrl.trim() || null
+ : null
+ : ((brand as any)?.ctaUrl ?? null),
+ // Custom Link Preview — only writable when the team plan grants the
+ // Business messaging tier. Otherwise we mirror back what's already
+ // persisted so the API doesn't clear it out from a lower tier.
+ customLinkPreviewEnabled: hasBusinessMessagingAccess
+ ? linkPreviewEnabled
+ : !!(brand as any)?.customLinkPreviewEnabled,
+ linkPreviewTitle: hasBusinessMessagingAccess
+ ? linkPreviewEnabled
+ ? linkPreviewTitle.trim() || null
+ : null
+ : ((brand as any)?.linkPreviewTitle ?? null),
+ linkPreviewDescription: hasBusinessMessagingAccess
+ ? linkPreviewEnabled
+ ? linkPreviewDescription.trim() || null
+ : null
+ : ((brand as any)?.linkPreviewDescription ?? null),
+ linkPreviewImage: hasBusinessMessagingAccess
+ ? linkPreviewEnabled
+ ? linkPreviewImageUrl
+ : null
+ : ((brand as any)?.linkPreviewImage ?? null),
+ linkPreviewFavicon: hasBusinessMessagingAccess
+ ? linkPreviewEnabled
+ ? linkPreviewFaviconUrl
+ : null
+ : ((brand as any)?.linkPreviewFavicon ?? null),
// Only include banner if user has dataroom access (Business+)
...(hasDataroomAccess && { banner: bannerBlobUrl }),
+ // Layout fields are only included when the plan can persist them. The
+ // API still re-checks tier and silently drops them otherwise, but
+ // sending less keeps the payload honest.
+ ...(hasLayoutSaveAccess && {
+ cardLayout,
+ showFolderTree,
+ viewerHeaderStyle,
+ hideFolderIconsInMain,
+ viewerLayoutPreset: derivedLayoutPreset,
+ }),
};
const res = await fetch(
@@ -222,6 +596,14 @@ export default function Branding() {
if (res.ok) {
mutate(`/api/teams/${teamInfo?.currentTeam?.id}/branding`);
setIsLoading(false);
+ if (hasLayoutSaveAccess) {
+ initialLayoutSnapshotRef.current = {
+ cardLayout,
+ showFolderTree,
+ viewerHeaderStyle,
+ hideFolderIconsInMain,
+ };
+ }
toast.success("Branding updated successfully");
} else {
setIsLoading(false);
@@ -244,19 +626,48 @@ export default function Branding() {
);
if (res.ok) {
+ await mutate(
+ `/api/teams/${teamInfo?.currentTeam?.id}/branding`,
+ null,
+ { revalidate: false },
+ );
setLogo(null);
setBanner(null);
setBrandColor("#000000");
setAccentColor("#030712");
+ setAccentButtonColor("#000000");
+ setCtaEnabled(false);
+ setCtaLabel("");
+ setCtaUrl("");
setApplyAccentColorToDataroomView(false);
- setWelcomeMessage("Your action is requested to continue");
+ setWelcomeMessage(DEFAULT_WELCOME_MESSAGE);
+ setWelcomeEnabled(false);
setWelcomeMessageError(null);
+ setLinkPreviewEnabled(false);
+ setLinkPreviewTitle("");
+ setLinkPreviewDescription("");
+ setLinkPreviewImage(null);
+ setLinkPreviewFavicon(null);
+ setCardLayout("LIST");
+ setShowFolderTree(true);
+ setViewerHeaderStyle("DEFAULT");
+ setHideFolderIconsInMain(false);
+ initialLayoutSnapshotRef.current = {
+ cardLayout: "LIST",
+ showFolderTree: true,
+ viewerHeaderStyle: "DEFAULT",
+ hideFolderIconsInMain: false,
+ };
setIsLoading(false);
toast.success("Branding reset successfully");
- router.reload();
+ } else {
+ setIsLoading(false);
+ toast.error("Failed to reset branding");
}
};
+ const mainPreviewTabCount = 2 + (hasDataroomAccess ? 1 : 0);
+
return (
<AppLayout>
<div className="relative mx-2 mb-10 mt-4 space-y-8 px-1 sm:mx-3 md:mx-5 md:mt-5 lg:mx-7 lg:mt-8 xl:mx-10">
@@ -285,11 +696,6 @@ export default function Branding() {
href: "/settings/domains",
segment: "domains",
},
- {
- label: "Link Previews",
- href: "/settings/presets",
- segment: "presets",
- },
]}
/>
</header>
@@ -324,8 +730,84 @@ export default function Branding() {
<div className="flex w-full flex-col gap-6 lg:flex-row lg:gap-8">
{/* Settings Column */}
<div className="flex w-full flex-col gap-6 lg:w-[420px] lg:shrink-0">
- {/* Scrollable Settings */}
- <div className="flex flex-col gap-6 lg:max-h-[calc(100vh-400px)] lg:overflow-y-auto lg:pr-4">
+ {/* Scrollable Settings — wrapped in Tabs (Branding / Layouts).
+ The Layouts trigger only renders when the team plan grants
+ visibility (Business+, DataRooms+, or any dataroom trial);
+ free plans see no Layouts tab at all. */}
+ <Tabs
+ value={settingsTab}
+ onValueChange={(v) => {
+ setSettingsTab(v);
+ // When opening the Layouts settings tab, lock the preview to
+ // the dataroom view since that's the only surface layouts
+ // affect. Switching back to Branding leaves the preview where
+ // the user left it.
+ if (v === "layouts") {
+ setPreviewTab("dataroom-view");
+ }
+ }}
+ className="w-full"
+ >
+ <TabsList
+ className={cn(
+ "grid w-full",
+ hasLayoutVisibility ? "grid-cols-2" : "grid-cols-1",
+ )}
+ >
+ <TabsTrigger value="branding">Branding</TabsTrigger>
+ {hasLayoutVisibility && (
+ <TabsTrigger value="layouts" className="gap-1.5">
+ Layouts
+ <span className="inline-flex items-center rounded-[4px] bg-orange-500 px-1.5 py-0.5 text-[9px] font-semibold uppercase leading-none tracking-wide text-white">
+ New
+ </span>
+ </TabsTrigger>
+ )}
+ </TabsList>
+ <TabsContent
+ value="branding"
+ className="mt-4 flex flex-col gap-6 lg:max-h-[calc(100vh-440px)] lg:overflow-y-auto lg:pr-4"
+ >
+ {/* Auto-fill from website */}
+ <Card>
+ <CardContent className="pt-6">
+ <div className="space-y-3">
+ <Label htmlFor="auto-fill-url">
+ Auto-fill from website
+ </Label>
+ <p className="text-xs text-muted-foreground">
+ Paste a website URL and we&apos;ll pull logo
+ {hasDataroomAccess ? ", banner" : ""} and brand colors
+ automatically. You can still tweak everything below
+ before saving.
+ </p>
+ <div className="flex gap-2">
+ <Input
+ id="auto-fill-url"
+ type="text"
+ placeholder="company.com"
+ value={autoFillUrl}
+ onChange={(e) => setAutoFillUrl(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") {
+ e.preventDefault();
+ handleAutoFill();
+ }
+ }}
+ />
+ <Button
+ type="button"
+ onClick={handleAutoFill}
+ loading={autoFillLoading}
+ disabled={!autoFillUrl.trim()}
+ >
+ Fetch
+ </Button>
+ </div>
+ </div>
+ </CardContent>
+ </Card>
+
{/* Logo Card */}
<Card>
<CardContent className="pt-6">
@@ -430,119 +912,140 @@ export default function Branding() {
{/* Banner Card - Only for Business+ users */}
{hasDataroomAccess && (
<Card>
- <CardContent className="pt-6">
- <div className="space-y-2">
- <Label htmlFor="banner">
- Banner{" "}
- <span className="font-normal text-muted-foreground">
- (for data rooms, max 2 MB)
- </span>
- </Label>
- <label
- htmlFor="banner"
- className="group relative mt-2 flex h-32 w-full cursor-pointer flex-col items-center justify-center rounded-lg border-2 border-dashed border-gray-300 bg-gray-50 transition-all hover:border-gray-400 hover:bg-gray-100"
- >
- <div
- className="absolute z-[5] h-full w-full rounded-lg"
- onDragOver={(e) => {
- e.preventDefault();
- e.stopPropagation();
- setBannerDragActive(true);
- }}
- onDragEnter={(e) => {
- e.preventDefault();
- e.stopPropagation();
- setBannerDragActive(true);
- }}
- onDragLeave={(e) => {
- e.preventDefault();
- e.stopPropagation();
- setBannerDragActive(false);
- }}
- onDrop={(e) => {
- e.preventDefault();
- e.stopPropagation();
- setBannerDragActive(false);
- setBannerError(null);
- const file =
- e.dataTransfer.files && e.dataTransfer.files[0];
- if (file) {
- if (file.size / 1024 / 1024 > 2) {
- setBannerError("File size too big (max 2MB)");
- } else if (
- file.type !== "image/png" &&
- file.type !== "image/jpeg"
- ) {
- setBannerError(
- "File type not supported (.png or .jpg only)",
- );
- } else {
- const reader = new FileReader();
- reader.onload = (e) => {
- const dataUrl = e.target?.result as string;
- setBanner(dataUrl);
- const blob = convertDataUrlToFile({
- dataUrl,
- });
- const blobUrl = URL.createObjectURL(blob);
- setBannerBlobUrl(blobUrl);
- };
- reader.readAsDataURL(file);
- }
- }
- }}
- />
- {!banner ? (
- <div
- className={cn(
- "flex flex-col items-center justify-center gap-2",
- bannerDragActive && "scale-105",
- )}
+ <CardContent className="space-y-3 pt-6">
+ <BannerEditor
+ banner={banner}
+ setBanner={setBanner}
+ setBannerBlobUrl={setBannerBlobUrl}
+ sizeHint="(for data rooms, max 2 MB)"
+ onUrlApplied={() => {
+ // Pasting a banner URL (image/video/YouTube) is a
+ // strong signal the user wants a richer hero — auto
+ // promote Standard → Modern so the preview reflects
+ // it. Only run when Layouts UI is visible to this
+ // plan; otherwise we'd silently mutate state the
+ // user can't see or revert.
+ if (
+ hasLayoutVisibility &&
+ derivedLayoutPreset === "STANDARD"
+ ) {
+ applyLayoutPreset("MODERN");
+ setPreviewTab("dataroom-view");
+ }
+ }}
+ dropZone={
+ <>
+ <label
+ htmlFor="banner"
+ className="group relative flex h-32 w-full cursor-pointer flex-col items-center justify-center rounded-lg border-2 border-dashed border-gray-300 bg-gray-50 transition-all hover:border-gray-400 hover:bg-gray-100"
>
- <UploadIcon
- className="h-8 w-8 text-gray-400"
- aria-hidden="true"
- />
- <p className="text-xs text-muted-foreground">
- Upload banner image
- </p>
- </div>
- ) : (
- <div className="relative flex h-full w-full items-center justify-center p-4">
- <img
- src={banner}
- alt="Banner preview"
- className="max-h-full max-w-full object-cover"
+ <div
+ className="absolute z-[5] h-full w-full rounded-lg"
+ onDragOver={(e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ setBannerDragActive(true);
+ }}
+ onDragEnter={(e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ setBannerDragActive(true);
+ }}
+ onDragLeave={(e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ setBannerDragActive(false);
+ }}
+ onDrop={(e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ setBannerDragActive(false);
+ setBannerError(null);
+ const file =
+ e.dataTransfer.files &&
+ e.dataTransfer.files[0];
+ if (file) {
+ if (file.size / 1024 / 1024 > 2) {
+ setBannerError(
+ "File size too big (max 2MB)",
+ );
+ } else if (
+ file.type !== "image/png" &&
+ file.type !== "image/jpeg"
+ ) {
+ setBannerError(
+ "File type not supported (.png or .jpg only)",
+ );
+ } else {
+ const reader = new FileReader();
+ reader.onload = (e) => {
+ const dataUrl = e.target
+ ?.result as string;
+ setBanner(dataUrl);
+ const blob = convertDataUrlToFile({
+ dataUrl,
+ });
+ const blobUrl =
+ URL.createObjectURL(blob);
+ setBannerBlobUrl(blobUrl);
+ };
+ reader.readAsDataURL(file);
+ }
+ }
+ }}
/>
- </div>
- )}
- </label>
- <input
- id="banner"
- name="banner"
- type="file"
- accept="image/jpeg,image/png"
- className="sr-only"
- onChange={onChangeBanner}
- />
- {bannerError && (
- <p className="text-sm text-red-500">{bannerError}</p>
- )}
- {banner && (
- <Button
- type="button"
- variant="ghost"
- size="sm"
- onClick={() => {
- setBanner(null);
- setBannerBlobUrl(null);
- }}
- className="text-xs"
- >
- Remove banner
- </Button>
- )}
- </div>
+ {!banner ? (
+ <div
+ className={cn(
+ "flex flex-col items-center justify-center gap-2",
+ bannerDragActive && "scale-105",
+ )}
+ >
+ <UploadIcon
+ className="h-8 w-8 text-gray-400"
+ aria-hidden="true"
+ />
+ <p className="text-xs text-muted-foreground">
+ Upload banner image
+ </p>
+ </div>
+ ) : (
+ <div className="relative h-full w-full overflow-hidden">
+ <DataroomBannerMedia
+ src={banner}
+ alt="Banner preview"
+ />
+ </div>
+ )}
+ </label>
+ <input
+ id="banner"
+ name="banner"
+ type="file"
+ accept="image/jpeg,image/png"
+ className="sr-only"
+ onChange={onChangeBanner}
+ />
+ </>
+ }
+ />
+ {bannerError && (
+ <p className="text-sm text-red-500">{bannerError}</p>
+ )}
+ {banner && (
+ <Button
+ type="button"
+ variant="ghost"
+ size="sm"
+ onClick={() => {
+ setBanner(null);
+ setBannerBlobUrl(null);
+ }}
+ className="text-xs"
+ >
+ Remove banner
+ </Button>
+ )}
</CardContent>
</Card>
)}
@@ -678,13 +1181,12 @@ export default function Branding() {
htmlFor="global-apply-accent-to-dataroom-view"
className="cursor-pointer text-sm font-medium"
>
- Apply background color to dataroom view by
- default
+ Apply background color to dataroom view
</Label>
- <p className="text-xs text-muted-foreground">
+ {/* <p className="text-xs text-muted-foreground">
Dataroom-specific branding can still override
this.
- </p>
+ </p> */}
</div>
</div>
</div>
@@ -693,54 +1195,394 @@ export default function Branding() {
</CardContent>
</Card>
- {/* Welcome Message Card */}
- <Card>
- <CardContent className="pt-6">
- <div className="space-y-3">
- <div className="flex items-center justify-between">
- <Label htmlFor="accent-color">
- Welcome Message{" "}
- <span className="font-normal text-muted-foreground">
- (front page)
- </span>
- </Label>
- <span className="text-sm text-muted-foreground">
- <span
- className={cn(
- welcomeMessageError && "text-red-500",
- )}
+ <CollapsibleBrandingSection
+ title="Advanced settings"
+ defaultOpen={false}
+ >
+ <div className="flex flex-col gap-6">
+ {/* Call to Action Card (with toggle) */}
+ <Card>
+ <CardContent className="pt-6">
+ <div className="space-y-3">
+ <div
+ className="flex items-center justify-between"
+ onClick={
+ !hasBusinessMessagingAccess
+ ? () => setUpgradeMessagingModalOpen(true)
+ : undefined
+ }
>
- {welcomeMessage.length}
- </span>
- /{MAX_WELCOME_MESSAGE_LENGTH}
- </span>
- </div>
- <Textarea
- id="welcome-message"
- value={welcomeMessage}
- onChange={(e) =>
- handleWelcomeMessageChange(e.target.value)
- }
- placeholder="Your action is requested to continue"
- className={cn(
- "min-h-24 resize-none",
- welcomeMessageError &&
- "border-red-500 focus:border-red-500 focus:ring-red-500",
+ <div
+ className={cn(
+ "flex flex-col",
+ !hasBusinessMessagingAccess && "cursor-pointer",
+ )}
+ >
+ <div className="flex items-center gap-2">
+ <Label htmlFor="cta-enabled">
+ Call to Action
+ </Label>
+ {!hasBusinessMessagingAccess && (
+ <CrownIcon
+ className="h-3.5 w-3.5 text-muted-foreground"
+ aria-label="Business plan feature"
+ />
+ )}
+ </div>
+ <p className="mt-1 text-xs text-muted-foreground">
+ Add a button visitors can click to open an
+ external link (e.g. book a meeting, visit your
+ website).
+ </p>
+ </div>
+ <Switch
+ id="cta-enabled"
+ checked={ctaEnabled}
+ className={
+ !hasBusinessMessagingAccess
+ ? "cursor-pointer opacity-50"
+ : undefined
+ }
+ onClick={
+ !hasBusinessMessagingAccess
+ ? (e) => {
+ e.preventDefault();
+ setUpgradeMessagingModalOpen(true);
+ }
+ : undefined
+ }
+ onCheckedChange={
+ !hasBusinessMessagingAccess
+ ? undefined
+ : (checked) => {
+ setCtaEnabled(checked);
+ if (checked && !ctaLabel.trim()) {
+ setCtaLabel("Book a call");
+ }
+ }
+ }
+ />
+ </div>
+ {ctaEnabled && (
+ <div className="space-y-3 border-t pt-4">
+ <div className="space-y-2">
+ <Label htmlFor="cta-label">Button label</Label>
+ <Input
+ id="cta-label"
+ placeholder="Book a meeting"
+ value={ctaLabel}
+ onChange={(e) =>
+ setCtaLabel(e.target.value)
+ }
+ />
+ </div>
+ <div className="space-y-2">
+ <Label htmlFor="cta-url">Link</Label>
+ <Input
+ id="cta-url"
+ placeholder="https://..."
+ value={ctaUrl}
+ onChange={(e) => setCtaUrl(e.target.value)}
+ />
+ </div>
+ <div className="space-y-2">
+ <Label htmlFor="accent-button-color">
+ Button color{" "}
+ <span className="font-normal text-muted-foreground">
+ (accent)
+ </span>
+ </Label>
+ <div className="flex items-center space-x-3">
+ <Popover>
+ <PopoverTrigger>
+ <div
+ className="h-10 w-10 cursor-pointer rounded-md border-2 border-gray-300 shadow-sm transition-all hover:border-gray-400"
+ style={{
+ backgroundColor: accentButtonColor,
+ }}
+ />
+ </PopoverTrigger>
+ <PopoverContent>
+ <HexColorPicker
+ color={accentButtonColor}
+ onChange={setAccentButtonColor}
+ />
+ </PopoverContent>
+ </Popover>
+ <HexColorInput
+ className="flex h-10 w-full rounded-md border border-gray-300 bg-background px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus:border-gray-400 focus:outline-none focus:ring-1 focus:ring-gray-400"
+ color={accentButtonColor}
+ onChange={setAccentButtonColor}
+ prefixed
+ />
+ </div>
+ </div>
+ </div>
+ )}
+ </div>
+ </CardContent>
+ </Card>
+
+ {/* Welcome Message Card (with toggle) */}
+ <Card>
+ <CardContent className="pt-6">
+ <div className="space-y-3">
+ <div
+ className="flex items-center justify-between"
+ onClick={
+ !hasBusinessMessagingAccess
+ ? () => setUpgradeMessagingModalOpen(true)
+ : undefined
+ }
+ >
+ <div
+ className={cn(
+ "flex flex-col",
+ !hasBusinessMessagingAccess && "cursor-pointer",
+ )}
+ >
+ <div className="flex items-center gap-2">
+ <Label htmlFor="welcome-enabled">
+ Welcome Message{" "}
+ <span className="font-normal text-muted-foreground">
+ (front page)
+ </span>
+ </Label>
+ {!hasBusinessMessagingAccess && (
+ <CrownIcon
+ className="h-3.5 w-3.5 text-muted-foreground"
+ aria-label="Business plan feature"
+ />
+ )}
+ </div>
+ <p className="mt-1 text-xs text-muted-foreground">
+ Shown to visitors on the access screen before
+ they see your content.
+ </p>
+ </div>
+ <Switch
+ id="welcome-enabled"
+ checked={welcomeEnabled}
+ className={
+ !hasBusinessMessagingAccess
+ ? "cursor-pointer opacity-50"
+ : undefined
+ }
+ onClick={
+ !hasBusinessMessagingAccess
+ ? (e) => {
+ e.preventDefault();
+ setUpgradeMessagingModalOpen(true);
+ }
+ : undefined
+ }
+ onCheckedChange={
+ !hasBusinessMessagingAccess
+ ? undefined
+ : (checked) => {
+ setWelcomeEnabled(checked);
+ if (checked) {
+ setPreviewTab("front-page");
+ }
+ }
+ }
+ />
+ </div>
+ {welcomeEnabled && (
+ <div className="space-y-3 border-t pt-4">
+ <div className="flex items-center justify-between">
+ <Label
+ htmlFor="welcome-message"
+ className="text-sm font-medium"
+ >
+ Message
+ </Label>
+ <span className="text-sm text-muted-foreground">
+ <span
+ className={cn(
+ welcomeMessageError && "text-red-500",
+ )}
+ >
+ {welcomeMessage.length}
+ </span>
+ /{MAX_WELCOME_MESSAGE_LENGTH}
+ </span>
+ </div>
+ <Textarea
+ id="welcome-message"
+ value={welcomeMessage}
+ onChange={(e) =>
+ handleWelcomeMessageChange(e.target.value)
+ }
+ placeholder={DEFAULT_WELCOME_MESSAGE}
+ className={cn(
+ "min-h-24 resize-none",
+ welcomeMessageError &&
+ "border-red-500 focus:border-red-500 focus:ring-red-500",
+ )}
+ />
+ {welcomeMessageError && (
+ <p className="text-xs text-red-500">
+ {welcomeMessageError}
+ </p>
+ )}
+ <p className="text-xs text-muted-foreground">
+ Keep the message concise — it should fit within
+ two lines for the best user experience.
+ </p>
+ </div>
+ )}
+ </div>
+ </CardContent>
+ </Card>
+
+ {/* Custom Link Preview — Open Graph defaults shared by
+ every data room and link the team creates. Per-link
+ and per-dataroom Custom Link Preview always override
+ this when enabled there. */}
+ <Card>
+ <CardContent className="pt-6">
+ {hasBusinessMessagingAccess ? (
+ <BrandingLinkPreviewForm
+ enabled={linkPreviewEnabled}
+ onEnabledChange={setLinkPreviewEnabled}
+ title={linkPreviewTitle}
+ onTitleChange={setLinkPreviewTitle}
+ description={linkPreviewDescription}
+ onDescriptionChange={setLinkPreviewDescription}
+ imageUrl={linkPreviewImage}
+ onImageChange={setLinkPreviewImage}
+ faviconUrl={linkPreviewFavicon}
+ onFaviconChange={setLinkPreviewFavicon}
+ inheritanceHint="Acts as the default for every data room and link. Per-dataroom and per-link previews still override this when enabled."
+ />
+ ) : (
+ <div
+ className="flex cursor-pointer items-center justify-between"
+ onClick={() =>
+ setUpgradeMessagingModalOpen(true)
+ }
+ >
+ <div className="flex flex-col">
+ <div className="flex items-center gap-2">
+ <Label htmlFor="link-preview-enabled-locked">
+ Custom Link Preview
+ </Label>
+ <CrownIcon
+ className="h-3.5 w-3.5 text-muted-foreground"
+ aria-label="Business plan feature"
+ />
+ </div>
+ <p className="mt-1 text-xs text-muted-foreground">
+ Default Open Graph title, description and
+ image for every link and data room — per-link
+ settings still override this.
+ </p>
+ </div>
+ <Switch
+ id="link-preview-enabled-locked"
+ checked={false}
+ className="cursor-pointer opacity-50"
+ onClick={(e) => {
+ e.preventDefault();
+ setUpgradeMessagingModalOpen(true);
+ }}
+ onCheckedChange={undefined}
+ />
+ </div>
)}
- />
- {welcomeMessageError && (
- <p className="text-xs text-red-500">
- {welcomeMessageError}
- </p>
- )}
- <p className="text-xs text-muted-foreground">
- Keep the message concise - it should fit within two
- lines for the best user experience.
- </p>
- </div>
- </CardContent>
- </Card>
- </div>
+ </CardContent>
+ </Card>
+ </div>
+ </CollapsibleBrandingSection>
+ </TabsContent>
+
+ {hasLayoutVisibility && (
+ <TabsContent
+ value="layouts"
+ className="mt-4 flex flex-col gap-6 lg:max-h-[calc(100vh-440px)] lg:overflow-y-auto lg:pr-4"
+ >
+ <Card>
+ <CardContent className="min-w-0 space-y-3 pt-6">
+ <div>
+ <Label>Default Data Room layout</Label>
+ <p className="mt-1 text-xs text-muted-foreground">
+ Choose a preset — applied to every dataroom that
+ hasn&apos;t set its own branding. Per-dataroom
+ branding always overrides this.
+ </p>
+ </div>
+ <DataroomLayoutPresetCards
+ selectedPreset={derivedLayoutPreset}
+ onSelect={applyLayoutPreset}
+ />
+ {derivedLayoutPreset === "CUSTOM" ? (
+ <p className="text-xs text-muted-foreground">
+ Custom combination — select a preset card to snap
+ back to a named layout.
+ </p>
+ ) : null}
+ </CardContent>
+ </Card>
+
+ {/* Folder tree (left navigation) */}
+ <Card>
+ <CardContent className="pt-6">
+ <div className="space-y-3">
+ <div className="flex items-center justify-between">
+ <Label htmlFor="global-show-folder-tree">
+ Navigation tree
+ </Label>
+ <Switch
+ id="global-show-folder-tree"
+ checked={showFolderTree}
+ onCheckedChange={setShowFolderTree}
+ />
+ </div>
+ <p className="text-xs text-muted-foreground">
+ Show the folder tree in the left column. When off,
+ visitors use breadcrumbs and the main area only.
+ </p>
+ </div>
+ </CardContent>
+ </Card>
+
+ {/* Card Layout */}
+ <Card>
+ <CardContent className="pt-6">
+ <div className="space-y-3">
+ <Label>Document Card Layout</Label>
+ <RadioGroup
+ value={cardLayout}
+ onValueChange={(v) =>
+ setCardLayout(v as DataroomCardLayout)
+ }
+ className="grid grid-cols-3 gap-2"
+ >
+ {CARD_LAYOUT_OPTIONS.map((opt) => (
+ <Label
+ key={opt.value}
+ htmlFor={`global-card-layout-${opt.value}`}
+ className={cn(
+ "flex cursor-pointer items-center gap-2 rounded-md border border-gray-200 px-3 py-2 text-xs",
+ cardLayout === opt.value &&
+ "border-black bg-gray-50",
+ )}
+ >
+ <RadioGroupItem
+ value={opt.value}
+ id={`global-card-layout-${opt.value}`}
+ />
+ {opt.label}
+ </Label>
+ ))}
+ </RadioGroup>
+ </div>
+ </CardContent>
+ </Card>
+ </TabsContent>
+ )}
+ </Tabs>
{/* Action Buttons - Always Visible */}
<div className="flex items-center gap-4 border-t bg-background pt-4">
@@ -749,13 +1591,23 @@ export default function Branding() {
text="Save changes"
clickedPlan={PlanEnum.Pro}
trigger="branding_page"
- highlightItem={["custom-branding", "custom-domain", "custom-social-cards"]}
+ highlightItem={["custom-branding", "custom-branding-bundle"]}
+ />
+ ) : layoutBlocksSave ? (
+ <UpgradeButton
+ text="Save changes"
+ clickedPlan={PlanEnum.DataRooms}
+ trigger="global_branding_layouts_save"
+ highlightItem={["dataroom-viewer-layouts"]}
+ hideItems={["datarooms"]}
/>
) : (
<Button
onClick={saveBranding}
loading={isLoading}
- disabled={!!welcomeMessageError}
+ disabled={
+ hasBusinessMessagingAccess && !!welcomeMessageError
+ }
className="bg-black text-white hover:bg-gray-800"
>
Save changes
@@ -769,6 +1621,26 @@ export default function Branding() {
Reset branding
</Button>
</div>
+ <UpgradePlanModal
+ clickedPlan={PlanEnum.DataRooms}
+ trigger="global_branding_layouts_save"
+ highlightItem={["dataroom-viewer-layouts"]}
+ hideItems={["datarooms"]}
+ open={upgradeLayoutsModalOpen}
+ setOpen={setUpgradeLayoutsModalOpen}
+ />
+ <UpgradePlanModal
+ clickedPlan={PlanEnum.Business}
+ trigger="global_branding_messaging_save"
+ highlightItem={[
+ "custom-welcome-message",
+ "custom-cta",
+ "custom-social-cards",
+ "custom-domain",
+ ]}
+ open={upgradeMessagingModalOpen}
+ setOpen={setUpgradeMessagingModalOpen}
+ />
</div>
{/* Separator Line */}
@@ -776,12 +1648,18 @@ export default function Branding() {
{/* Preview Column */}
<div className="flex-1 lg:pl-4">
- <Tabs defaultValue="document-view" className="w-full">
+ <Tabs
+ value={previewTab}
+ onValueChange={setPreviewTab}
+ className="w-full"
+ >
<div className="w-full overflow-x-auto">
<TabsList
className={cn(
- "grid w-full",
- hasDataroomAccess ? "grid-cols-3" : "grid-cols-2",
+ "grid w-full gap-1",
+ mainPreviewTabCount === 3 &&
+ "grid-cols-1 sm:grid-cols-3",
+ mainPreviewTabCount === 2 && "grid-cols-2",
)}
>
<TabsTrigger value="document-view">
@@ -845,10 +1723,10 @@ export default function Branding() {
<div className="relative min-h-0 flex-1 overflow-x-auto">
<div className="relative h-full max-w-[1396px]">
<iframe
- key={`document-view-${debouncedBrandColor}-${debouncedAccentColor}`}
+ key={`document-view-${debouncedBrandColor}-${debouncedAccentColor}-${debouncedAccentButtonColor}-${previewCtaLabel}-${previewCtaUrl}`}
name="document-view"
id="document-view"
- src={`/nav_ppreview_demo?brandColor=${encodeURIComponent(debouncedBrandColor)}&accentColor=${encodeURIComponent(debouncedAccentColor)}&brandLogo=${blobUrl ? encodeURIComponent(blobUrl) : logo ? encodeURIComponent(logo) : ""}`}
+ src={`/nav_ppreview_demo?brandColor=${encodeURIComponent(debouncedBrandColor)}&accentColor=${encodeURIComponent(debouncedAccentColor)}&brandLogo=${blobUrl ? encodeURIComponent(blobUrl) : logo ? encodeURIComponent(logo) : ""}&accentButtonColor=${encodeURIComponent(debouncedAccentButtonColor)}&ctaLabel=${encodeURIComponent(previewCtaLabel)}&ctaUrl=${encodeURIComponent(previewCtaUrl)}`}
className="absolute left-0 top-0 h-full w-full origin-top-left scale-50 overflow-hidden rounded-b-lg border-0 bg-white"
style={{
width: "200%",
@@ -913,10 +1791,10 @@ export default function Branding() {
<div className="relative min-h-0 flex-1 overflow-x-auto">
<div className="relative h-full max-w-[1396px]">
<iframe
- key={`dataroom-view-${debouncedBrandColor}-${debouncedAccentColor}-${banner}-${applyAccentColorToDataroomView}`}
+ key={`dataroom-view-${debouncedBrandColor}-${debouncedAccentColor}-${debouncedAccentButtonColor}-${banner}-${applyAccentColorToDataroomView}-${previewCtaLabel}-${previewCtaUrl}-${cardLayout}-${showFolderTree}-${viewerHeaderStyle}-${hideFolderIconsInMain}`}
name="dataroom-view"
id="dataroom-view"
- src={`/room_ppreview_demo?brandColor=${encodeURIComponent(debouncedBrandColor)}&accentColor=${encodeURIComponent(debouncedAccentColor)}&applyAccentColorToDataroomView=${applyAccentColorToDataroomView ? "1" : "0"}&brandLogo=${blobUrl ? encodeURIComponent(blobUrl) : logo ? encodeURIComponent(logo) : ""}&brandBanner=${banner === "no-banner" ? encodeURIComponent("no-banner") : bannerBlobUrl ? encodeURIComponent(bannerBlobUrl) : banner ? encodeURIComponent(banner) : ""}`}
+ src={`/room_ppreview_demo?brandColor=${encodeURIComponent(debouncedBrandColor)}&accentColor=${encodeURIComponent(debouncedAccentColor)}&applyAccentColorToDataroomView=${applyAccentColorToDataroomView ? "1" : "0"}&brandLogo=${blobUrl ? encodeURIComponent(blobUrl) : logo ? encodeURIComponent(logo) : ""}&brandBanner=${banner === "no-banner" ? encodeURIComponent("no-banner") : bannerBlobUrl ? encodeURIComponent(bannerBlobUrl) : banner ? encodeURIComponent(banner) : ""}&accentButtonColor=${encodeURIComponent(debouncedAccentButtonColor)}&ctaLabel=${encodeURIComponent(previewCtaLabel)}&ctaUrl=${encodeURIComponent(previewCtaUrl)}&cardLayout=${encodeURIComponent(cardLayout)}&showFolderTree=${showFolderTree ? "1" : "0"}&viewerHeaderStyle=${encodeURIComponent(viewerHeaderStyle)}&hideFolderIconsInMain=${hideFolderIconsInMain ? "1" : "0"}`}
className="absolute left-0 top-0 h-full w-full origin-top-left scale-50 overflow-hidden rounded-b-lg border-0 bg-white"
style={{
width: "200%",
@@ -981,10 +1859,10 @@ export default function Branding() {
<div className="relative min-h-0 flex-1 overflow-x-auto">
<div className="relative h-full max-w-[1396px]">
<iframe
- key={`access-screen-${debouncedBrandColor}-${debouncedAccentColor}-${debouncedWelcomeMessage}`}
+ key={`access-screen-${debouncedBrandColor}-${debouncedAccentColor}-${previewWelcomeMessage}`}
name="access-screen"
id="access-screen"
- src={`/entrance_ppreview_demo?brandColor=${encodeURIComponent(debouncedBrandColor)}&accentColor=${encodeURIComponent(debouncedAccentColor)}&brandLogo=${blobUrl ? encodeURIComponent(blobUrl) : logo ? encodeURIComponent(logo) : ""}&welcomeMessage=${encodeURIComponent(debouncedWelcomeMessage)}`}
+ src={`/entrance_ppreview_demo?brandColor=${encodeURIComponent(debouncedBrandColor)}&accentColor=${encodeURIComponent(debouncedAccentColor)}&brandLogo=${blobUrl ? encodeURIComponent(blobUrl) : logo ? encodeURIComponent(logo) : ""}&welcomeMessage=${encodeURIComponent(previewWelcomeMessage)}`}
className="absolute left-0 top-0 h-full w-full origin-top-left scale-50 overflow-hidden rounded-b-lg border-0 bg-white"
style={{
width: "200%",
diff --git a/pages/datarooms/[id]/branding/index.tsx b/pages/datarooms/[id]/branding/index.tsx
index 86e7dd53..ef8e13ca 100644
--- a/pages/datarooms/[id]/branding/index.tsx
+++ b/pages/datarooms/[id]/branding/index.tsx
@@ -1,38 +1,66 @@
-import { useRouter } from "next/router";
-
-import { useCallback, useEffect, useState } from "react";
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import { PlanEnum } from "@/ee/stripe/constants";
import { useTeam } from "@/context/team-context";
-import { Check, CircleHelpIcon, UploadIcon } from "lucide-react";
+import {
+ Check,
+ CircleHelpIcon,
+ CrownIcon,
+ UploadIcon,
+} from "lucide-react";
import { HexColorInput, HexColorPicker } from "react-colorful";
import sanitizeHtml from "sanitize-html";
import { toast } from "sonner";
import { mutate } from "swr";
import { useDebounce } from "use-debounce";
+import { usePlan } from "@/lib/swr/use-billing";
import { useBrand, useDataroomBrand } from "@/lib/swr/use-brand";
import { useDataroom } from "@/lib/swr/use-dataroom";
import { cn, convertDataUrlToFile, uploadImage } from "@/lib/utils";
+import {
+ CARD_LAYOUT_OPTIONS,
+ asDataroomCardLayout,
+ asDataroomViewerHeaderStyle,
+ inferDataroomViewerLayoutPreset,
+ type DataroomCardLayout,
+ type DataroomLayoutCardId,
+ type DataroomViewerHeaderStyle,
+} from "@/ee/features/branding/lib/dataroom-viewer-layout";
+import { UpgradePlanModal } from "@/components/billing/upgrade-plan-modal";
+import { BannerEditor } from "@/ee/features/branding/components/banner-editor";
+import { CollapsibleBrandingSection } from "@/ee/features/branding/components/collapsible-branding-section";
+import { DataroomLayoutPresetCards } from "@/ee/features/branding/components/dataroom-layout-preset-cards";
+import { BrandingLinkPreviewForm } from "@/ee/features/branding/components/branding-link-preview-form";
+import { BrandingSocialPreviewReadonly } from "@/ee/features/branding/components/branding-social-preview-readonly";
+import { DataroomBannerMedia } from "@/components/view/dataroom/dataroom-banner-media";
import AppLayout from "@/components/layouts/app";
import { Button } from "@/components/ui/button";
import { Card, CardContent } from "@/components/ui/card";
import { Checkbox } from "@/components/ui/checkbox";
+import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/components/ui/popover";
+import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
+import { Switch } from "@/components/ui/switch";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Textarea } from "@/components/ui/textarea";
+import { UpgradeButton } from "@/components/ui/upgrade-button";
import { BadgeTooltip } from "@/components/ui/tooltip";
-
const DEFAULT_BANNER_IMAGE = "/_static/papermark-banner.png";
export default function DataroomBrandPage() {
- const router = useRouter();
const teamInfo = useTeam();
+ const { isDatarooms, isDataroomsPlus, isTrial, isBusiness } = usePlan();
+ const hasLayoutCustomizationAccess =
+ isDatarooms || isDataroomsPlus || isTrial;
+ const hasBusinessMessagingAccess =
+ isBusiness || isDatarooms || isTrial;
const { dataroom } = useDataroom();
const { brand: dataroomBrand } = useDataroomBrand({
dataroomId: dataroom?.id,
@@ -41,6 +69,7 @@ export default function DataroomBrandPage() {
const [brandColor, setBrandColor] = useState<string>("#000000");
const [accentColor, setAccentColor] = useState<string>("#FFFFFF");
+ const [accentButtonColor, setAccentButtonColor] = useState<string>("#000000");
const [applyAccentColorToDataroomView, setApplyAccentColorToDataroomView] =
useState<boolean>(false);
const [logo, setLogo] = useState<string | null>(null);
@@ -48,12 +77,43 @@ export default function DataroomBrandPage() {
const [originalBanner, setOriginalBanner] = useState<string | null>(null);
const [blobUrl, setBlobUrl] = useState<string | null>(null);
const [bannerBlobUrl, setBannerBlobUrl] = useState<string | null>(null);
+ const DEFAULT_WELCOME_MESSAGE = "Your action is requested to continue";
const [welcomeMessage, setWelcomeMessage] = useState<string>(
- "Your action is requested to continue",
+ DEFAULT_WELCOME_MESSAGE,
+ );
+ const [welcomeEnabled, setWelcomeEnabled] = useState<boolean>(false);
+ const [linkPreviewEnabled, setLinkPreviewEnabled] = useState(false);
+ const [linkPreviewTitle, setLinkPreviewTitle] = useState("");
+ const [linkPreviewDescription, setLinkPreviewDescription] = useState("");
+ const [linkPreviewImage, setLinkPreviewImage] = useState<string | null>(null);
+ const [linkPreviewFavicon, setLinkPreviewFavicon] = useState<string | null>(
+ null,
);
+ const [previewTab, setPreviewTab] = useState<string>("dataroom-view");
+
+ // Layout customization state
+ const [showFolderTree, setShowFolderTree] = useState<boolean>(true);
+ const [cardLayout, setCardLayout] = useState<DataroomCardLayout>("LIST");
+ const [viewerHeaderStyle, setViewerHeaderStyle] =
+ useState<DataroomViewerHeaderStyle>("DEFAULT");
+ const [hideFolderIconsInMain, setHideFolderIconsInMain] =
+ useState<boolean>(false);
+ const [ctaLabel, setCtaLabel] = useState<string>("");
+ const [ctaUrl, setCtaUrl] = useState<string>("");
const [debouncedBrandColor] = useDebounce(brandColor, 300);
const [debouncedAccentColor] = useDebounce(accentColor, 300);
const [debouncedWelcomeMessage] = useDebounce(welcomeMessage, 500);
+ const [debouncedLinkPreviewTitle] = useDebounce(linkPreviewTitle, 300);
+ const [debouncedLinkPreviewDescription] = useDebounce(
+ linkPreviewDescription,
+ 300,
+ );
+ const [debouncedLinkPreviewImage] = useDebounce(linkPreviewImage, 300);
+ const [debouncedLinkPreviewFavicon] = useDebounce(linkPreviewFavicon, 300);
+ const previewWelcomeMessage =
+ hasBusinessMessagingAccess && welcomeEnabled
+ ? debouncedWelcomeMessage
+ : DEFAULT_WELCOME_MESSAGE;
const [isLoading, setIsLoading] = useState<boolean>(false);
const [fileError, setFileError] = useState<string | null>(null);
const [dragActive, setDragActive] = useState(false);
@@ -61,6 +121,176 @@ export default function DataroomBrandPage() {
null,
);
+ // Auto-fill from website (brand lookup)
+ const [autoFillUrl, setAutoFillUrl] = useState<string>("");
+ const [autoFillLoading, setAutoFillLoading] = useState<boolean>(false);
+ const [ctaEnabled, setCtaEnabled] = useState<boolean>(false);
+
+ const hasSeededNullDataroomFromGlobalRef = useRef(false);
+ const lastVisibleBannerRef = useRef<string | null>(null);
+
+ // Snapshot of layout fields at last load, used to detect "unsaved layout changes"
+ // for the upgrade gate when the team is below the Data Rooms tier.
+ const initialLayoutSnapshotRef = useRef<{
+ cardLayout: DataroomCardLayout;
+ showFolderTree: boolean;
+ viewerHeaderStyle: DataroomViewerHeaderStyle;
+ hideFolderIconsInMain: boolean;
+ } | null>(null);
+
+ const [upgradeLayoutsModalOpen, setUpgradeLayoutsModalOpen] =
+ useState<boolean>(false);
+ const [upgradeMessagingModalOpen, setUpgradeMessagingModalOpen] =
+ useState<boolean>(false);
+
+ useEffect(() => {
+ if (banner && banner !== "no-banner") {
+ lastVisibleBannerRef.current = banner;
+ }
+ }, [banner]);
+
+ // Revoke object URLs whenever they're replaced or the component unmounts to
+ // avoid leaking blob storage across re-uploads and navigations.
+ useEffect(() => {
+ if (!blobUrl) return;
+ return () => {
+ URL.revokeObjectURL(blobUrl);
+ };
+ }, [blobUrl]);
+
+ useEffect(() => {
+ if (!bannerBlobUrl) return;
+ return () => {
+ URL.revokeObjectURL(bannerBlobUrl);
+ };
+ }, [bannerBlobUrl]);
+
+ const derivedLayoutPreset = useMemo(
+ () =>
+ inferDataroomViewerLayoutPreset({
+ cardLayout,
+ showFolderTree,
+ hideFolderIconsInMain,
+ viewerHeaderStyle,
+ }),
+ [cardLayout, showFolderTree, hideFolderIconsInMain, viewerHeaderStyle],
+ );
+
+ const layoutHasUnsavedChanges = useMemo(() => {
+ const initial = initialLayoutSnapshotRef.current;
+ if (!initial) return false;
+ return (
+ initial.cardLayout !== cardLayout ||
+ initial.showFolderTree !== showFolderTree ||
+ initial.viewerHeaderStyle !== viewerHeaderStyle ||
+ initial.hideFolderIconsInMain !== hideFolderIconsInMain
+ );
+ }, [cardLayout, showFolderTree, viewerHeaderStyle, hideFolderIconsInMain]);
+
+ const layoutBlocksSave =
+ !hasLayoutCustomizationAccess && layoutHasUnsavedChanges;
+
+ const applyLayoutPreset = (id: DataroomLayoutCardId) => {
+ const restoreBanner = () =>
+ lastVisibleBannerRef.current ??
+ (originalBanner && originalBanner !== "no-banner"
+ ? originalBanner
+ : null) ??
+ DEFAULT_BANNER_IMAGE;
+
+ switch (id) {
+ case "STANDARD":
+ setBanner(restoreBanner());
+ setCardLayout("LIST");
+ setShowFolderTree(true);
+ setViewerHeaderStyle("DEFAULT");
+ setHideFolderIconsInMain(false);
+ break;
+ case "STRICT":
+ if (banner !== "no-banner") {
+ lastVisibleBannerRef.current = banner;
+ }
+ setBanner("no-banner");
+ setCardLayout("COMPACT");
+ setShowFolderTree(false);
+ setViewerHeaderStyle("DEFAULT");
+ setHideFolderIconsInMain(true);
+ break;
+ case "MODERN":
+ setBanner(restoreBanner());
+ setCardLayout("COMPACT");
+ setShowFolderTree(false);
+ setViewerHeaderStyle("SPLIT");
+ setHideFolderIconsInMain(true);
+ break;
+ case "NOTION":
+ setBanner(restoreBanner());
+ setCardLayout("GRID");
+ setShowFolderTree(false);
+ setViewerHeaderStyle("NOTION");
+ setHideFolderIconsInMain(false);
+ break;
+ default:
+ break;
+ }
+ };
+
+ useEffect(() => {
+ hasSeededNullDataroomFromGlobalRef.current = false;
+ }, [dataroom?.id]);
+
+ const handleAutoFill = async () => {
+ if (!autoFillUrl.trim()) return;
+ setAutoFillLoading(true);
+ try {
+ const res = await fetch("/api/branding/auto-fill", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ url: autoFillUrl.trim() }),
+ });
+ const data = await res.json();
+ if (!res.ok) {
+ toast.error(data.error || "Could not load brand");
+ return;
+ }
+ let applied = 0;
+ if (data.logo) {
+ setLogo(data.logo);
+ setBlobUrl(null);
+ applied++;
+ }
+ if (data.banner) {
+ setBanner(data.banner);
+ setOriginalBanner(data.banner);
+ setBannerBlobUrl(null);
+ applied++;
+ }
+ if (data.brandColor) {
+ setBrandColor(data.brandColor);
+ applied++;
+ }
+ if (data.accentColor) {
+ setAccentColor(data.accentColor);
+ applied++;
+ }
+ if (data.accentButtonColor) {
+ setAccentButtonColor(data.accentButtonColor);
+ applied++;
+ }
+ if (applied === 0) {
+ toast.warning("No brand data found for that website");
+ } else {
+ toast.success(
+ `Loaded ${data.name ?? data.domain}. Review and click Save changes.`,
+ );
+ }
+ } catch (err) {
+ toast.error("Lookup failed");
+ } finally {
+ setAutoFillLoading(false);
+ }
+ };
+
// Welcome message validation
const MAX_WELCOME_MESSAGE_LENGTH = 80; // Roughly 2 lines of text
@@ -141,34 +371,183 @@ export default function DataroomBrandPage() {
);
useEffect(() => {
- // Merge dataroom brand with global brand as fallback
- if (dataroomBrand || globalBrand) {
+ if (dataroomBrand === undefined) return;
+
+ if (dataroomBrand) {
setBrandColor(
- dataroomBrand?.brandColor || globalBrand?.brandColor || "#000000",
+ dataroomBrand.brandColor || globalBrand?.brandColor || "#000000",
);
setAccentColor(
- dataroomBrand?.accentColor || globalBrand?.accentColor || "#FFFFFF",
+ dataroomBrand.accentColor || globalBrand?.accentColor || "#FFFFFF",
+ );
+ setAccentButtonColor(
+ (dataroomBrand as any)?.accentButtonColor ||
+ (globalBrand as any)?.accentButtonColor ||
+ dataroomBrand.brandColor ||
+ globalBrand?.brandColor ||
+ "#000000",
);
setApplyAccentColorToDataroomView(
(dataroomBrand as any)?.applyAccentColorToDataroomView ??
(globalBrand as any)?.applyAccentColorToDataroomView ??
false,
);
- setLogo(dataroomBrand?.logo || globalBrand?.logo || null);
- const bannerValue = dataroomBrand?.banner || globalBrand?.banner || null;
+ setLogo(dataroomBrand.logo || globalBrand?.logo || null);
+ const bannerValue = dataroomBrand.banner || globalBrand?.banner || null;
setBanner(bannerValue);
setOriginalBanner(bannerValue);
- const message =
- dataroomBrand?.welcomeMessage ||
- globalBrand?.welcomeMessage ||
- "Your action is requested to continue";
+ const savedMessage =
+ dataroomBrand.welcomeMessage ?? globalBrand?.welcomeMessage ?? null;
+ const message = savedMessage || DEFAULT_WELCOME_MESSAGE;
setWelcomeMessage(message);
- // Validate existing message
+ setWelcomeEnabled(
+ !!savedMessage && savedMessage !== DEFAULT_WELCOME_MESSAGE,
+ );
const error = validateWelcomeMessage(message);
setWelcomeMessageError(error);
+ const initialShowFolderTree = dataroomBrand.showFolderTree ?? true;
+ const initialCardLayout = asDataroomCardLayout(dataroomBrand.cardLayout);
+ const initialViewerHeaderStyle = asDataroomViewerHeaderStyle(
+ (dataroomBrand as any).viewerHeaderStyle,
+ );
+ const initialHideFolderIconsInMain = Boolean(
+ (dataroomBrand as any).hideFolderIconsInMain,
+ );
+ setShowFolderTree(initialShowFolderTree);
+ setCardLayout(initialCardLayout);
+ setViewerHeaderStyle(initialViewerHeaderStyle);
+ setHideFolderIconsInMain(initialHideFolderIconsInMain);
+ initialLayoutSnapshotRef.current = {
+ cardLayout: initialCardLayout,
+ showFolderTree: initialShowFolderTree,
+ viewerHeaderStyle: initialViewerHeaderStyle,
+ hideFolderIconsInMain: initialHideFolderIconsInMain,
+ };
+ const initialCtaLabel =
+ dataroomBrand.ctaLabel ?? (globalBrand as any)?.ctaLabel ?? "";
+ const initialCtaUrl =
+ dataroomBrand.ctaUrl ?? (globalBrand as any)?.ctaUrl ?? "";
+ setCtaLabel(initialCtaLabel);
+ setCtaUrl(initialCtaUrl);
+ setCtaEnabled(!!(initialCtaLabel || initialCtaUrl));
+ setLinkPreviewEnabled(
+ (dataroomBrand as any)?.customLinkPreviewEnabled === true,
+ );
+ setLinkPreviewTitle((dataroomBrand as any)?.linkPreviewTitle ?? "");
+ setLinkPreviewDescription(
+ (dataroomBrand as any)?.linkPreviewDescription ?? "",
+ );
+ setLinkPreviewImage((dataroomBrand as any)?.linkPreviewImage ?? null);
+ setLinkPreviewFavicon((dataroomBrand as any)?.linkPreviewFavicon ?? null);
+ return;
+ }
+
+ // No dataroom row yet (or cleared). Wait for team brand so we do not flash
+ // empty values before global defaults are known.
+ if (globalBrand === undefined) return;
+
+ if (hasSeededNullDataroomFromGlobalRef.current) return;
+ hasSeededNullDataroomFromGlobalRef.current = true;
+
+ if (globalBrand) {
+ setBrandColor(globalBrand.brandColor || "#000000");
+ setAccentColor(globalBrand.accentColor || "#FFFFFF");
+ setAccentButtonColor(
+ (globalBrand as any)?.accentButtonColor ||
+ globalBrand.brandColor ||
+ "#000000",
+ );
+ setApplyAccentColorToDataroomView(
+ (globalBrand as any)?.applyAccentColorToDataroomView ?? false,
+ );
+ setLogo(globalBrand.logo || null);
+ const bannerValue = globalBrand.banner || null;
+ setBanner(bannerValue);
+ setOriginalBanner(bannerValue);
+ const savedMessage = globalBrand.welcomeMessage ?? null;
+ const message = savedMessage || DEFAULT_WELCOME_MESSAGE;
+ setWelcomeMessage(message);
+ setWelcomeEnabled(
+ !!savedMessage && savedMessage !== DEFAULT_WELCOME_MESSAGE,
+ );
+ setWelcomeMessageError(validateWelcomeMessage(message));
+ // Layouts inherit from the team brand exactly like colors / logo / CTA.
+ // Once the user saves anything here a DataroomBrand row is created and
+ // those persisted values win, but until then we mirror the team
+ // defaults so a new dataroom doesn't reset to "Standard".
+ const inheritedCardLayout = asDataroomCardLayout(
+ (globalBrand as any)?.cardLayout,
+ );
+ const inheritedShowFolderTree =
+ (globalBrand as any)?.showFolderTree ?? true;
+ const inheritedViewerHeaderStyle = asDataroomViewerHeaderStyle(
+ (globalBrand as any)?.viewerHeaderStyle,
+ );
+ const inheritedHideFolderIconsInMain = Boolean(
+ (globalBrand as any)?.hideFolderIconsInMain,
+ );
+ setShowFolderTree(inheritedShowFolderTree);
+ setCardLayout(inheritedCardLayout);
+ setViewerHeaderStyle(inheritedViewerHeaderStyle);
+ setHideFolderIconsInMain(inheritedHideFolderIconsInMain);
+ initialLayoutSnapshotRef.current = {
+ cardLayout: inheritedCardLayout,
+ showFolderTree: inheritedShowFolderTree,
+ viewerHeaderStyle: inheritedViewerHeaderStyle,
+ hideFolderIconsInMain: inheritedHideFolderIconsInMain,
+ };
+ const initialCtaLabel = (globalBrand as any)?.ctaLabel ?? "";
+ const initialCtaUrl = (globalBrand as any)?.ctaUrl ?? "";
+ setCtaLabel(initialCtaLabel);
+ setCtaUrl(initialCtaUrl);
+ setCtaEnabled(!!(initialCtaLabel || initialCtaUrl));
+ setLinkPreviewEnabled(
+ (globalBrand as any)?.customLinkPreviewEnabled === true,
+ );
+ setLinkPreviewTitle((globalBrand as any)?.linkPreviewTitle ?? "");
+ setLinkPreviewDescription(
+ (globalBrand as any)?.linkPreviewDescription ?? "",
+ );
+ setLinkPreviewImage((globalBrand as any)?.linkPreviewImage ?? null);
+ setLinkPreviewFavicon((globalBrand as any)?.linkPreviewFavicon ?? null);
+ } else {
+ setBrandColor("#000000");
+ setAccentColor("#FFFFFF");
+ setAccentButtonColor("#000000");
+ setApplyAccentColorToDataroomView(false);
+ setLogo(null);
+ setBanner(DEFAULT_BANNER_IMAGE);
+ setOriginalBanner(DEFAULT_BANNER_IMAGE);
+ setWelcomeMessage(DEFAULT_WELCOME_MESSAGE);
+ setWelcomeEnabled(false);
+ setWelcomeMessageError(null);
+ setShowFolderTree(true);
+ setCardLayout("LIST");
+ setViewerHeaderStyle("DEFAULT");
+ setHideFolderIconsInMain(false);
+ initialLayoutSnapshotRef.current = {
+ cardLayout: "LIST",
+ showFolderTree: true,
+ viewerHeaderStyle: "DEFAULT",
+ hideFolderIconsInMain: false,
+ };
+ setCtaLabel("");
+ setCtaUrl("");
+ setCtaEnabled(false);
+ setLinkPreviewEnabled(false);
+ setLinkPreviewTitle("");
+ setLinkPreviewDescription("");
+ setLinkPreviewImage(null);
+ setLinkPreviewFavicon(null);
}
}, [dataroomBrand, globalBrand]);
+ useEffect(() => {
+ if (!linkPreviewEnabled && previewTab === "shared-link-preview") {
+ setPreviewTab("dataroom-view");
+ }
+ }, [linkPreviewEnabled, previewTab]);
+
// Handle welcome message change with validation
const handleWelcomeMessageChange = (value: string) => {
setWelcomeMessage(value);
@@ -183,14 +562,24 @@ export default function DataroomBrandPage() {
const saveBranding = async (e: any) => {
e.preventDefault();
- // Validate welcome message before saving
- const welcomeError = validateWelcomeMessage(welcomeMessage);
- if (welcomeError) {
- setWelcomeMessageError(welcomeError);
- toast.error("Please fix the validation errors before saving");
+ // Block save and prompt for upgrade if the user changed any layout settings
+ // without an eligible plan. Branding-only changes (colors, banner, logo)
+ // still flow through.
+ if (layoutBlocksSave) {
+ setUpgradeLayoutsModalOpen(true);
return;
}
+ // Validate welcome message before saving
+ if (hasBusinessMessagingAccess) {
+ const welcomeError = validateWelcomeMessage(welcomeMessage);
+ if (welcomeError) {
+ setWelcomeMessageError(welcomeError);
+ toast.error("Please fix the validation errors before saving");
+ return;
+ }
+ }
+
setIsLoading(true);
// Upload the image if it's a data URL
@@ -217,14 +606,62 @@ export default function DataroomBrandPage() {
bannerBlobUrl = "no-banner";
}
+ let linkPreviewImageUrl: string | null =
+ linkPreviewImage && linkPreviewImage.startsWith("data:")
+ ? null
+ : linkPreviewImage;
+ if (linkPreviewImage?.startsWith("data:")) {
+ const blob = convertDataUrlToFile({ dataUrl: linkPreviewImage });
+ linkPreviewImageUrl = await uploadImage(blob);
+ setLinkPreviewImage(linkPreviewImageUrl);
+ }
+
+ let linkPreviewFaviconUrl: string | null =
+ linkPreviewFavicon && linkPreviewFavicon.startsWith("data:")
+ ? null
+ : linkPreviewFavicon;
+ if (linkPreviewFavicon?.startsWith("data:")) {
+ const blob = convertDataUrlToFile({ dataUrl: linkPreviewFavicon });
+ linkPreviewFaviconUrl = await uploadImage(blob);
+ setLinkPreviewFavicon(linkPreviewFaviconUrl);
+ }
+
const data = {
- welcomeMessage:
- welcomeMessage.trim() || "Your action is requested to continue",
+ welcomeMessage: hasBusinessMessagingAccess
+ ? welcomeEnabled
+ ? welcomeMessage.trim() || DEFAULT_WELCOME_MESSAGE
+ : null
+ : ((dataroomBrand as any)?.welcomeMessage ?? null),
brandColor: brandColor,
accentColor: accentColor,
+ accentButtonColor: accentButtonColor,
applyAccentColorToDataroomView,
logo: blobUrl,
banner: bannerBlobUrl,
+ cardLayout,
+ showFolderTree,
+ viewerLayoutPreset: derivedLayoutPreset,
+ viewerHeaderStyle,
+ hideFolderIconsInMain,
+ ctaLabel: hasBusinessMessagingAccess
+ ? ctaEnabled
+ ? ctaLabel.trim() || null
+ : null
+ : ((dataroomBrand as any)?.ctaLabel ?? null),
+ ctaUrl: hasBusinessMessagingAccess
+ ? ctaEnabled
+ ? ctaUrl.trim() || null
+ : null
+ : ((dataroomBrand as any)?.ctaUrl ?? null),
+ customLinkPreviewEnabled: linkPreviewEnabled,
+ linkPreviewTitle: linkPreviewEnabled
+ ? linkPreviewTitle.trim() || null
+ : null,
+ linkPreviewDescription: linkPreviewEnabled
+ ? linkPreviewDescription.trim() || null
+ : null,
+ linkPreviewImage: linkPreviewEnabled ? linkPreviewImageUrl : null,
+ linkPreviewFavicon: linkPreviewEnabled ? linkPreviewFaviconUrl : null,
};
const res = await fetch(
@@ -261,39 +698,147 @@ export default function DataroomBrandPage() {
},
);
if (res.ok) {
- setLogo(null);
- setBanner(DEFAULT_BANNER_IMAGE);
- setOriginalBanner(DEFAULT_BANNER_IMAGE);
- setBrandColor("#000000");
+ hasSeededNullDataroomFromGlobalRef.current = true;
+ await mutate(
+ `/api/teams/${teamInfo?.currentTeam?.id}/datarooms/${dataroom.id}/branding`,
+ null,
+ { revalidate: false },
+ );
+
+ // Rehydrate from the team/global brand instead of fixed defaults so the
+ // UI mirrors inherited branding immediately after the dataroom row is
+ // cleared (matches the seed-from-global effect above).
+ const inheritedBanner =
+ globalBrand?.banner ?? DEFAULT_BANNER_IMAGE;
+ const inheritedCardLayout = asDataroomCardLayout(
+ (globalBrand as any)?.cardLayout,
+ );
+ const inheritedShowFolderTree =
+ (globalBrand as any)?.showFolderTree ?? true;
+ const inheritedViewerHeaderStyle = asDataroomViewerHeaderStyle(
+ (globalBrand as any)?.viewerHeaderStyle,
+ );
+ const inheritedHideFolderIconsInMain = Boolean(
+ (globalBrand as any)?.hideFolderIconsInMain,
+ );
+ const inheritedCtaLabel = (globalBrand as any)?.ctaLabel ?? "";
+ const inheritedCtaUrl = (globalBrand as any)?.ctaUrl ?? "";
+ const inheritedWelcomeSaved = globalBrand?.welcomeMessage ?? null;
+ const inheritedWelcomeMessage =
+ inheritedWelcomeSaved || DEFAULT_WELCOME_MESSAGE;
+
+ setLogo(globalBrand?.logo ?? null);
+ setBanner(inheritedBanner);
+ setOriginalBanner(inheritedBanner);
+ setBrandColor(globalBrand?.brandColor ?? "#000000");
+ setAccentColor(globalBrand?.accentColor ?? "#FFFFFF");
+ setAccentButtonColor(
+ (globalBrand as any)?.accentButtonColor ??
+ globalBrand?.brandColor ??
+ "#000000",
+ );
setApplyAccentColorToDataroomView(
(globalBrand as any)?.applyAccentColorToDataroomView ?? false,
);
+ setShowFolderTree(inheritedShowFolderTree);
+ setCardLayout(inheritedCardLayout);
+ setViewerHeaderStyle(inheritedViewerHeaderStyle);
+ setHideFolderIconsInMain(inheritedHideFolderIconsInMain);
+ initialLayoutSnapshotRef.current = {
+ cardLayout: inheritedCardLayout,
+ showFolderTree: inheritedShowFolderTree,
+ viewerHeaderStyle: inheritedViewerHeaderStyle,
+ hideFolderIconsInMain: inheritedHideFolderIconsInMain,
+ };
+ setCtaLabel(inheritedCtaLabel);
+ setCtaUrl(inheritedCtaUrl);
+ setCtaEnabled(!!(inheritedCtaLabel || inheritedCtaUrl));
+ setWelcomeMessage(inheritedWelcomeMessage);
+ setWelcomeEnabled(
+ !!inheritedWelcomeSaved &&
+ inheritedWelcomeSaved !== DEFAULT_WELCOME_MESSAGE,
+ );
+ setWelcomeMessageError(validateWelcomeMessage(inheritedWelcomeMessage));
+ setLinkPreviewEnabled(
+ (globalBrand as any)?.customLinkPreviewEnabled === true,
+ );
+ setLinkPreviewTitle((globalBrand as any)?.linkPreviewTitle ?? "");
+ setLinkPreviewDescription(
+ (globalBrand as any)?.linkPreviewDescription ?? "",
+ );
+ setLinkPreviewImage((globalBrand as any)?.linkPreviewImage ?? null);
+ setLinkPreviewFavicon((globalBrand as any)?.linkPreviewFavicon ?? null);
setIsLoading(false);
toast.success("Branding reset successfully");
- router.reload();
+ } else {
+ setIsLoading(false);
+ toast.error("Failed to reset branding");
}
};
+ // Build preview iframe URL with all branding + layout params so the embedded
+ // demo page can render an accurate preview.
+ const buildPreviewQuery = () => {
+ const params = new URLSearchParams();
+ params.set("brandColor", debouncedBrandColor);
+ params.set("accentColor", debouncedAccentColor);
+ params.set(
+ "applyAccentColorToDataroomView",
+ applyAccentColorToDataroomView ? "1" : "0",
+ );
+ const logoSrc = blobUrl || logo || "";
+ if (logoSrc) params.set("brandLogo", logoSrc);
+ const bannerSrc =
+ banner === "no-banner"
+ ? "no-banner"
+ : bannerBlobUrl || banner || "";
+ if (bannerSrc) params.set("brandBanner", bannerSrc);
+ params.set("cardLayout", cardLayout);
+ params.set("showFolderTree", showFolderTree ? "1" : "0");
+ // When the toggle is on we always render a preview button so the user can
+ // see the styling, even before they type a label/url. Real viewers still
+ // require both fields.
+ if (hasBusinessMessagingAccess && ctaEnabled) {
+ params.set("ctaLabel", ctaLabel.trim() || "Book a call");
+ params.set("ctaUrl", ctaUrl.trim() || "#");
+ }
+ if (accentButtonColor) params.set("accentButtonColor", accentButtonColor);
+ params.set("viewerHeaderStyle", viewerHeaderStyle);
+ params.set("hideFolderIconsInMain", hideFolderIconsInMain ? "1" : "0");
+ return params.toString();
+ };
+
return (
<AppLayout>
<div className="relative mx-2 mb-10 mt-4 space-y-8 px-1 sm:mx-3 md:mx-5 md:mt-5 lg:mx-7 lg:mt-8 xl:mx-10">
<div className="mb-4 flex items-center justify-between md:mb-8 lg:mb-12">
- <div className="space-y-1">
+ <div className="max-w-3xl space-y-2">
<h3 className="text-2xl font-semibold tracking-tight text-foreground">
Dataroom Branding
</h3>
- <p className="flex flex-row items-center gap-2 text-sm text-muted-foreground">
- Customize your data room&apos;s branding for a cohesive user
- experience.
- <BadgeTooltip
- linkText="Click here"
- content="How to customize data room branding?"
- key="branding"
- link="https://www.papermark.com/help/article/dataroom-branding"
- >
- <CircleHelpIcon className="h-4 w-4 shrink-0 text-muted-foreground hover:text-foreground" />
- </BadgeTooltip>
- </p>
+ <div className="text-sm text-muted-foreground">
+ <p>
+ Customize your data room&apos;s branding for a cohesive user
+ experience.{" "}
+ <BadgeTooltip
+ linkText="Click here"
+ content="How to customize data room branding?"
+ key="branding"
+ link="https://www.papermark.com/help/article/dataroom-branding"
+ >
+ <CircleHelpIcon className="inline-block h-4 w-4 shrink-0 align-text-bottom text-muted-foreground hover:text-foreground" />
+ </BadgeTooltip>{" "}
+ To build a fully whitelabeled data room via our API, CLI, and
+ MCP,{" "}
+ <a
+ href="mailto:[email protected]?subject=Whitelabeled%20data%20room%20access"
+ className="underline underline-offset-4 hover:text-foreground"
+ >
+ email support to request access
+ </a>
+ .
+ </p>
+ </div>
</div>
</div>
@@ -302,7 +847,57 @@ export default function DataroomBrandPage() {
{/* Settings Column */}
<div className="flex w-full flex-col gap-6 lg:w-[420px] lg:shrink-0">
{/* Scrollable Settings */}
- <div className="flex flex-col gap-6 lg:max-h-[calc(100vh-400px)] lg:overflow-y-auto lg:pr-4">
+ <Tabs defaultValue="branding" className="w-full">
+ <TabsList className="grid w-full grid-cols-2">
+ <TabsTrigger value="branding">Branding</TabsTrigger>
+ <TabsTrigger value="layouts" className="gap-1.5">
+ Layouts
+ <span className="inline-flex items-center rounded-[4px] bg-orange-500 px-1.5 py-0.5 text-[9px] font-semibold uppercase leading-none tracking-wide text-white">
+ New
+ </span>
+ </TabsTrigger>
+ </TabsList>
+ <TabsContent
+ value="branding"
+ className="mt-4 flex flex-col gap-6 lg:max-h-[calc(100vh-440px)] lg:overflow-y-auto lg:pr-4"
+ >
+ {/* Auto-fill from website */}
+ <Card>
+ <CardContent className="pt-6">
+ <div className="space-y-3">
+ <Label htmlFor="auto-fill-url">Auto-fill from website</Label>
+ <p className="text-xs text-muted-foreground">
+ Paste a website URL and we&apos;ll pull logo, banner and
+ brand colors automatically. You can still tweak everything
+ below before saving.
+ </p>
+ <div className="flex gap-2">
+ <Input
+ id="auto-fill-url"
+ type="text"
+ placeholder="company.com"
+ value={autoFillUrl}
+ onChange={(e) => setAutoFillUrl(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") {
+ e.preventDefault();
+ handleAutoFill();
+ }
+ }}
+ />
+ <Button
+ type="button"
+ onClick={handleAutoFill}
+ loading={autoFillLoading}
+ disabled={!autoFillUrl.trim()}
+ >
+ Fetch
+ </Button>
+ </div>
+ </div>
+ </CardContent>
+ </Card>
+
{/* Logo Card */}
<Card>
<CardContent className="pt-6">
@@ -406,143 +1001,146 @@ export default function DataroomBrandPage() {
{/* Banner Card */}
<Card>
- <CardContent className="pt-6">
- <div className="space-y-2">
- <Label htmlFor="banner">
- Banner{" "}
- <span className="font-normal text-muted-foreground">
- (max 5 MB, min. 1920×320)
- </span>
- </Label>
- <label
- htmlFor="banner"
- className="group relative mt-2 flex h-20 w-full cursor-pointer flex-col items-center justify-center rounded-lg border-2 border-dashed border-gray-300 bg-gray-50 transition-all hover:border-gray-400 hover:bg-gray-100"
- >
- <div
- className="absolute z-[5] h-full w-full rounded-lg"
- onDragOver={(e) => {
- e.preventDefault();
- e.stopPropagation();
- setDragActive(true);
- }}
- onDragEnter={(e) => {
- e.preventDefault();
- e.stopPropagation();
- setDragActive(true);
- }}
- onDragLeave={(e) => {
- e.preventDefault();
- e.stopPropagation();
- setDragActive(false);
- }}
- onDrop={(e) => {
- e.preventDefault();
- e.stopPropagation();
- setDragActive(false);
- setFileError(null);
- const file =
- e.dataTransfer.files && e.dataTransfer.files[0];
- if (file) {
- if (file.size / 1024 / 1024 > 5) {
- setFileError("File size too big (max 5MB)");
- } else if (
- file.type !== "image/png" &&
- file.type !== "image/jpeg"
- ) {
- setFileError(
- "File type not supported (.png or .jpg only)",
- );
- } else {
- const reader = new FileReader();
- reader.onload = (e) => {
- const dataUrl = e.target?.result as string;
- setBanner(dataUrl);
- // When uploading a new image, this becomes the new "original" until saved
- setOriginalBanner(dataUrl);
- const blob = convertDataUrlToFile({
- dataUrl,
- });
- const bannerBlobUrl = URL.createObjectURL(blob);
- setBannerBlobUrl(bannerBlobUrl);
- };
- reader.readAsDataURL(file);
- }
- }
- }}
- />
- {!banner || banner === DEFAULT_BANNER_IMAGE ? (
- <div
- className={cn(
- "flex flex-col items-center justify-center gap-2",
- dragActive && "scale-105",
- )}
+ <CardContent className="space-y-3 pt-6">
+ <BannerEditor
+ banner={banner}
+ setBanner={setBanner}
+ setBannerBlobUrl={setBannerBlobUrl}
+ sizeHint="(max 5 MB, min. 1920×320)"
+ defaultBannerImage={DEFAULT_BANNER_IMAGE}
+ onUrlApplied={() => {
+ // Pasting a banner URL (image/video/YouTube) is a strong
+ // signal the user wants a richer hero — auto-promote the
+ // Standard preset to Modern. Other presets stay put.
+ if (derivedLayoutPreset === "STANDARD") {
+ applyLayoutPreset("MODERN");
+ }
+ }}
+ dropZone={
+ <>
+ <label
+ htmlFor="banner"
+ className="group relative flex h-24 w-full cursor-pointer flex-col items-center justify-center rounded-lg border-2 border-dashed border-gray-300 bg-gray-50 transition-all hover:border-gray-400 hover:bg-gray-100"
>
- <UploadIcon
- className="h-8 w-8 text-gray-400"
- aria-hidden="true"
- />
- </div>
- ) : banner === "no-banner" ? (
- <div className="flex flex-col items-center justify-center gap-2">
- <p className="text-center text-sm font-medium text-gray-600">
- Banner Hidden <br />
- Upload to add banner
- </p>
- </div>
- ) : (
- <div className="relative flex h-full w-full items-center justify-center p-4">
- <img
- src={banner}
- alt="Banner preview"
- className="max-h-full max-w-full object-contain"
+ <div
+ className="absolute z-[5] h-full w-full rounded-lg"
+ onDragOver={(e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ setDragActive(true);
+ }}
+ onDragEnter={(e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ setDragActive(true);
+ }}
+ onDragLeave={(e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ setDragActive(false);
+ }}
+ onDrop={(e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ setDragActive(false);
+ setFileError(null);
+ const file =
+ e.dataTransfer.files && e.dataTransfer.files[0];
+ if (file) {
+ if (file.size / 1024 / 1024 > 5) {
+ setFileError("File size too big (max 5MB)");
+ } else if (
+ file.type !== "image/png" &&
+ file.type !== "image/jpeg"
+ ) {
+ setFileError(
+ "File type not supported (.png or .jpg only)",
+ );
+ } else {
+ const reader = new FileReader();
+ reader.onload = (e) => {
+ const dataUrl = e.target?.result as string;
+ setBanner(dataUrl);
+ setOriginalBanner(dataUrl);
+ const blob = convertDataUrlToFile({
+ dataUrl,
+ });
+ const bannerBlobUrl =
+ URL.createObjectURL(blob);
+ setBannerBlobUrl(bannerBlobUrl);
+ };
+ reader.readAsDataURL(file);
+ }
+ }
+ }}
/>
- </div>
- )}
- </label>
- <input
- id="banner"
- name="banner"
- type="file"
- accept="image/jpeg,image/png"
- className="sr-only"
- onChange={onChangeBanner}
- />
+ {!banner || banner === DEFAULT_BANNER_IMAGE ? (
+ <div
+ className={cn(
+ "flex flex-col items-center justify-center gap-2",
+ dragActive && "scale-105",
+ )}
+ >
+ <UploadIcon
+ className="h-8 w-8 text-gray-400"
+ aria-hidden="true"
+ />
+ </div>
+ ) : banner === "no-banner" ? (
+ <div className="flex flex-col items-center justify-center gap-2">
+ <p className="text-center text-sm font-medium text-gray-600">
+ Banner Hidden <br />
+ Upload to add banner
+ </p>
+ </div>
+ ) : (
+ <div className="relative h-full w-full overflow-hidden">
+ <DataroomBannerMedia
+ src={banner}
+ alt="Banner preview"
+ />
+ </div>
+ )}
+ </label>
+ <input
+ id="banner"
+ name="banner"
+ type="file"
+ accept="image/jpeg,image/png"
+ className="sr-only"
+ onChange={onChangeBanner}
+ />
+ </>
+ }
+ />
+ {banner === "no-banner" && (
+ <p className="text-xs text-muted-foreground">
+ Banner is hidden — turn it on in Layouts → Banner to show
+ it.
+ </p>
+ )}
+ {banner &&
+ banner !== "no-banner" &&
+ banner !== DEFAULT_BANNER_IMAGE &&
+ !banner.startsWith("data:") &&
+ banner !== originalBanner ? (
<div className="flex items-center gap-2">
<Button
type="button"
variant="outline"
size="sm"
- onClick={() => setBanner("no-banner")}
- className={cn(
- "text-xs",
- banner === "no-banner" && "border-black",
- )}
+ onClick={() => setBanner(originalBanner)}
+ className="text-xs"
>
- Hide Banner
+ {originalBanner === DEFAULT_BANNER_IMAGE
+ ? "Use Default Banner"
+ : "Restore Banner"}
</Button>
- {(banner === "no-banner" &&
- originalBanner !== "no-banner") ||
- (banner &&
- banner !== DEFAULT_BANNER_IMAGE &&
- !banner.startsWith("data:") &&
- banner !== originalBanner) ? (
- <Button
- type="button"
- variant="outline"
- size="sm"
- onClick={() => setBanner(originalBanner)}
- className="text-xs"
- >
- {originalBanner === DEFAULT_BANNER_IMAGE
- ? "Use Default Banner"
- : "Restore Banner"}
- </Button>
- ) : null}
</div>
- {fileError && (
- <p className="text-sm text-red-500">{fileError}</p>
- )}
- </div>
+ ) : null}
+ {fileError && (
+ <p className="text-sm text-red-500">{fileError}</p>
+ )}
</CardContent>
</Card>
@@ -683,63 +1281,426 @@ export default function DataroomBrandPage() {
</CardContent>
</Card>
- {/* Welcome Message Card */}
- <Card>
- <CardContent className="pt-6">
- <div className="space-y-3">
- <div className="flex items-center justify-between">
- <Label htmlFor="accent-color">
- Welcome Message{" "}
- <span className="font-normal text-muted-foreground">
- (front page)
- </span>
- </Label>
- <span className="text-sm text-muted-foreground">
- <span
- className={cn(welcomeMessageError && "text-red-500")}
+ <CollapsibleBrandingSection
+ title="Advanced settings"
+ defaultOpen={false}
+ >
+ <div className="flex flex-col gap-6">
+ {/* Call to Action Card (with toggle) */}
+ <Card>
+ <CardContent className="pt-6">
+ <div className="space-y-3">
+ <div
+ className="flex items-center justify-between"
+ onClick={
+ !hasBusinessMessagingAccess
+ ? () => setUpgradeMessagingModalOpen(true)
+ : undefined
+ }
>
- {welcomeMessage.length}
- </span>
- /{MAX_WELCOME_MESSAGE_LENGTH}
- </span>
- </div>
- <Textarea
- id="welcome-message"
- value={welcomeMessage}
- onChange={(e) =>
- handleWelcomeMessageChange(e.target.value)
- }
- placeholder="Your action is requested to continue"
- className={cn(
- "min-h-24 resize-none",
- welcomeMessageError &&
- "border-red-500 focus:border-red-500 focus:ring-red-500",
- )}
- />
- {welcomeMessageError && (
- <p className="text-xs text-red-500">
- {welcomeMessageError}
- </p>
- )}
- <p className="text-xs text-muted-foreground">
- Keep the message concise - it should fit within two lines
- for the best user experience.
- </p>
- </div>
- </CardContent>
- </Card>
- </div>
+ <div
+ className={cn(
+ "flex flex-col",
+ !hasBusinessMessagingAccess && "cursor-pointer",
+ )}
+ >
+ <div className="flex items-center gap-2">
+ <Label htmlFor="dataroom-cta-enabled">
+ Call to Action
+ </Label>
+ {!hasBusinessMessagingAccess && (
+ <CrownIcon
+ className="h-3.5 w-3.5 text-muted-foreground"
+ aria-label="Business plan feature"
+ />
+ )}
+ </div>
+ <p className="mt-1 text-xs text-muted-foreground">
+ Renders in the nav when enabled. Falls back to
+ global branding when off.
+ </p>
+ </div>
+ <Switch
+ id="dataroom-cta-enabled"
+ checked={ctaEnabled}
+ className={
+ !hasBusinessMessagingAccess
+ ? "cursor-pointer opacity-50"
+ : undefined
+ }
+ onClick={
+ !hasBusinessMessagingAccess
+ ? (e) => {
+ e.preventDefault();
+ setUpgradeMessagingModalOpen(true);
+ }
+ : undefined
+ }
+ onCheckedChange={
+ !hasBusinessMessagingAccess
+ ? undefined
+ : (checked) => {
+ setCtaEnabled(checked);
+ if (checked && !ctaLabel.trim()) {
+ setCtaLabel("Book a call");
+ }
+ }
+ }
+ />
+ </div>
+ {ctaEnabled && (
+ <div className="space-y-3 border-t pt-4">
+ <div className="space-y-2">
+ <Label htmlFor="dataroom-cta-label">
+ Button label
+ </Label>
+ <Input
+ id="dataroom-cta-label"
+ disabled={!hasBusinessMessagingAccess}
+ placeholder="Book a meeting"
+ value={ctaLabel}
+ onChange={(e) => setCtaLabel(e.target.value)}
+ />
+ </div>
+ <div className="space-y-2">
+ <Label htmlFor="dataroom-cta-url">Link</Label>
+ <Input
+ id="dataroom-cta-url"
+ disabled={!hasBusinessMessagingAccess}
+ placeholder="https://..."
+ value={ctaUrl}
+ onChange={(e) => setCtaUrl(e.target.value)}
+ />
+ </div>
+ <div className="space-y-2">
+ <Label htmlFor="dataroom-accent-button-color">
+ Button color{" "}
+ <span className="font-normal text-muted-foreground">
+ (accent)
+ </span>
+ </Label>
+ <div
+ className={cn(
+ "flex items-center space-x-3",
+ !hasBusinessMessagingAccess &&
+ "pointer-events-none opacity-60",
+ )}
+ >
+ <Popover>
+ <PopoverTrigger>
+ <div
+ className="h-10 w-10 cursor-pointer rounded-md border-2 border-gray-300 shadow-sm transition-all hover:border-gray-400"
+ style={{
+ backgroundColor: accentButtonColor,
+ }}
+ />
+ </PopoverTrigger>
+ <PopoverContent>
+ <HexColorPicker
+ color={accentButtonColor}
+ onChange={setAccentButtonColor}
+ />
+ </PopoverContent>
+ </Popover>
+ <HexColorInput
+ className="flex h-10 w-full rounded-md border border-gray-300 bg-background px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus:border-gray-400 focus:outline-none focus:ring-1 focus:ring-gray-400"
+ color={accentButtonColor}
+ onChange={setAccentButtonColor}
+ prefixed
+ />
+ </div>
+ </div>
+ </div>
+ )}
+ </div>
+ </CardContent>
+ </Card>
+
+ {/* Welcome Message Card (with toggle) */}
+ <Card>
+ <CardContent className="pt-6">
+ <div className="space-y-3">
+ <div
+ className="flex items-center justify-between"
+ onClick={
+ !hasBusinessMessagingAccess
+ ? () => setUpgradeMessagingModalOpen(true)
+ : undefined
+ }
+ >
+ <div
+ className={cn(
+ "flex flex-col",
+ !hasBusinessMessagingAccess && "cursor-pointer",
+ )}
+ >
+ <div className="flex items-center gap-2">
+ <Label htmlFor="dataroom-welcome-enabled">
+ Welcome Message{" "}
+ <span className="font-normal text-muted-foreground">
+ (front page)
+ </span>
+ </Label>
+ {!hasBusinessMessagingAccess && (
+ <CrownIcon
+ className="h-3.5 w-3.5 text-muted-foreground"
+ aria-label="Business plan feature"
+ />
+ )}
+ </div>
+ <p className="mt-1 text-xs text-muted-foreground">
+ Shown to visitors on the access screen before they
+ see your content.
+ </p>
+ </div>
+ <Switch
+ id="dataroom-welcome-enabled"
+ checked={welcomeEnabled}
+ className={
+ !hasBusinessMessagingAccess
+ ? "cursor-pointer opacity-50"
+ : undefined
+ }
+ onClick={
+ !hasBusinessMessagingAccess
+ ? (e) => {
+ e.preventDefault();
+ setUpgradeMessagingModalOpen(true);
+ }
+ : undefined
+ }
+ onCheckedChange={
+ !hasBusinessMessagingAccess
+ ? undefined
+ : (checked) => {
+ setWelcomeEnabled(checked);
+ if (checked) {
+ setPreviewTab("access-view");
+ }
+ }
+ }
+ />
+ </div>
+ {welcomeEnabled && (
+ <div className="space-y-3 border-t pt-4">
+ <div className="flex items-center justify-between">
+ <Label
+ htmlFor="dataroom-welcome-message"
+ className="text-sm font-medium"
+ >
+ Message
+ </Label>
+ <span className="text-sm text-muted-foreground">
+ <span
+ className={cn(
+ welcomeMessageError && "text-red-500",
+ )}
+ >
+ {welcomeMessage.length}
+ </span>
+ /{MAX_WELCOME_MESSAGE_LENGTH}
+ </span>
+ </div>
+ <Textarea
+ id="dataroom-welcome-message"
+ disabled={!hasBusinessMessagingAccess}
+ value={welcomeMessage}
+ onChange={(e) =>
+ handleWelcomeMessageChange(e.target.value)
+ }
+ placeholder={DEFAULT_WELCOME_MESSAGE}
+ className={cn(
+ "min-h-24 resize-none",
+ welcomeMessageError &&
+ "border-red-500 focus:border-red-500 focus:ring-red-500",
+ )}
+ />
+ {welcomeMessageError && (
+ <p className="text-xs text-red-500">
+ {welcomeMessageError}
+ </p>
+ )}
+ <p className="text-xs text-muted-foreground">
+ Keep the message concise — it should fit within
+ two lines for the best user experience.
+ </p>
+ </div>
+ )}
+ </div>
+ </CardContent>
+ </Card>
+
+ <Card>
+ <CardContent className="pt-6">
+ <BrandingLinkPreviewForm
+ enabled={linkPreviewEnabled}
+ onEnabledChange={(v) => {
+ setLinkPreviewEnabled(v);
+ if (v) setPreviewTab("shared-link-preview");
+ }}
+ title={linkPreviewTitle}
+ onTitleChange={setLinkPreviewTitle}
+ description={linkPreviewDescription}
+ onDescriptionChange={setLinkPreviewDescription}
+ imageUrl={linkPreviewImage}
+ onImageChange={setLinkPreviewImage}
+ faviconUrl={linkPreviewFavicon}
+ onFaviconChange={setLinkPreviewFavicon}
+ inheritanceHint="For this dataroom, empty fields fall back to team branding when both are enabled."
+ />
+ </CardContent>
+ </Card>
+ </div>
+ </CollapsibleBrandingSection>
+ </TabsContent>
+
+ <TabsContent
+ value="layouts"
+ className="mt-4 flex flex-col gap-6 lg:max-h-[calc(100vh-440px)] lg:overflow-y-auto lg:pr-4"
+ >
+ <>
+ <Card>
+ <CardContent className="min-w-0 space-y-3 pt-6">
+ <div>
+ <Label>Data Room layout</Label>
+ <p className="mt-1 text-xs text-muted-foreground">
+ Choose a preset — the options below update to match.
+ Mixing toggles manually switches to a custom
+ combination.
+ </p>
+ </div>
+ <DataroomLayoutPresetCards
+ selectedPreset={derivedLayoutPreset}
+ onSelect={applyLayoutPreset}
+ />
+ {derivedLayoutPreset === "CUSTOM" ? (
+ <p className="text-xs text-muted-foreground">
+ Custom combination — select a preset card to snap
+ back to a named layout.
+ </p>
+ ) : null}
+ </CardContent>
+ </Card>
+
+ {/* Banner visibility */}
+ <Card>
+ <CardContent className="pt-6">
+ <div className="space-y-3">
+ <div className="flex items-center justify-between">
+ <Label htmlFor="banner-visible">Banner</Label>
+ <Switch
+ id="banner-visible"
+ checked={banner !== "no-banner"}
+ onCheckedChange={(checked) => {
+ if (checked) {
+ const restored =
+ lastVisibleBannerRef.current ??
+ (originalBanner &&
+ originalBanner !== "no-banner"
+ ? originalBanner
+ : null) ??
+ DEFAULT_BANNER_IMAGE;
+ setBanner(restored);
+ } else {
+ if (banner && banner !== "no-banner") {
+ lastVisibleBannerRef.current = banner;
+ }
+ setBanner("no-banner");
+ }
+ }}
+ />
+ </div>
+ <p className="text-xs text-muted-foreground">
+ Show a banner image or video at the top of the
+ dataroom. Upload a file or paste a URL (image,
+ video, or YouTube) under Brand identity → Banner.
+ </p>
+ </div>
+ </CardContent>
+ </Card>
+
+ {/* Folder tree (left navigation) */}
+ <Card>
+ <CardContent className="pt-6">
+ <div className="space-y-3">
+ <div className="flex items-center justify-between">
+ <Label htmlFor="show-folder-tree">
+ Navigation tree
+ </Label>
+ <Switch
+ id="show-folder-tree"
+ checked={showFolderTree}
+ onCheckedChange={setShowFolderTree}
+ />
+ </div>
+ <p className="text-xs text-muted-foreground">
+ Show the folder tree in the left column. When off,
+ visitors use breadcrumbs and the main area only.
+ </p>
+ </div>
+ </CardContent>
+ </Card>
+
+ {/* Card Layout */}
+ <Card>
+ <CardContent className="pt-6">
+ <div className="space-y-3">
+ <Label>Document Card Layout</Label>
+ <RadioGroup
+ value={cardLayout}
+ onValueChange={(v) =>
+ setCardLayout(v as DataroomCardLayout)
+ }
+ className="grid grid-cols-3 gap-2"
+ >
+ {CARD_LAYOUT_OPTIONS.map((opt) => (
+ <Label
+ key={opt.value}
+ htmlFor={`card-layout-${opt.value}`}
+ className={cn(
+ "flex cursor-pointer items-center gap-2 rounded-md border border-gray-200 px-3 py-2 text-xs",
+ cardLayout === opt.value &&
+ "border-black bg-gray-50",
+ )}
+ >
+ <RadioGroupItem
+ value={opt.value}
+ id={`card-layout-${opt.value}`}
+ />
+ {opt.label}
+ </Label>
+ ))}
+ </RadioGroup>
+ </div>
+ </CardContent>
+ </Card>
+
+ </>
+ </TabsContent>
+ </Tabs>
{/* Action Buttons - Always Visible */}
<div className="flex items-center gap-4 border-t bg-background pt-4">
- <Button
- onClick={saveBranding}
- loading={isLoading}
- disabled={!!welcomeMessageError}
- className="bg-black text-white hover:bg-gray-800"
- >
- Save changes
- </Button>
+ {layoutBlocksSave ? (
+ <UpgradeButton
+ text="Save changes"
+ clickedPlan={PlanEnum.DataRooms}
+ trigger="dataroom_branding_layouts_save"
+ highlightItem={["dataroom-viewer-layouts"]}
+ hideItems={["datarooms"]}
+ />
+ ) : (
+ <Button
+ onClick={saveBranding}
+ loading={isLoading}
+ disabled={
+ hasBusinessMessagingAccess && !!welcomeMessageError
+ }
+ className="bg-black text-white hover:bg-gray-800"
+ >
+ Save changes
+ </Button>
+ )}
<Button
variant="ghost"
onClick={handleDelete}
@@ -748,6 +1709,21 @@ export default function DataroomBrandPage() {
Reset branding
</Button>
</div>
+ <UpgradePlanModal
+ clickedPlan={PlanEnum.DataRooms}
+ trigger="dataroom_branding_layouts_save"
+ highlightItem={["dataroom-viewer-layouts"]}
+ hideItems={["datarooms"]}
+ open={upgradeLayoutsModalOpen}
+ setOpen={setUpgradeLayoutsModalOpen}
+ />
+ <UpgradePlanModal
+ clickedPlan={PlanEnum.Business}
+ trigger="dataroom_branding_welcome_cta"
+ highlightItem={["custom-welcome-message", "custom-cta"]}
+ open={upgradeMessagingModalOpen}
+ setOpen={setUpgradeMessagingModalOpen}
+ />
</div>
{/* Separator Line */}
@@ -755,12 +1731,28 @@ export default function DataroomBrandPage() {
{/* Preview Column */}
<div className="flex-1 lg:pl-4">
- <Tabs defaultValue="dataroom-view" className="w-full">
+ <Tabs
+ value={previewTab}
+ onValueChange={setPreviewTab}
+ className="w-full"
+ >
<div className="w-full overflow-x-auto">
- <TabsList className="grid w-full grid-cols-3">
+ <TabsList
+ className={cn(
+ "grid w-full gap-1",
+ linkPreviewEnabled
+ ? "grid-cols-2 sm:grid-cols-4"
+ : "grid-cols-3",
+ )}
+ >
<TabsTrigger value="dataroom-view">Dataroom View</TabsTrigger>
<TabsTrigger value="document-view">Document View</TabsTrigger>
<TabsTrigger value="access-view">Front Page</TabsTrigger>
+ {linkPreviewEnabled && (
+ <TabsTrigger value="shared-link-preview">
+ Shared link preview
+ </TabsTrigger>
+ )}
</TabsList>
</div>
{/* Dataroom View */}
@@ -814,10 +1806,10 @@ export default function DataroomBrandPage() {
<div className="relative min-h-0 flex-1 overflow-x-auto">
<div className="relative h-full max-w-[1396px]">
<iframe
- key={`dataroom-view-${debouncedBrandColor}-${debouncedAccentColor}-${banner}`}
+ key={`dataroom-view-${debouncedBrandColor}-${debouncedAccentColor}-${banner}-${cardLayout}-${showFolderTree}-${viewerHeaderStyle}-${hideFolderIconsInMain}-${ctaLabel}`}
name="dataroom-view"
id="dataroom-view"
- src={`/room_ppreview_demo?brandColor=${encodeURIComponent(debouncedBrandColor)}&accentColor=${encodeURIComponent(debouncedAccentColor)}&applyAccentColorToDataroomView=${applyAccentColorToDataroomView ? "1" : "0"}&brandLogo=${blobUrl ? encodeURIComponent(blobUrl) : logo ? encodeURIComponent(logo) : ""}&brandBanner=${banner === "no-banner" ? encodeURIComponent("no-banner") : bannerBlobUrl ? encodeURIComponent(bannerBlobUrl) : banner ? encodeURIComponent(banner) : ""}`}
+ src={`/room_ppreview_demo?${buildPreviewQuery()}`}
className="absolute left-0 top-0 h-full w-full origin-top-left scale-50 overflow-hidden rounded-b-lg border-0 bg-white"
style={{
width: "200%",
@@ -949,10 +1941,10 @@ export default function DataroomBrandPage() {
<div className="relative min-h-0 flex-1 overflow-x-auto">
<div className="relative h-full max-w-[1396px]">
<iframe
- key={`access-screen-${debouncedBrandColor}-${debouncedAccentColor}-${debouncedWelcomeMessage}`}
+ key={`access-screen-${debouncedBrandColor}-${debouncedAccentColor}-${previewWelcomeMessage}`}
name="access-screen"
id="access-screen"
- src={`/entrance_ppreview_demo?brandColor=${encodeURIComponent(debouncedBrandColor)}&accentColor=${encodeURIComponent(debouncedAccentColor)}&brandLogo=${blobUrl ? encodeURIComponent(blobUrl) : logo ? encodeURIComponent(logo) : ""}&welcomeMessage=${encodeURIComponent(debouncedWelcomeMessage)}`}
+ src={`/entrance_ppreview_demo?brandColor=${encodeURIComponent(debouncedBrandColor)}&accentColor=${encodeURIComponent(debouncedAccentColor)}&brandLogo=${blobUrl ? encodeURIComponent(blobUrl) : logo ? encodeURIComponent(logo) : ""}&welcomeMessage=${encodeURIComponent(previewWelcomeMessage)}`}
className="absolute left-0 top-0 h-full w-full origin-top-left scale-50 overflow-hidden rounded-b-lg border-0 bg-white"
style={{
width: "200%",
@@ -966,6 +1958,18 @@ export default function DataroomBrandPage() {
</div>
</div>
</TabsContent>
+ {linkPreviewEnabled && (
+ <TabsContent value="shared-link-preview" className="mt-6">
+ <div className="mx-auto flex max-w-xl justify-center">
+ <BrandingSocialPreviewReadonly
+ title={debouncedLinkPreviewTitle}
+ description={debouncedLinkPreviewDescription}
+ image={debouncedLinkPreviewImage}
+ favicon={debouncedLinkPreviewFavicon}
+ />
+ </div>
+ </TabsContent>
+ )}
</Tabs>
{/* Preview Mode Info */}
diff --git a/pages/nav_ppreview_demo.tsx b/pages/nav_ppreview_demo.tsx
index ca77cddb..3e1a4337 100644
--- a/pages/nav_ppreview_demo.tsx
+++ b/pages/nav_ppreview_demo.tsx
@@ -4,12 +4,35 @@ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
export default function ViewPage() {
const router = useRouter();
- const { brandLogo, brandColor, accentColor } = router.query as {
+ const {
+ brandLogo,
+ brandColor,
+ accentColor,
+ accentButtonColor,
+ ctaLabel,
+ ctaUrl,
+ } = router.query as {
brandLogo: string;
brandColor: string;
accentColor: string;
+ accentButtonColor?: string;
+ ctaLabel?: string;
+ ctaUrl?: string;
};
+ const safeCtaUrl = (() => {
+ if (!ctaUrl) return null;
+ try {
+ const url = new URL(ctaUrl);
+ if (url.protocol !== "http:" && url.protocol !== "https:") return null;
+ return url.toString();
+ } catch {
+ return null;
+ }
+ })();
+
+ const showCta = !!ctaLabel && !!safeCtaUrl;
+
return (
<div className="bg-gray-950" style={{ backgroundColor: accentColor }}>
{/* Nav */}
@@ -37,6 +60,20 @@ export default function ViewPage() {
</div>
</div>
<div className="absolute inset-y-0 right-0 flex items-center space-x-4 pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0">
+ {showCta && (
+ <a
+ href={safeCtaUrl!}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="inline-flex items-center justify-center rounded-md px-4 py-2 text-sm font-medium text-white"
+ style={{
+ backgroundColor:
+ accentButtonColor || brandColor || "#000000",
+ }}
+ >
+ {ctaLabel}
+ </a>
+ )}
<div className="flex h-10 items-center rounded-md bg-gray-900 px-4 py-2 text-sm font-medium text-white">
<span>1</span>
<span className="text-gray-400"> / 13</span>
diff --git a/pages/room_ppreview_demo.tsx b/pages/room_ppreview_demo.tsx
index af798ff7..f9fb8b32 100644
--- a/pages/room_ppreview_demo.tsx
+++ b/pages/room_ppreview_demo.tsx
@@ -1,7 +1,29 @@
import { useRouter } from "next/router";
+import { type CSSProperties, type ReactNode, useMemo, useState } from "react";
+
+import {
+ type DataroomCardLayout,
+ type DataroomViewerHeaderStyle,
+} from "@/ee/features/branding/lib/dataroom-viewer-layout";
+
+import { PlayIcon } from "lucide-react";
+
import { ViewFolderTree } from "@/components/datarooms/folders";
+import {
+ Breadcrumb,
+ BreadcrumbItem,
+ BreadcrumbLink,
+ BreadcrumbList,
+ BreadcrumbPage,
+ BreadcrumbSeparator,
+} from "@/components/ui/breadcrumb";
+import { cn } from "@/lib/utils";
+import { useLogoTone } from "@/ee/features/branding/lib/use-logo-tone";
+import { classifyDataroomBanner } from "@/ee/features/branding/lib/dataroom-banner";
+import { getDataroomPreviewDataset } from "@/ee/features/branding/lib/dataroom-preview-presets";
import DocumentCard from "@/components/view/dataroom/document-card";
+import { CompactDataroomListHeader } from "@/components/view/dataroom/compact-dataroom-list-header";
import FolderCard from "@/components/view/dataroom/folder-card";
import {
ViewerSurfaceThemeProvider,
@@ -10,224 +32,847 @@ import {
const DEFAULT_BANNER_IMAGE = "/_static/papermark-banner.png";
+const DATAROOM_NAV_PAGE_FRAME =
+ "mx-auto w-full px-3 md:px-6 lg:px-8 xl:px-14";
+
+/**
+ * Preview iframe mirror of `NotionLogoChip` in `nav-dataroom`: picks white or
+ * black behind the cover logo based on the logo's averaged pixel luminance so
+ * the chip always contrasts with the logo regardless of brand colors.
+ */
+function PreviewNotionLogoChip({
+ src,
+ shouldApplyAccent,
+ surfacePanelBorderColor,
+}: {
+ src: string;
+ shouldApplyAccent: boolean;
+ surfacePanelBorderColor: string;
+}) {
+ const { tone, imgProps } = useLogoTone(src);
+ const isLightLogo = tone === "light";
+ return (
+ <div
+ className={cn(
+ "flex size-16 items-center justify-center overflow-hidden rounded-xl border p-2 shadow-sm sm:size-20",
+ isLightLogo
+ ? "border-neutral-800 bg-neutral-950"
+ : "border-neutral-200 bg-white",
+ )}
+ style={
+ shouldApplyAccent
+ ? { borderColor: surfacePanelBorderColor }
+ : undefined
+ }
+ >
+ {/* Display <img> doubles as the source for `useLogoTone`'s canvas
+ analysis — `crossOrigin` keeps the canvas read untainted and lets
+ the hook reuse this single decode instead of fetching a second
+ Image() over the wire. */}
+ <img
+ className="h-full w-full object-contain"
+ src={src}
+ alt=""
+ crossOrigin="anonymous"
+ referrerPolicy="no-referrer"
+ {...imgProps}
+ />
+ </div>
+ );
+}
+
+/**
+ * Renders the dataroom banner in the preview iframe.
+ *
+ * Strategy:
+ * - image → render <img>.
+ * - YouTube→ use the official video thumbnail as a still and overlay a play
+ * badge so users see exactly what their banner will look like
+ * (we avoid the iframe because it doesn't scale well at 50%).
+ * - video → render <video preload="metadata" muted playsInline> (no
+ * autoplay). The browser shows the first frame as the poster, and
+ * a play badge is overlaid so the user can preview frame + intent.
+ */
+function PreviewBannerMedia({
+ src,
+ className,
+ imgClassName,
+}: {
+ src: string;
+ className?: string;
+ imgClassName?: string;
+}) {
+ const classified = classifyDataroomBanner(src);
+
+ if (classified.kind === "youtube" && classified.youtubeId) {
+ const thumb = `https://img.youtube.com/vi/${classified.youtubeId}/hqdefault.jpg`;
+ return (
+ <VideoBannerPreview
+ className={className}
+ ariaLabel="YouTube banner preview"
+ >
+ <img
+ className={cn(
+ "absolute inset-0 h-full w-full object-cover",
+ imgClassName,
+ )}
+ src={thumb}
+ alt=""
+ loading="lazy"
+ />
+ </VideoBannerPreview>
+ );
+ }
+
+ if (classified.kind === "video" && classified.src) {
+ return (
+ <VideoBannerPreview
+ className={className}
+ ariaLabel="Video banner preview"
+ >
+ <video
+ className={cn(
+ "absolute inset-0 h-full w-full object-cover",
+ imgClassName,
+ )}
+ src={classified.src}
+ preload="metadata"
+ muted
+ playsInline
+ // first frame as poster; do not autoplay in editor preview
+ />
+ </VideoBannerPreview>
+ );
+ }
+
+ return (
+ <img
+ className={cn("h-full w-full object-cover", imgClassName, className)}
+ src={src}
+ alt="Banner"
+ />
+ );
+}
+
+/** Shared layout for video / YouTube banner previews: still frame underneath
+ * + soft gradient + centered play badge so it reads as playable media. */
+function VideoBannerPreview({
+ children,
+ className,
+ ariaLabel,
+}: {
+ children: ReactNode;
+ className?: string;
+ ariaLabel: string;
+}) {
+ return (
+ <div
+ className={cn(
+ "relative h-full w-full overflow-hidden bg-neutral-900",
+ className,
+ )}
+ aria-label={ariaLabel}
+ >
+ {children}
+ <div className="pointer-events-none absolute inset-0 bg-gradient-to-t from-black/45 via-black/10 to-black/15" />
+ <div className="pointer-events-none absolute inset-0 flex items-center justify-center">
+ <div className="flex h-16 w-16 items-center justify-center rounded-full bg-white/95 shadow-[0_8px_30px_rgba(0,0,0,0.35)] ring-1 ring-black/5 transition-transform duration-200 hover:scale-105">
+ <PlayIcon className="ml-0.5 h-6 w-6 fill-neutral-900 text-neutral-900" />
+ </div>
+ </div>
+ </div>
+ );
+}
+
+/** Preview iframe: align with dataroom viewer (sharp corners, optional folder tree). */
export default function ViewPage() {
const router = useRouter();
+ const [previewFolderId, setPreviewFolderId] = useState<string | null>(null);
const {
brandLogo,
brandColor,
brandBanner,
accentColor,
applyAccentColorToDataroomView,
+ cardLayout: cardLayoutParam,
+ showFolderTree: showFolderTreeParam,
+ ctaLabel,
+ ctaUrl,
+ accentButtonColor,
+ viewerHeaderStyle: viewerHeaderStyleParam,
+ hideFolderIconsInMain: hideFolderIconsMainParam,
} = router.query as {
- brandLogo: string;
- brandColor: string;
- brandBanner: string;
- accentColor: string;
+ brandLogo?: string;
+ brandColor?: string;
+ brandBanner?: string;
+ accentColor?: string;
applyAccentColorToDataroomView?: string;
+ cardLayout?: string;
+ showFolderTree?: string;
+ ctaLabel?: string;
+ ctaUrl?: string;
+ accentButtonColor?: string;
+ viewerHeaderStyle?: string;
+ hideFolderIconsInMain?: string;
};
+ // Always the same "Example Virtual Data Room" — keeps the preview consistent
+ // across pages and avoids depending on per-team onboarding answers.
+ const previewDataset = useMemo(() => getDataroomPreviewDataset(), []);
+ const previewFolders = previewDataset.folders;
+ const previewDocuments = previewDataset.documents;
+
+ // Preview docs only carry `folderName`; derive a stable folderId so the
+ // tree and the main pane can filter the same way the live viewer does
+ // (folders by parentId, documents by folderId).
+ const folderIdByName = useMemo(() => {
+ const map = new Map<string, string>();
+ for (const folder of previewFolders) map.set(folder.name, folder.id);
+ return map;
+ }, [previewFolders]);
+
+ const getDocumentFolderId = (folderName: string | null): string | null =>
+ folderName ? (folderIdByName.get(folderName) ?? null) : null;
+
+ const filteredPreviewFolders = useMemo(
+ () => previewFolders.filter((f) => f.parentId === previewFolderId),
+ [previewFolders, previewFolderId],
+ );
+
+ const filteredPreviewDocuments = useMemo(
+ () =>
+ previewDocuments.filter(
+ (doc) => getDocumentFolderId(doc.folderName) === previewFolderId,
+ ),
+ // getDocumentFolderId only depends on folderIdByName
+ [previewDocuments, previewFolderId, folderIdByName],
+ );
+
+ const cardLayout: DataroomCardLayout =
+ cardLayoutParam === "GRID" || cardLayoutParam === "COMPACT"
+ ? cardLayoutParam
+ : "LIST";
+ const showFolderTree = showFolderTreeParam !== "0";
+ const showNavCta = !!ctaLabel && !!ctaUrl;
+ const showLeftColumnDesktop = showFolderTree;
+
+ const viewerHeaderStyle: DataroomViewerHeaderStyle =
+ viewerHeaderStyleParam === "SPLIT" || viewerHeaderStyleParam === "NOTION"
+ ? viewerHeaderStyleParam
+ : "DEFAULT";
+ const hideFolderIconsInMain = hideFolderIconsMainParam === "1";
+ const hasBanner = brandBanner !== "no-banner";
+ const headerMode: "DEFAULT" | "SPLIT" | "NOTION" =
+ hasBanner && (viewerHeaderStyle === "SPLIT" || viewerHeaderStyle === "NOTION")
+ ? viewerHeaderStyle
+ : "DEFAULT";
+ const bannerSrc = brandBanner || DEFAULT_BANNER_IMAGE;
+
+ // Mirror live viewer: only Modern's boxed banner shows playable video /
+ // YouTube. For Default + Notion full-width banners we fall back to the
+ // default banner image so the preview matches what visitors will see.
+ const bannerKindPreview = classifyDataroomBanner(bannerSrc).kind;
+ const fullBleedBannerSrc =
+ bannerKindPreview === "video" || bannerKindPreview === "youtube"
+ ? DEFAULT_BANNER_IMAGE
+ : bannerSrc;
+
+ const isModernPreview = headerMode === "SPLIT";
+
const shouldApplyAccentToDataroomView =
applyAccentColorToDataroomView === "1";
const dataroomViewBackgroundColor = shouldApplyAccentToDataroomView
? accentColor
: "#ffffff";
- const previewSurfaceTheme = createViewerSurfaceTheme(dataroomViewBackgroundColor);
+ const previewSurfaceTheme = createViewerSurfaceTheme(
+ dataroomViewBackgroundColor,
+ );
+ // Adaptive CSS vars used by breadcrumb/search/separator inside Modern (SPLIT)
+ // header so they match the body palette when accent is applied.
+ const previewSplitSurfaceVars = {
+ "--viewer-text": previewSurfaceTheme.palette.textColor,
+ "--viewer-muted-text": previewSurfaceTheme.palette.mutedTextColor,
+ "--viewer-subtle-text": previewSurfaceTheme.palette.subtleTextColor,
+ "--viewer-panel-bg": previewSurfaceTheme.palette.panelBgColor,
+ "--viewer-panel-bg-hover": previewSurfaceTheme.palette.panelHoverBgColor,
+ "--viewer-panel-border": previewSurfaceTheme.palette.panelBorderColor,
+ "--viewer-panel-border-hover":
+ previewSurfaceTheme.palette.panelBorderHoverColor,
+ "--viewer-control-bg": previewSurfaceTheme.palette.controlBgColor,
+ "--viewer-control-border": previewSurfaceTheme.palette.controlBorderColor,
+ "--viewer-control-border-strong":
+ previewSurfaceTheme.palette.controlBorderStrongColor,
+ "--viewer-control-icon": previewSurfaceTheme.palette.controlIconColor,
+ "--viewer-placeholder":
+ previewSurfaceTheme.palette.controlPlaceholderColor,
+ "--viewer-accent":
+ accentButtonColor || brandColor || previewSurfaceTheme.palette.textColor,
+ } as CSSProperties;
+
+ const itemListClassName =
+ cardLayout === "GRID"
+ ? null
+ : cardLayout === "COMPACT"
+ ? "overflow-auto"
+ : "space-y-4";
+
+ const compactPreviewShowUpdated = cardLayout === "COMPACT";
+ const compactPreviewShowActions = false;
+
+ const renderPrimaryLogo = () =>
+ brandLogo ? (
+ <img
+ className="h-10 w-28 object-contain sm:h-12 sm:w-32"
+ src={brandLogo}
+ alt="Logo"
+ />
+ ) : (
+ <div className="text-2xl font-bold tracking-tighter text-white">
+ Papermark
+ </div>
+ );
return (
<div
className="min-h-screen bg-white"
style={
- dataroomViewBackgroundColor
- ? { backgroundColor: dataroomViewBackgroundColor }
- : undefined
+ {
+ backgroundColor: dataroomViewBackgroundColor,
+ } as CSSProperties
}
>
- {/* Nav */}
+ {/* Header — matches live viewer modes */}
<nav
- className="bg-black"
- style={{
- backgroundColor: brandColor,
- }}
+ className={cn(
+ headerMode === "SPLIT"
+ ? cn(
+ "border-b border-[var(--viewer-panel-border)] text-neutral-900 dark:text-neutral-100",
+ shouldApplyAccentToDataroomView
+ ? ""
+ : "bg-white dark:bg-neutral-950",
+ )
+ : "bg-black",
+ )}
+ style={
+ headerMode === "SPLIT"
+ ? {
+ ...previewSplitSurfaceVars,
+ ...(shouldApplyAccentToDataroomView
+ ? { backgroundColor: dataroomViewBackgroundColor }
+ : {}),
+ }
+ : { backgroundColor: brandColor || "#000000" }
+ }
>
- <div className="mx-auto px-2 sm:px-6 lg:px-8">
- <div className="relative flex h-16 items-center justify-between">
- <div className="flex flex-1 items-center justify-start">
- <div className="relative flex h-16 w-36 flex-shrink-0 items-center overflow-y-hidden">
- {brandLogo ? (
- <img
- className="w-full object-contain"
- src={brandLogo}
- alt="Logo"
+ {headerMode === "NOTION" && hasBanner ? (
+ <>
+ {/* Notion preset: no brand-colored navbar above the cover image.
+ In the real viewer the CTA/conversations/download buttons get
+ relocated into the body toolbar (right of the search input). */}
+ <div className="relative h-[20vh] w-full overflow-hidden bg-neutral-100 dark:bg-neutral-900 sm:h-auto sm:max-h-80">
+ <PreviewBannerMedia
+ src={fullBleedBannerSrc}
+ className="h-full w-full"
+ imgClassName="h-full w-full object-cover sm:max-h-80 sm:object-contain xl:object-cover"
+ />
+ </div>
+ <div
+ className={cn(
+ "text-black dark:text-white",
+ shouldApplyAccentToDataroomView
+ ? ""
+ : "bg-white dark:bg-neutral-950",
+ )}
+ style={
+ shouldApplyAccentToDataroomView
+ ? {
+ ...previewSplitSurfaceVars,
+ backgroundColor: dataroomViewBackgroundColor,
+ }
+ : previewSplitSurfaceVars
+ }
+ >
+ <div className={cn(DATAROOM_NAV_PAGE_FRAME, "pb-10 pt-2")}>
+ <div className="-mt-10 relative z-10 flex w-full flex-col items-start text-left sm:-mt-12">
+ {brandLogo ? (
+ // Notion cover logo chip: adaptive background based on the
+ // logo's averaged luminance — dark logos sit in a white
+ // box, light/white logos sit in a black box so they're
+ // always visible regardless of brand colors.
+ <PreviewNotionLogoChip
+ src={brandLogo}
+ shouldApplyAccent={shouldApplyAccentToDataroomView}
+ surfacePanelBorderColor={
+ previewSurfaceTheme.palette.panelBorderColor
+ }
+ />
+ ) : (
+ <div
+ className={cn(
+ "flex size-16 items-center justify-center rounded-xl border text-sm font-semibold sm:size-20",
+ shouldApplyAccentToDataroomView
+ ? ""
+ : "border-neutral-200 bg-neutral-900 text-white dark:border-neutral-700 dark:bg-white dark:text-neutral-950",
+ )}
+ style={
+ shouldApplyAccentToDataroomView
+ ? {
+ backgroundColor:
+ previewSurfaceTheme.palette.ctaBgColor,
+ color:
+ previewSurfaceTheme.palette.ctaTextColor,
+ borderColor:
+ previewSurfaceTheme.palette.panelBorderColor,
+ }
+ : undefined
+ }
+ >
+ EX
+ </div>
+ )}
+ <div
+ className="mt-4 max-w-3xl text-3xl"
+ style={
+ shouldApplyAccentToDataroomView
+ ? { color: previewSurfaceTheme.palette.textColor }
+ : undefined
+ }
+ >
+ Example Data Room
+ </div>
+ <time
+ className="mt-0.5 block text-sm text-neutral-600 dark:text-neutral-400"
+ style={
+ shouldApplyAccentToDataroomView
+ ? { color: previewSurfaceTheme.palette.mutedTextColor }
+ : undefined
+ }
+ >
+ Last updated 2 hours ago
+ </time>
+ </div>
+ </div>
+ </div>
+ </>
+ ) : headerMode === "SPLIT" && hasBanner ? (
+ <>
+ <div className={cn(DATAROOM_NAV_PAGE_FRAME, "pt-4")}>
+ <div className="flex items-center justify-between gap-2 border-b border-[var(--viewer-panel-border)] pb-2">
+ <div className="relative flex min-h-14 shrink-0 items-center">
+ {brandLogo ? (
+ <img
+ className="h-10 w-28 object-contain sm:h-12 sm:w-32"
+ src={brandLogo}
+ alt="Logo"
+ />
+ ) : (
+ <div className="text-2xl font-bold tracking-tighter text-neutral-900 dark:text-white">
+ Papermark
+ </div>
+ )}
+ </div>
+ <div className="flex min-w-0 shrink items-center justify-end gap-2">
+ {showNavCta ? (
+ <a
+ href={ctaUrl}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="inline-flex shrink-0 items-center justify-center rounded-md px-4 py-2 text-sm font-medium text-white"
+ style={{
+ backgroundColor:
+ accentButtonColor || brandColor || "#111827",
+ }}
+ >
+ {ctaLabel}
+ </a>
+ ) : null}
+ </div>
+ </div>
+
+ <div className="grid gap-4 py-4 lg:grid-cols-[minmax(0,1fr)_minmax(220px,40%)] lg:items-center lg:gap-8 lg:py-6">
+ <div className="min-w-0 space-y-2">
+ <p
+ className="text-[11px] font-medium uppercase tracking-[0.2em] text-neutral-500 dark:text-neutral-400"
+ style={
+ shouldApplyAccentToDataroomView
+ ? { color: previewSurfaceTheme.palette.mutedTextColor }
+ : undefined
+ }
+ >
+ DATA ROOM · UPDATED MAY 10, 2026
+ </p>
+ <h1
+ className="text-balance text-3xl text-neutral-950 dark:text-white"
+ style={
+ shouldApplyAccentToDataroomView
+ ? { color: previewSurfaceTheme.palette.textColor }
+ : undefined
+ }
+ >
+ Example Data Room
+ </h1>
+ <p
+ className="max-w-2xl text-pretty text-sm leading-relaxed text-neutral-600 dark:text-neutral-300"
+ style={
+ shouldApplyAccentToDataroomView
+ ? { color: previewSurfaceTheme.palette.mutedTextColor }
+ : undefined
+ }
+ >
+ Preview of the modern layout: hero copy uses your welcome
+ message when set in branding.
+ </p>
+ </div>
+ <div className="relative aspect-[16/7] w-full overflow-hidden rounded-xl border border-neutral-200/90 bg-neutral-200/30 shadow-sm dark:border-neutral-800 dark:bg-neutral-900 lg:aspect-[16/9]">
+ <div className="absolute inset-0">
+ <PreviewBannerMedia src={bannerSrc} />
+ </div>
+ </div>
+ </div>
+
+ <div className="flex flex-col gap-3 py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4">
+ <div className="min-w-0 flex-1 overflow-hidden">
+ {previewFolders.length > 0 ? (
+ <Breadcrumb>
+ <BreadcrumbList className="text-sm text-[var(--viewer-muted-text)]">
+ <BreadcrumbItem>
+ <BreadcrumbLink
+ onClick={() => setPreviewFolderId(null)}
+ className="cursor-pointer text-[var(--viewer-muted-text)] hover:text-[var(--viewer-text)]"
+ >
+ Home
+ </BreadcrumbLink>
+ </BreadcrumbItem>
+ {previewFolderId ? (
+ <>
+ <BreadcrumbSeparator className="text-[var(--viewer-subtle-text)]" />
+ <BreadcrumbItem>
+ <BreadcrumbPage className="font-medium text-[var(--viewer-text)]">
+ {previewFolders.find(
+ (f) => f.id === previewFolderId,
+ )?.name ?? "Folder"}
+ </BreadcrumbPage>
+ </BreadcrumbItem>
+ </>
+ ) : null}
+ </BreadcrumbList>
+ </Breadcrumb>
+ ) : (
+ <div className="text-sm text-[var(--viewer-muted-text)]">
+ Home
+ </div>
+ )}
+ </div>
+ {/* Right cluster mirrors the live viewer: search input + action
+ button placeholders (Generate Index, Add Document) live on
+ the same line as the search so Modern's nav top-row matches
+ Standard's body toolbar. */}
+ <div className="flex min-w-0 shrink-0 items-center gap-x-2">
+ <div
+ className="h-9 w-full min-w-[12rem] max-w-sm shrink-0 rounded-md border border-[var(--viewer-control-border)] bg-[var(--viewer-control-bg)] shadow-sm sm:w-72"
+ aria-hidden
/>
- ) : (
- <div className="text-2xl font-bold tracking-tighter text-white">
- Papermark
+ <div
+ className="h-9 w-28 shrink-0 rounded-md border border-[var(--viewer-control-border)] bg-[var(--viewer-control-bg)] shadow-sm"
+ aria-hidden
+ title="Generate index"
+ />
+ <div
+ className="h-9 w-28 shrink-0 rounded-md border border-[var(--viewer-control-border)] bg-[var(--viewer-control-bg)] shadow-sm"
+ aria-hidden
+ title="Add document"
+ />
+ </div>
+ </div>
+ </div>
+ </>
+ ) : (
+ <>
+ <div className={DATAROOM_NAV_PAGE_FRAME}>
+ <div className="relative flex h-16 items-center justify-between">
+ <div className="flex flex-1 items-center justify-start">
+ <div className="relative flex h-16 w-36 flex-shrink-0 items-center overflow-y-hidden">
+ {renderPrimaryLogo()}
</div>
+ </div>
+ {showNavCta && (
+ <a
+ href={ctaUrl}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="inline-flex items-center justify-center px-4 py-2 text-sm font-medium text-white"
+ style={{
+ backgroundColor:
+ accentButtonColor || brandColor || "#ffffff",
+ color: accentButtonColor ? "#ffffff" : "#000000",
+ }}
+ >
+ {ctaLabel}
+ </a>
)}
</div>
</div>
- </div>
- </div>
- {/* Banner section */}
- {brandBanner !== "no-banner" && (
- <div className="relative h-[30vh]">
- <img
- className="h-[30vh] w-full object-cover"
- src={brandBanner || DEFAULT_BANNER_IMAGE}
- alt="Banner"
- width={1920}
- height={320}
- />
- <div className="absolute bottom-5 w-fit rounded-r-md bg-white/30 backdrop-blur-md">
- <div className="px-5 py-2 sm:px-10">
- <div className="text-3xl">Example Data Room</div>
- <time className="text-sm">Last updated 2 hours ago</time>
+ {hasBanner ? (
+ <div className="relative h-[20vh] sm:h-auto sm:max-h-80">
+ <PreviewBannerMedia
+ src={fullBleedBannerSrc}
+ imgClassName="sm:max-h-80 sm:object-contain xl:object-cover"
+ />
+ <div className="absolute bottom-5 w-fit rounded-r-md bg-white/30 backdrop-blur-md">
+ <div className="px-5 py-2 sm:px-10">
+ <div className="text-3xl">Example Data Room</div>
+ <time className="mt-0.5 block text-sm">
+ Last updated 2 hours ago
+ </time>
+ </div>
+ </div>
</div>
- </div>
- </div>
+ ) : null}
+ </>
)}
</nav>
{/* Body */}
<ViewerSurfaceThemeProvider value={previewSurfaceTheme}>
- <div style={{ height: "calc(100vh - 64px)" }} className="relative flex">
- {/* Tree view */}
- <div
- className="hidden h-full shrink-0 overflow-y-auto overflow-x-hidden px-3 pb-4 pt-4 md:block md:px-4 md:pt-6 lg:px-6 lg:pt-9 xl:px-8"
- style={{ width: "clamp(260px, 28vw, 440px)" }}
- >
- <ViewFolderTree
- folders={[
- {
- id: "1",
- name: "Marketing",
- parentId: null,
- dataroomId: "1",
- orderIndex: 0,
- hierarchicalIndex: null,
- path: "/",
- createdAt: new Date(),
- updatedAt: new Date(),
- icon: null,
- color: null,
- },
- {
- id: "2",
- name: "Sales",
- parentId: null,
- dataroomId: "1",
- orderIndex: 1,
- hierarchicalIndex: null,
- path: "/",
- createdAt: new Date(),
- updatedAt: new Date(),
- icon: null,
- color: null,
- },
- ]}
- documents={[
- {
- id: "1",
- name: "Q4 Report.pdf",
- dataroomDocumentId: "1",
- folderId: null,
- orderIndex: null,
- hierarchicalIndex: null,
- versions: [
- {
- id: "1",
- versionNumber: 1,
- hasPages: true,
- },
- ],
- },
- ]}
- setFolderId={() => {}}
- folderId={null}
- />
- </div>
+ <div
+ style={
+ {
+ minHeight: "min(560px, 70vh)",
+ } as CSSProperties
+ }
+ className="relative flex flex-1"
+ >
+ {showLeftColumnDesktop && (
+ <div
+ className="hidden h-full shrink-0 overflow-y-auto overflow-x-hidden px-3 pb-4 pt-4 md:block md:px-4 md:pt-6 lg:px-6 lg:pt-9 xl:px-8"
+ style={{ width: "clamp(260px, 28vw, 440px)" }}
+ >
+ {brandBanner === "no-banner" && (
+ <div className="mb-3 min-w-0">
+ <div
+ className="text-3xl"
+ style={{ color: previewSurfaceTheme.palette.textColor }}
+ >
+ Example Data Room
+ </div>
+ <time
+ className="mt-0.5 block text-sm"
+ style={{
+ color: previewSurfaceTheme.palette.mutedTextColor,
+ }}
+ >
+ Last updated 2 hours ago
+ </time>
+ </div>
+ )}
+ {showFolderTree && (
+ <ViewFolderTree
+ folders={previewFolders}
+ documents={previewDocuments.map((doc) => ({
+ id: doc.id,
+ name: doc.name,
+ dataroomDocumentId: doc.dataroomDocumentId,
+ folderId: getDocumentFolderId(doc.folderName),
+ orderIndex: null,
+ hierarchicalIndex: null,
+ versions: doc.versions.map((v) => ({
+ id: v.id,
+ versionNumber: v.versionNumber,
+ hasPages: v.hasPages,
+ })),
+ }))}
+ setFolderId={setPreviewFolderId}
+ folderId={previewFolderId}
+ />
+ )}
+ </div>
+ )}
{/* Detail view */}
<div className="flex-grow overflow-auto">
<div className="h-full space-y-8 px-3 pb-4 pt-4 md:px-6 md:pt-6 lg:px-8 lg:pt-9 xl:px-14">
<div className="space-y-4">
- <div
- className={`text-sm ${previewSurfaceTheme.usesLightText ? "text-white/70" : "text-muted-foreground"}`}
- >Home</div>
- <ul className="grid gap-4">
- <li key="1">
- <FolderCard
- folder={{
- id: "1",
- name: "Marketing",
- parentId: null,
- dataroomId: "1",
- orderIndex: 0,
- hierarchicalIndex: null,
- path: "/",
- createdAt: new Date(),
- updatedAt: new Date(),
- icon: null,
- color: null,
+ {brandBanner === "no-banner" && !showLeftColumnDesktop ? (
+ <div className="-mb-2 min-w-0 md:-mb-1">
+ <div
+ className="text-3xl"
+ style={{ color: previewSurfaceTheme.palette.textColor }}
+ >
+ Example Data Room
+ </div>
+ <div
+ className="mt-0.5 block text-sm"
+ style={{
+ color: previewSurfaceTheme.palette.mutedTextColor,
}}
- dataroomId="1"
- setFolderId={() => {}}
- isPreview={false}
- linkId="1"
- allowDownload={false}
- />
- </li>
-
- <li key="2">
- <FolderCard
- folder={{
- id: "2",
- name: "Sales",
- parentId: null,
- dataroomId: "1",
- orderIndex: 1,
- hierarchicalIndex: null,
- path: "/",
- createdAt: new Date(),
- updatedAt: new Date(),
- icon: null,
- color: null,
- }}
- dataroomId="1"
- setFolderId={() => {}}
- isPreview={false}
- linkId="1"
- allowDownload={false}
- />
- </li>
-
- <li key="3">
- <DocumentCard
- document={{
- id: "1",
- name: "Q4 Report.pdf",
- dataroomDocumentId: "1",
- downloadOnly: false,
- canDownload: false,
- hierarchicalIndex: null,
- versions: [
- {
- id: "1",
- type: "pdf",
- versionNumber: 1,
- hasPages: true,
- isVertical: true,
- updatedAt: new Date(),
- },
- ],
- }}
- linkId="1"
- isPreview={false}
- allowDownload={false}
+ >
+ Last updated 2 hours ago
+ </div>
+ </div>
+ ) : null}
+ {cardLayout === "LIST" && !isModernPreview ? (
+ <div className="flex min-w-0 flex-1 items-center justify-between gap-x-2 gap-y-2">
+ <div className="flex min-w-0 flex-1 items-center gap-2 overflow-hidden">
+ {!showFolderTree && previewFolders.length > 0 ? (
+ <Breadcrumb>
+ <BreadcrumbList className="text-sm text-neutral-600 dark:text-neutral-400">
+ <BreadcrumbItem>
+ <BreadcrumbLink
+ onClick={() => setPreviewFolderId(null)}
+ className="cursor-pointer hover:text-neutral-900 dark:hover:text-neutral-100"
+ >
+ Home
+ </BreadcrumbLink>
+ </BreadcrumbItem>
+ {previewFolderId ? (
+ <>
+ <BreadcrumbSeparator className="text-neutral-400" />
+ <BreadcrumbItem>
+ <BreadcrumbPage className="font-medium text-neutral-900 dark:text-neutral-100">
+ {previewFolders.find(
+ (f) => f.id === previewFolderId,
+ )?.name ?? "Folder"}
+ </BreadcrumbPage>
+ </BreadcrumbItem>
+ </>
+ ) : null}
+ </BreadcrumbList>
+ </Breadcrumb>
+ ) : (
+ <div
+ className={`text-sm ${previewSurfaceTheme.usesLightText ? "text-white/70" : "text-muted-foreground"}`}
+ >
+ Home
+ </div>
+ )}
+ </div>
+ <div
+ className="h-9 w-full min-w-[12rem] max-w-sm shrink-0 rounded-md border border-neutral-300 bg-white shadow-sm dark:border-neutral-600 dark:bg-neutral-900 sm:w-72"
+ aria-hidden
/>
- </li>
- </ul>
+ </div>
+ ) : null}
+ {cardLayout === "GRID" ? (
+ <div className="space-y-4">
+ <ul
+ role="list"
+ className="grid grid-cols-2 gap-3 sm:grid-cols-3 sm:gap-4"
+ >
+ {filteredPreviewFolders.map((folder) => (
+ <li key={folder.id}>
+ <FolderCard
+ folder={folder}
+ dataroomId="1"
+ setFolderId={setPreviewFolderId}
+ isPreview={false}
+ linkId="1"
+ allowDownload={false}
+ layout={cardLayout}
+ hideFolderIcons={hideFolderIconsInMain}
+ compactShowUpdatedColumn={compactPreviewShowUpdated}
+ compactShowActionsColumn={compactPreviewShowActions}
+ />
+ </li>
+ ))}
+ </ul>
+ <ul
+ role="list"
+ className="grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5"
+ >
+ {filteredPreviewDocuments.map((doc) => (
+ <li key={doc.id}>
+ <DocumentCard
+ document={{
+ id: doc.id,
+ name: doc.name,
+ dataroomDocumentId: doc.dataroomDocumentId,
+ downloadOnly: doc.downloadOnly,
+ canDownload: doc.canDownload,
+ hierarchicalIndex: doc.hierarchicalIndex,
+ versions: doc.versions,
+ }}
+ linkId="1"
+ isPreview={false}
+ allowDownload={false}
+ layout={cardLayout}
+ compactShowUpdatedColumn={compactPreviewShowUpdated}
+ compactShowActionsColumn={compactPreviewShowActions}
+ />
+ </li>
+ ))}
+ </ul>
+ </div>
+ ) : (
+ <div
+ className={cn(
+ cardLayout === "COMPACT" &&
+ "mt-4 border-t border-[var(--viewer-panel-border)]",
+ )}
+ >
+ {cardLayout === "COMPACT" ? (
+ <CompactDataroomListHeader
+ showUpdatedColumn={compactPreviewShowUpdated}
+ showSettingsColumn={compactPreviewShowActions}
+ showIndexColumn
+ />
+ ) : null}
+ <ul className={itemListClassName ?? ""}>
+ {filteredPreviewFolders.map((folder, idx) => (
+ <li key={folder.id}>
+ <FolderCard
+ folder={folder}
+ dataroomId="1"
+ setFolderId={setPreviewFolderId}
+ isPreview={false}
+ linkId="1"
+ allowDownload={false}
+ layout={cardLayout}
+ hideFolderIcons={hideFolderIconsInMain}
+ compactShowUpdatedColumn={
+ compactPreviewShowUpdated
+ }
+ compactShowActionsColumn={
+ compactPreviewShowActions
+ }
+ compactShowIndexColumn={cardLayout === "COMPACT"}
+ editorialIndex={idx}
+ />
+ </li>
+ ))}
+
+ {filteredPreviewDocuments.map((doc, idx) => (
+ <li key={doc.id}>
+ <DocumentCard
+ document={{
+ id: doc.id,
+ name: doc.name,
+ dataroomDocumentId: doc.dataroomDocumentId,
+ downloadOnly: doc.downloadOnly,
+ canDownload: doc.canDownload,
+ hierarchicalIndex: doc.hierarchicalIndex,
+ versions: doc.versions,
+ }}
+ linkId="1"
+ isPreview={false}
+ allowDownload={false}
+ layout={cardLayout}
+ compactShowUpdatedColumn={
+ compactPreviewShowUpdated
+ }
+ compactShowActionsColumn={
+ compactPreviewShowActions
+ }
+ compactShowIndexColumn={cardLayout === "COMPACT"}
+ editorialIndex={
+ filteredPreviewFolders.length + idx
+ }
+ />
+ </li>
+ ))}
+ </ul>
+ </div>
+ )}
</div>
</div>
</div>
diff --git a/pages/view/[linkId]/d/[documentId].tsx b/pages/view/[linkId]/d/[documentId].tsx
index 0920fa57..fecf75f9 100644
--- a/pages/view/[linkId]/d/[documentId].tsx
+++ b/pages/view/[linkId]/d/[documentId].tsx
@@ -229,7 +229,7 @@ export async function getStaticProps(context: GetStaticPropsContext) {
return { notFound: true };
}
- const { linkType, link, brand } = result;
+ const { linkType, link, brand, publicMeta } = result;
if (!link || !linkType) {
return { notFound: true };
@@ -297,11 +297,11 @@ export async function getStaticProps(context: GetStaticPropsContext) {
theme,
},
meta: {
- enableCustomMetatag: link.enableCustomMetatag || false,
- metaTitle: link.metaTitle,
- metaDescription: link.metaDescription,
- metaImage: link.metaImage,
- metaFavicon: link.metaFavicon ?? "/favicon.ico",
+ enableCustomMetatag: publicMeta.enableCustomMetatag,
+ metaTitle: publicMeta.metaTitle,
+ metaDescription: publicMeta.metaDescription,
+ metaImage: publicMeta.metaImage,
+ metaFavicon: publicMeta.metaFavicon,
metaUrl: `https://www.papermark.com/view/${linkId}`,
},
showPoweredByBanner: false,
diff --git a/pages/view/[linkId]/index.tsx b/pages/view/[linkId]/index.tsx
index 8eb5030d..0cb39ce0 100644
--- a/pages/view/[linkId]/index.tsx
+++ b/pages/view/[linkId]/index.tsx
@@ -101,7 +101,7 @@ export const getStaticProps = async (context: GetStaticPropsContext) => {
};
}
- const { linkType, link, brand, dataroomIndexEnabled } = result;
+ const { linkType, link, brand, publicMeta } = result;
if (!linkType) {
return {
@@ -124,12 +124,12 @@ export const getStaticProps = async (context: GetStaticPropsContext) => {
theme: null,
},
meta: {
- enableCustomMetatag: false,
- metaTitle: null,
- metaDescription: null,
- metaImage: null,
+ enableCustomMetatag: publicMeta.enableCustomMetatag,
+ metaTitle: publicMeta.metaTitle,
+ metaDescription: publicMeta.metaDescription,
+ metaImage: publicMeta.metaImage,
metaUrl: `https://www.papermark.com/view/${linkId}`,
- metaFavicon: "/favicon.ico",
+ metaFavicon: publicMeta.metaFavicon,
},
showPoweredByBanner: false,
showAccountCreationSlide: false,
@@ -214,11 +214,11 @@ export const getStaticProps = async (context: GetStaticPropsContext) => {
theme,
},
meta: {
- enableCustomMetatag: link.enableCustomMetatag || false,
- metaTitle: link.metaTitle,
- metaDescription: link.metaDescription,
- metaImage: link.metaImage,
- metaFavicon: link.metaFavicon ?? "/favicon.ico",
+ enableCustomMetatag: publicMeta.enableCustomMetatag,
+ metaTitle: publicMeta.metaTitle,
+ metaDescription: publicMeta.metaDescription,
+ metaImage: publicMeta.metaImage,
+ metaFavicon: publicMeta.metaFavicon,
metaUrl: `https://www.papermark.com/view/${linkId}`,
},
showPoweredByBanner: link.showBanner || teamPlan === "free",
@@ -268,8 +268,9 @@ export const getStaticProps = async (context: GetStaticPropsContext) => {
const { teamId } = link.dataroom;
- // `dataroomIndexEnabled` is resolved server-side by `fetchLinkDataById`.
const featureFlags = await getFeatureFlags({ teamId });
+ const dataroomIndexEnabled =
+ result.dataroomIndexEnabledForViewer ?? false;
const annotationsEnabled = featureFlags.annotations;
const textSelectionEnabled = featureFlags.textSelection;
@@ -299,11 +300,11 @@ export const getStaticProps = async (context: GetStaticPropsContext) => {
brand,
},
meta: {
- enableCustomMetatag: link.enableCustomMetatag || false,
- metaTitle: link.metaTitle,
- metaDescription: link.metaDescription,
- metaImage: link.metaImage,
- metaFavicon: link.metaFavicon ?? "/favicon.ico",
+ enableCustomMetatag: publicMeta.enableCustomMetatag,
+ metaTitle: publicMeta.metaTitle,
+ metaDescription: publicMeta.metaDescription,
+ metaImage: publicMeta.metaImage,
+ metaFavicon: publicMeta.metaFavicon,
metaUrl: `https://www.papermark.com/view/${linkId}`,
},
showPoweredByBanner: false,
diff --git a/pages/view/domains/[domain]/[slug]/d/[documentId].tsx b/pages/view/domains/[domain]/[slug]/d/[documentId].tsx
index 52a143da..ef87609f 100644
--- a/pages/view/domains/[domain]/[slug]/d/[documentId].tsx
+++ b/pages/view/domains/[domain]/[slug]/d/[documentId].tsx
@@ -239,7 +239,7 @@ export async function getStaticProps(context: GetStaticPropsContext) {
return { notFound: true, revalidate: 10 };
}
- const { linkType, link, brand } = result;
+ const { linkType, link, brand, publicMeta } = result;
if (!link || !linkType) {
return { notFound: true, revalidate: 10 };
@@ -308,11 +308,11 @@ export async function getStaticProps(context: GetStaticPropsContext) {
theme,
},
meta: {
- enableCustomMetatag: link.enableCustomMetatag || false,
- metaTitle: link.metaTitle,
- metaDescription: link.metaDescription,
- metaImage: link.metaImage,
- metaFavicon: link.metaFavicon ?? "/favicon.ico",
+ enableCustomMetatag: publicMeta.enableCustomMetatag,
+ metaTitle: publicMeta.metaTitle,
+ metaDescription: publicMeta.metaDescription,
+ metaImage: publicMeta.metaImage,
+ metaFavicon: publicMeta.metaFavicon,
metaUrl: `https://${domain}/${slug}` || null,
},
showPoweredByBanner: false,
diff --git a/pages/view/domains/[domain]/[slug]/index.tsx b/pages/view/domains/[domain]/[slug]/index.tsx
index b1ed5954..42b3030a 100644
--- a/pages/view/domains/[domain]/[slug]/index.tsx
+++ b/pages/view/domains/[domain]/[slug]/index.tsx
@@ -84,7 +84,7 @@ export const getStaticProps = async (context: GetStaticPropsContext) => {
};
}
- const { linkType, link, brand, linkId, dataroomIndexEnabled } = result;
+ const { linkType, link, brand, linkId, publicMeta } = result;
if (!linkType) {
return {
@@ -110,12 +110,12 @@ export const getStaticProps = async (context: GetStaticPropsContext) => {
theme: null,
},
meta: {
- enableCustomMetatag: false,
- metaTitle: null,
- metaDescription: null,
- metaImage: null,
+ enableCustomMetatag: publicMeta.enableCustomMetatag,
+ metaTitle: publicMeta.metaTitle,
+ metaDescription: publicMeta.metaDescription,
+ metaImage: publicMeta.metaImage,
metaUrl: `https://${domain}/${slug}`,
- metaFavicon: "/favicon.ico",
+ metaFavicon: publicMeta.metaFavicon,
},
showPoweredByBanner: false,
showAccountCreationSlide: false,
@@ -190,11 +190,11 @@ export const getStaticProps = async (context: GetStaticPropsContext) => {
theme,
},
meta: {
- enableCustomMetatag: link.enableCustomMetatag || false,
- metaTitle: link.metaTitle,
- metaDescription: link.metaDescription,
- metaImage: link.metaImage,
- metaFavicon: link.metaFavicon || "/favicon.ico",
+ enableCustomMetatag: publicMeta.enableCustomMetatag,
+ metaTitle: publicMeta.metaTitle,
+ metaDescription: publicMeta.metaDescription,
+ metaImage: publicMeta.metaImage,
+ metaFavicon: publicMeta.metaFavicon,
metaUrl: `https://${domain}/${slug}` || null,
},
showAccountCreationSlide: link.showBanner || teamPlan === "free",
@@ -242,8 +242,9 @@ export const getStaticProps = async (context: GetStaticPropsContext) => {
const { teamId } = link.dataroom;
- // `dataroomIndexEnabled` is resolved server-side by `fetchLinkDataByDomainSlug`.
const featureFlags = await getFeatureFlags({ teamId });
+ const dataroomIndexEnabled =
+ result.dataroomIndexEnabledForViewer ?? false;
const textSelectionEnabled = featureFlags.textSelection;
const lastUpdatedAt = link.dataroom.documents.reduce(
@@ -272,11 +273,11 @@ export const getStaticProps = async (context: GetStaticPropsContext) => {
brand,
},
meta: {
- enableCustomMetatag: link.enableCustomMetatag || false,
- metaTitle: link.metaTitle,
- metaDescription: link.metaDescription,
- metaImage: link.metaImage,
- metaFavicon: link.metaFavicon || "/favicon.ico",
+ enableCustomMetatag: publicMeta.enableCustomMetatag,
+ metaTitle: publicMeta.metaTitle,
+ metaDescription: publicMeta.metaDescription,
+ metaImage: publicMeta.metaImage,
+ metaFavicon: publicMeta.metaFavicon,
metaUrl: `https://${domain}/${slug}` || null,
},
showPoweredByBanner: false,
diff --git a/prisma/migrations/20260519000000_add_brand_and_dataroom_layout_branding/migration.sql b/prisma/migrations/20260519000000_add_brand_and_dataroom_layout_branding/migration.sql
new file mode 100644
index 00000000..a70574c4
--- /dev/null
+++ b/prisma/migrations/20260519000000_add_brand_and_dataroom_layout_branding/migration.sql
@@ -0,0 +1,39 @@
+-- Consolidated branding/layout migration.
+-- Layout TEXT values (cardLayout, viewerLayoutPreset, viewerHeaderStyle) are
+-- validated by Zod at the API boundary; allowed values live in
+-- ee/features/branding/lib/dataroom-viewer-layout.ts.
+
+ALTER TABLE "Brand"
+ ADD COLUMN "accentButtonColor" TEXT,
+ ADD COLUMN "ctaLabel" TEXT,
+ ADD COLUMN "ctaUrl" TEXT,
+ ADD COLUMN "cardLayout" TEXT NOT NULL DEFAULT 'LIST',
+ ADD COLUMN "showFolderTree" BOOLEAN NOT NULL DEFAULT true,
+ ADD COLUMN "viewerLayoutPreset" TEXT NOT NULL DEFAULT 'STANDARD',
+ ADD COLUMN "viewerHeaderStyle" TEXT NOT NULL DEFAULT 'DEFAULT',
+ ADD COLUMN "hideFolderIconsInMain" BOOLEAN NOT NULL DEFAULT false,
+ ADD COLUMN "customLinkPreviewEnabled" BOOLEAN NOT NULL DEFAULT false,
+ ADD COLUMN "linkPreviewTitle" TEXT,
+ ADD COLUMN "linkPreviewDescription" TEXT,
+ ADD COLUMN "linkPreviewImage" TEXT,
+ ADD COLUMN "linkPreviewFavicon" TEXT;
+
+ALTER TABLE "DataroomBrand"
+ ADD COLUMN "accentButtonColor" TEXT,
+ ADD COLUMN "cardLayout" TEXT NOT NULL DEFAULT 'LIST',
+ ADD COLUMN "showFolderTree" BOOLEAN NOT NULL DEFAULT true,
+ ADD COLUMN "viewerLayoutPreset" TEXT NOT NULL DEFAULT 'STANDARD',
+ ADD COLUMN "viewerHeaderStyle" TEXT NOT NULL DEFAULT 'DEFAULT',
+ ADD COLUMN "hideFolderIconsInMain" BOOLEAN NOT NULL DEFAULT false,
+ ADD COLUMN "ctaLabel" TEXT,
+ ADD COLUMN "ctaUrl" TEXT,
+ ADD COLUMN "customLinkPreviewEnabled" BOOLEAN NOT NULL DEFAULT false,
+ ADD COLUMN "linkPreviewTitle" TEXT,
+ ADD COLUMN "linkPreviewDescription" TEXT,
+ ADD COLUMN "linkPreviewImage" TEXT,
+ ADD COLUMN "linkPreviewFavicon" TEXT;
+
+-- defaultShowBanner: backfill existing datarooms to false (preserve old
+-- behaviour), then flip default to true for new datarooms.
+ALTER TABLE "Dataroom" ADD COLUMN "defaultShowBanner" BOOLEAN NOT NULL DEFAULT false;
+ALTER TABLE "Dataroom" ALTER COLUMN "defaultShowBanner" SET DEFAULT true;
diff --git a/prisma/schema/dataroom.prisma b/prisma/schema/dataroom.prisma
index 3076ac02..4cda4891 100644
--- a/prisma/schema/dataroom.prisma
+++ b/prisma/schema/dataroom.prisma
@@ -42,10 +42,12 @@ model Dataroom {
// when new documents/folders are added to this dataroom.
defaultPermissionStrategy DefaultPermissionStrategy @default(INHERIT_FROM_PARENT)
- // Default strategy applied to viewer groups (group file permissions) when
- // new documents/folders are added. Kept separate from
- // `defaultPermissionStrategy` so admins can have, for example, links default
- // to inheriting permissions while groups default to hidden.
+ // Seeds the "Show Secured by Papermark" toggle on new links. Pre-existing
+ // datarooms were backfilled to false; new datarooms default to true.
+ defaultShowBanner Boolean @default(true)
+
+ // Default permission strategy for viewer groups. Kept separate from
+ // defaultPermissionStrategy so links and groups can have different defaults.
defaultGroupPermissionStrategy DefaultPermissionStrategy @default(INHERIT_FROM_PARENT)
// bulk download setting
@@ -125,15 +127,32 @@ model DataroomFolder {
}
model DataroomBrand {
- id String @id @default(cuid())
+ id String @id @default(cuid())
logo String? // This should be a reference to where the file is stored (S3, Google Cloud Storage, etc.)
banner String? // This should be a reference to where the file is stored (S3, Google Cloud Storage, etc.)
brandColor String? // This should be a reference to the brand color
- accentColor String? // This should be a reference to the accent color
- applyAccentColorToDataroomView Boolean @default(false) // When true, apply accentColor to dataroom list/tree viewer background
+ accentColor String? // This should be a reference to the accent color (front-page background)
+ accentButtonColor String? // Color used for CTA buttons; falls back to global Brand.accentButtonColor
+ applyAccentColorToDataroomView Boolean @default(false) // When true, apply accentColor to dataroom list/tree viewer background
welcomeMessage String? // This should be a reference to the welcome message
- dataroomId String @unique
- dataroom Dataroom @relation(fields: [dataroomId], references: [id], onDelete: Cascade)
+
+ cardLayout String @default("LIST")
+ showFolderTree Boolean @default(true) // hide folder nav tree when false
+ viewerLayoutPreset String @default("STANDARD")
+ viewerHeaderStyle String @default("DEFAULT")
+ hideFolderIconsInMain Boolean @default(false)
+ ctaLabel String?
+ ctaUrl String?
+
+ // Open Graph / social preview for this dataroom's links (overrides team brand when enabled)
+ customLinkPreviewEnabled Boolean @default(false)
+ linkPreviewTitle String?
+ linkPreviewDescription String?
+ linkPreviewImage String?
+ linkPreviewFavicon String?
+
+ dataroomId String @unique
+ dataroom Dataroom @relation(fields: [dataroomId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
diff --git a/prisma/schema/schema.prisma b/prisma/schema/schema.prisma
index 77a5aa0c..acb760e8 100644
--- a/prisma/schema/schema.prisma
+++ b/prisma/schema/schema.prisma
@@ -81,11 +81,28 @@ model Brand {
logo String? // This should be a reference to where the file is stored (S3, Google Cloud Storage, etc.)
banner String? // Banner image for dataroom view (fallback)
brandColor String? // This should be a reference to the brand color
- accentColor String? // This should be a reference to the accent color
+ accentColor String? // This should be a reference to the accent color (front-page background)
+ accentButtonColor String? // Color used for CTA buttons (separate from brand/background)
applyAccentColorToDataroomView Boolean @default(false) // Global default for whether accentColor applies to dataroom list/tree viewer background
welcomeMessage String? // This should be a reference to the welcome message
- teamId String @unique
- team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
+ ctaLabel String? // Default CTA button label (inherited by datarooms unless overridden)
+ ctaUrl String? // Default CTA button URL (inherited by datarooms unless overridden)
+
+ cardLayout String @default("LIST")
+ showFolderTree Boolean @default(true)
+ viewerLayoutPreset String @default("STANDARD")
+ viewerHeaderStyle String @default("DEFAULT")
+ hideFolderIconsInMain Boolean @default(false)
+
+ // Default Open Graph / social preview for shared links (per-link settings override)
+ customLinkPreviewEnabled Boolean @default(false)
+ linkPreviewTitle String?
+ linkPreviewDescription String?
+ linkPreviewImage String?
+ linkPreviewFavicon String?
+
+ teamId String @unique
+ team Team @relation(fields: [teamId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
diff --git a/prisma/schema/team.prisma b/prisma/schema/team.prisma
index fa5e7da2..b036472f 100644
--- a/prisma/schema/team.prisma
+++ b/prisma/schema/team.prisma
@@ -47,8 +47,8 @@ model Team {
// Populated when a trial is manually extended via the admin script.
trialStartedAt DateTime? // When the trial actually started
trialEndsAt DateTime? // Authoritative trial end timestamp (null = use legacy 7d-from-creation)
- trialReminderRunId String? // Trigger.dev run id for the 24h reminder email
- trialExpiredRunId String? // Trigger.dev run id for the trial-expired task
+ trialReminderRunId String? // Trigger.dev run id for the 24h reminder email
+ trialExpiredRunId String? // Trigger.dev run id for the trial-expired task
limits Json? // Plan limits // {datarooms: 1, users: 1, domains: 1, customDomainOnPro: boolean, customDomainInDataroom: boolean}