Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
feat: document view navbar cta 1c6b
Marc Seitz530b2f39f6f2
diff --git a/components/view/dataroom/dataroom-trailing-actions.tsx b/components/view/dataroom/dataroom-trailing-actions.tsxindex 108a2aaf..3a99ab34 100644--- a/components/view/dataroom/dataroom-trailing-actions.tsx+++ b/components/view/dataroom/dataroom-trailing-actions.tsx@@ -2,6 +2,7 @@ import { BadgeInfoIcon, Download } from "lucide-react";import { useTranslation } from "react-i18next";import { cn } from "@/lib/utils";+import { determineTextColor } from "@/lib/utils/determine-text-color";import { ButtonTooltip } from "@/components/ui/tooltip";import {@@ -89,11 +90,13 @@ export function DataroomTrailingActions({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"+ className="inline-flex items-center justify-center rounded-md px-4 py-2 text-sm font-medium transition-colors hover:opacity-90"style={{backgroundColor:brand?.accentButtonColor || brand?.brandColor || "#111827",- color: "#ffffff",+ color: determineTextColor(+ brand?.accentButtonColor || brand?.brandColor || "#111827",+ ),}}>{brand!.ctaLabel}diff --git a/components/view/nav.tsx b/components/view/nav.tsxindex 67d4fb38..f00d4103 100644--- a/components/view/nav.tsx+++ b/components/view/nav.tsx@@ -19,6 +19,7 @@ import {import { toast } from "sonner";import { createAdaptiveSurfacePalette } from "@/lib/utils/create-adaptive-surface-palette";+import { determineTextColor } from "@/lib/utils/determine-text-color";import { downloadFromLinkEndpoint } from "@/lib/utils/download-document";import {@@ -122,6 +123,25 @@ export default function Nav({const [showConversations, setShowConversations] = useState(false);const navColorPalette = createAdaptiveSurfacePalette(brand?.brandColor);+ const ctaLabel = (brand as { ctaLabel?: string | null } | null | undefined)+ ?.ctaLabel;+ const ctaUrlRaw = (brand as { ctaUrl?: string | null } | null | undefined)+ ?.ctaUrl;+ const accentButtonColor = (+ brand as { accentButtonColor?: string | null } | null | undefined+ )?.accentButtonColor;+ const safeCtaUrl = (() => {+ if (!ctaUrlRaw) return null;+ try {+ const url = new URL(ctaUrlRaw);+ if (url.protocol !== "http:" && url.protocol !== "https:") return null;+ return url.toString();+ } catch {+ return null;+ }+ })();+ const showCta = !!ctaLabel && !!safeCtaUrl;+// Extract the dataroom path from the URL// This regex captures everything before "/d/" in the pathconst dataroomPathMatch = asPath.match(/^(.*?)\/d\//);@@ -250,6 +270,23 @@ export default function Nav({) : null}</div><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">+ {showCta && (+ <a+ href={safeCtaUrl!}+ target="_blank"+ rel="noopener noreferrer"+ className="inline-flex h-8 items-center justify-center rounded-md px-4 text-sm font-medium transition-colors hover:opacity-90 sm:h-10"+ style={{+ backgroundColor:+ accentButtonColor || brand?.brandColor || "#111827",+ color: determineTextColor(+ accentButtonColor || brand?.brandColor || "#111827",+ ),+ }}+ >+ {ctaLabel}+ </a>+ )}{isTeamMember && (<TooltipProvider delayDuration={100}><Tooltip>diff --git a/lib/api/links/link-data.ts b/lib/api/links/link-data.tsindex a59e4b5f..1ed518b1 100644--- a/lib/api/links/link-data.ts+++ b/lib/api/links/link-data.ts@@ -648,7 +648,10 @@ export async function fetchDocumentLinkData({logo: true,brandColor: true,accentColor: true,+ accentButtonColor: true,welcomeMessage: true,+ ctaLabel: true,+ ctaUrl: true,defaultLanguage: true,},});diff --git a/pages/nav_ppreview_demo.tsx b/pages/nav_ppreview_demo.tsxindex 998d9d46..5b55320a 100644--- a/pages/nav_ppreview_demo.tsx+++ b/pages/nav_ppreview_demo.tsx@@ -1,6 +1,7 @@import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";import { useBrandingPreviewParams } from "@/ee/features/branding/lib/use-branding-preview-params";+import { determineTextColor } from "@/lib/utils/determine-text-color";export default function ViewPage() {// Seeded from the URL on first paint, then live-updated over postMessage so@@ -59,10 +60,13 @@ export default function ViewPage() {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"+ className="inline-flex items-center justify-center rounded-md px-4 py-2 text-sm font-medium"style={{backgroundColor:accentButtonColor || brandColor || "#000000",+ color: determineTextColor(+ accentButtonColor || brandColor || "#000000",+ ),}}>{ctaLabel}diff --git a/pages/room_ppreview_demo.tsx b/pages/room_ppreview_demo.tsxindex 9fe1227e..84eded22 100644--- a/pages/room_ppreview_demo.tsx+++ b/pages/room_ppreview_demo.tsx@@ -24,6 +24,7 @@ import {BreadcrumbSeparator,} from "@/components/ui/breadcrumb";import { cn } from "@/lib/utils";+import { determineTextColor } from "@/lib/utils/determine-text-color";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";@@ -476,10 +477,13 @@ export default function ViewPage({ i18n }: ViewerI18nPageProps) {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"+ className="inline-flex shrink-0 items-center justify-center rounded-md px-4 py-2 text-sm font-medium"style={{backgroundColor:accentButtonColor || brandColor || "#111827",+ color: determineTextColor(+ accentButtonColor || brandColor || "#111827",+ ),}}>{ctaLabel}@@ -599,11 +603,13 @@ export default function ViewPage({ i18n }: ViewerI18nPageProps) {href={ctaUrl}target="_blank"rel="noopener noreferrer"- className="inline-flex items-center justify-center px-4 py-2 text-sm font-medium text-white"+ className="inline-flex items-center justify-center px-4 py-2 text-sm font-medium"style={{backgroundColor:accentButtonColor || brandColor || "#ffffff",- color: accentButtonColor ? "#ffffff" : "#000000",+ color: determineTextColor(+ accentButtonColor || brandColor || "#ffffff",+ ),}}>{ctaLabel}