The Open Source DocuSign Alternative.
TypeScript digital-signaturedocument-signingdocusign-alternativee-signatureesignesignaturenext-authnextjsopen-sourcepades-standardpdfpdf-signpdf-signaturepostgresqlprismaself-hostedsigningtypescript
feat: single-player-mode-polish (#435)
David Nguyen6d0e8f6dd897
diff --git a/apps/marketing/src/app/(marketing)/layout.tsx b/apps/marketing/src/app/(marketing)/layout.tsxindex 36241e8e2..365d8a5d1 100644--- a/apps/marketing/src/app/(marketing)/layout.tsx+++ b/apps/marketing/src/app/(marketing)/layout.tsx@@ -2,6 +2,8 @@import React, { useEffect, useState } from 'react';+import { usePathname } from 'next/navigation';+import { cn } from '@documenso/ui/lib/utils';import { Footer } from '~/components/(marketing)/footer';@@ -13,6 +15,7 @@ export type MarketingLayoutProps = {export default function MarketingLayout({ children }: MarketingLayoutProps) {const [scrollY, setScrollY] = useState(0);+ const pathname = usePathname();useEffect(() => {const onScroll = () => {@@ -25,7 +28,11 @@ export default function MarketingLayout({ children }: MarketingLayoutProps) {}, []);return (- <div className="relative max-w-[100vw] overflow-y-auto overflow-x-hidden pt-20 md:pt-28">+ <div+ className={cn('relative max-w-[100vw] pt-20 md:pt-28', {+ 'overflow-y-auto overflow-x-hidden': pathname !== '/singleplayer',+ })}+ ><divclassName={cn('fixed left-0 top-0 z-50 w-full bg-transparent', {'bg-background/50 backdrop-blur-md': scrollY > 5,diff --git a/apps/marketing/src/app/(marketing)/single-player-mode/[token]/success/page.tsx b/apps/marketing/src/app/(marketing)/singleplayer/[token]/success/page.tsxsimilarity index 100%rename from apps/marketing/src/app/(marketing)/single-player-mode/[token]/success/page.tsxrename to apps/marketing/src/app/(marketing)/singleplayer/[token]/success/page.tsxdiff --git a/apps/marketing/src/app/(marketing)/single-player-mode/page.tsx b/apps/marketing/src/app/(marketing)/singleplayer/page.tsxsimilarity index 99%rename from apps/marketing/src/app/(marketing)/single-player-mode/page.tsxrename to apps/marketing/src/app/(marketing)/singleplayer/page.tsxindex 3c76ebac0..0ae72c788 100644--- a/apps/marketing/src/app/(marketing)/single-player-mode/page.tsx+++ b/apps/marketing/src/app/(marketing)/singleplayer/page.tsx@@ -130,7 +130,7 @@ export default function SinglePlayerModePage() {signer: data.email,});- router.push(`/single-player-mode/${documentToken}/success`);+ router.push(`/singleplayer/${documentToken}/success`);} catch {toast({title: 'Something went wrong',diff --git a/apps/marketing/src/components/(marketing)/footer.tsx b/apps/marketing/src/components/(marketing)/footer.tsxindex b1f5e39bf..11d368c22 100644--- a/apps/marketing/src/components/(marketing)/footer.tsx+++ b/apps/marketing/src/components/(marketing)/footer.tsx@@ -23,7 +23,7 @@ const SOCIAL_LINKS = [const FOOTER_LINKS = [{ href: '/pricing', text: 'Pricing' },- { href: '/single-player-mode', text: 'Single Player Mode' },+ { href: '/singleplayer', text: 'Singleplayer' },{ href: '/blog', text: 'Blog' },{ href: '/open', text: 'Open' },{ href: 'https://shop.documenso.com', text: 'Shop', target: '_blank' },diff --git a/apps/marketing/src/components/(marketing)/header.tsx b/apps/marketing/src/components/(marketing)/header.tsxindex 34f1658ac..875f37231 100644--- a/apps/marketing/src/components/(marketing)/header.tsx+++ b/apps/marketing/src/components/(marketing)/header.tsx@@ -29,7 +29,7 @@ export const Header = ({ className, ...props }: HeaderProps) => {{isSinglePlayerModeMarketingEnabled && (<Link- href="/single-player-mode"+ href="/singleplayer"className="bg-primary dark:text-background rounded-full px-2 py-1 text-xs font-semibold sm:px-3">Try now!diff --git a/apps/marketing/src/components/(marketing)/hero.tsx b/apps/marketing/src/components/(marketing)/hero.tsxindex 29bae1b89..88e21bca2 100644--- a/apps/marketing/src/components/(marketing)/hero.tsx+++ b/apps/marketing/src/components/(marketing)/hero.tsx@@ -134,9 +134,9 @@ export const Hero = ({ className, ...props }: HeroProps) => {variants={HeroTitleVariants}initial="initial"animate="animate"- className="border-primary bg-background hover:bg-muted mx-auto mt-8 w-60 rounded-xl border transition duration-300"+ className="border-primary bg-background hover:bg-muted mx-auto mt-8 w-60 rounded-xl border transition-colors duration-300">- <Link href="/single-player-mode" className="block px-4 py-2 text-center">+ <Link href="/singleplayer" className="block px-4 py-2 text-center"><h2 className="text-muted-foreground text-xs font-semibold">Introducing Single Player Mode</h2>diff --git a/apps/marketing/src/components/(marketing)/mobile-navigation.tsx b/apps/marketing/src/components/(marketing)/mobile-navigation.tsxindex c9bd07631..a1897ce58 100644--- a/apps/marketing/src/components/(marketing)/mobile-navigation.tsx+++ b/apps/marketing/src/components/(marketing)/mobile-navigation.tsx@@ -17,8 +17,8 @@ export type MobileNavigationProps = {export const MENU_NAVIGATION_LINKS = [{- href: '/single-player-mode',- text: 'Single Player Mode',+ href: '/singleplayer',+ text: 'Singleplayer',},{href: '/blog',diff --git a/packages/lib/client-only/hooks/use-element-scale-size.ts b/packages/lib/client-only/hooks/use-element-scale-size.tsindex 3e9b34b3f..1c8ab320e 100644--- a/packages/lib/client-only/hooks/use-element-scale-size.ts+++ b/packages/lib/client-only/hooks/use-element-scale-size.ts@@ -60,26 +60,17 @@ export const calculateTextScaleSize = (*/export function useElementScaleSize(container: { width: number; height: number },- child: RefObject<HTMLElement | null>,+ text: string,fontSize: number,fontFamily: string,) {const [scalingFactor, setScalingFactor] = useState(1);useEffect(() => {- if (!child.current) {- return;- }-- const scaleSize = calculateTextScaleSize(- container,- child.current.innerText,- `${fontSize}px`,- fontFamily,- );+ const scaleSize = calculateTextScaleSize(container, text, `${fontSize}px`, fontFamily);setScalingFactor(scaleSize);- }, [child, container, fontFamily, fontSize]);+ }, [text, container, fontFamily, fontSize]);return scalingFactor;}diff --git a/packages/ui/components/signing-card.tsx b/packages/ui/components/signing-card.tsxindex 24a6b6e28..3c65ba9dc 100644--- a/packages/ui/components/signing-card.tsx+++ b/packages/ui/components/signing-card.tsx@@ -56,7 +56,7 @@ export const SigningCard3D = ({ className, name, signingCelebrationImage }: Signconst sheenGradient = useMotionTemplate`linear-gradient(30deg,transparent,- rgba(var(--sheen-color) / ${trackMouse ? sheenOpacity : 0}) ${sheenPosition}%,+ rgba(var(--sheen-color) / ${sheenOpacity}) ${sheenPosition}%,transparent)`;const cardRef = useRef<HTMLDivElement>(null);@@ -98,10 +98,12 @@ export const SigningCard3D = ({ className, name, signingCelebrationImage }: Signvoid animate(cardX, 0, { duration: 2, ease: 'backInOut' });void animate(cardY, 0, { duration: 2, ease: 'backInOut' });+ void animate(sheenOpacity, 0, { duration: 2, ease: 'backInOut' });+setTrackMouse(false);}, 1000);},- [cardX, cardY, cardCenterPosition, trackMouse],+ [cardX, cardY, cardCenterPosition, trackMouse, sheenOpacity],);useEffect(() => {@@ -126,7 +128,6 @@ export const SigningCard3D = ({ className, name, signingCelebrationImage }: SigntransformStyle: 'preserve-3d',rotateX,rotateY,- // willChange: 'transform background-image',}}><SigningCardContent className="bg-transparent" name={name} />diff --git a/packages/ui/primitives/document-flow/single-player-mode-fields.tsx b/packages/ui/primitives/document-flow/single-player-mode-fields.tsxindex 022b05d60..04c093efc 100644--- a/packages/ui/primitives/document-flow/single-player-mode-fields.tsx+++ b/packages/ui/primitives/document-flow/single-player-mode-fields.tsx@@ -70,25 +70,23 @@ export function SinglePlayerModeSignatureField({throw new Error('Invalid field type');}- const $paragraphEl = useRef<HTMLParagraphElement>(null);-const { height, width } = useFieldPageCoords(field);+ const insertedBase64Signature = field.inserted && field.Signature?.signatureImageAsBase64;+ const insertedTypeSignature = field.inserted && field.Signature?.typedSignature;+const scalingFactor = useElementScaleSize({height,width,},- $paragraphEl,+ insertedTypeSignature || '',maxFontSize,fontVariableValue,);const fontSize = maxFontSize * scalingFactor;- const insertedBase64Signature = field.inserted && field.Signature?.signatureImageAsBase64;- const insertedTypeSignature = field.inserted && field.Signature?.typedSignature;-return (<SinglePlayerModeFieldCardContainer field={field}>{insertedBase64Signature ? (@@ -99,7 +97,6 @@ export function SinglePlayerModeSignatureField({/>) : insertedTypeSignature ? (<p- ref={$paragraphEl}style={{fontSize: `clamp(${minFontSize}px, ${fontSize}px, ${maxFontSize}px)`,fontFamily: `var(${fontVariable})`,@@ -145,7 +142,7 @@ export function SinglePlayerModeCustomTextField({height,width,},- $paragraphEl,+ field.customText,maxFontSize,fontVariableValue,);