The Open Source DocuSign Alternative.
TypeScript digital-signaturedocument-signingdocusign-alternativee-signatureesignesignaturenext-authnextjsopen-sourcepades-standardpdfpdf-signpdf-signaturepostgresqlprismaself-hostedsigningtypescript
fix: add css targets for embeds
Mythie5fac29a07fca
diff --git a/apps/documentation/pages/developers/embedding/css-variables.mdx b/apps/documentation/pages/developers/embedding/css-variables.mdxindex 143967042..d9259545e 100644--- a/apps/documentation/pages/developers/embedding/css-variables.mdx+++ b/apps/documentation/pages/developers/embedding/css-variables.mdx@@ -111,6 +111,83 @@ The colors will be automatically converted to the appropriate format internally.4. **Consistent Radius**: Use a consistent border radius value that matches your application's design system.+## CSS Class Targets++In addition to CSS variables, specific components in the embedded experience can be targeted using CSS classes for more granular styling:++### Component Classes++| Class Name | Description |+| --------------------------------- | ----------------------------------------------------------------------- |+| `.embed--Root` | Main container for the embedded signing experience |+| `.embed--DocumentContainer` | Container for the document and signing widget |+| `.embed--DocumentViewer` | Container for the document viewer |+| `.embed--DocumentWidget` | The signing widget container |+| `.embed--DocumentWidgetContainer` | Outer container for the signing widget, handles positioning |+| `.embed--DocumentWidgetHeader` | Header section of the signing widget |+| `.embed--DocumentWidgetContent` | Main content area of the signing widget |+| `.embed--DocumentWidgetForm` | Form section within the signing widget |+| `.embed--DocumentWidgetFooter` | Footer section of the signing widget |+| `.embed--WaitingForTurn` | Container for the waiting screen when it's not the user's turn to sign |+| `.embed--DocumentCompleted` | Container for the completion screen after signing |+| `.field--FieldRootContainer` | Base container for document fields (signatures, text, checkboxes, etc.) |++Field components also expose several data attributes that can be used for styling different states:++| Data Attribute | Values | Description |+| ------------------- | ---------------------------------------------- | ------------------------------------ |+| `[data-field-type]` | `SIGNATURE`, `TEXT`, `CHECKBOX`, `RADIO`, etc. | The type of field |+| `[data-inserted]` | `true`, `false` | Whether the field has been filled |+| `[data-validate]` | `true`, `false` | Whether the field is being validated |++### Field Styling Example++```css+/* Style all field containers */+.field--FieldRootContainer {+ transition: all 200ms ease;+}++/* Style specific field types */+.field--FieldRootContainer[data-field-type='SIGNATURE'] {+ background-color: rgba(0, 0, 0, 0.02);+}++/* Style inserted fields */+.field--FieldRootContainer[data-inserted='true'] {+ background-color: var(--primary);+ opacity: 0.2;+}++/* Style fields being validated */+.field--FieldRootContainer[data-validate='true'] {+ border-color: orange;+}+```++### Example Usage++```css+/* Custom styles for the document widget */+.embed--DocumentWidget {+ background-color: #ffffff;+ box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);+}++/* Custom styles for the waiting screen */+.embed--WaitingForTurn {+ background-color: #f9fafb;+ padding: 2rem;+}++/* Responsive adjustments for the document container */+@media (min-width: 768px) {+ .embed--DocumentContainer {+ gap: 2rem;+ }+}+```+## Related- [React Integration](/developers/embedding/react)diff --git a/apps/remix/app/components/embed/embed-document-completed.tsx b/apps/remix/app/components/embed/embed-document-completed.tsxindex ed83cdfe8..f334ce644 100644--- a/apps/remix/app/components/embed/embed-document-completed.tsx+++ b/apps/remix/app/components/embed/embed-document-completed.tsx@@ -12,7 +12,7 @@ export type EmbedDocumentCompletedPageProps = {export const EmbedDocumentCompleted = ({ name, signature }: EmbedDocumentCompletedPageProps) => {console.log({ signature });return (- <div className="relative mx-auto flex min-h-[100dvh] max-w-screen-lg flex-col items-center justify-center p-6">+ <div className="embed--DocumentCompleted relative mx-auto flex min-h-[100dvh] max-w-screen-lg flex-col items-center justify-center p-6"><h3 className="text-foreground text-2xl font-semibold"><Trans>Document Completed!</Trans></h3>diff --git a/apps/remix/app/components/embed/embed-document-signing-page.tsx b/apps/remix/app/components/embed/embed-document-signing-page.tsxindex e566a0881..980e80f7a 100644--- a/apps/remix/app/components/embed/embed-document-signing-page.tsx+++ b/apps/remix/app/components/embed/embed-document-signing-page.tsx@@ -225,12 +225,12 @@ export const EmbedSignDocumentClientPage = ({return (<DocumentSigningRecipientProvider recipient={recipient} targetSigner={selectedSigner ?? null}>- <div className="relative mx-auto flex min-h-[100dvh] max-w-screen-lg flex-col items-center justify-center p-6">+ <div className="embed--Root relative mx-auto flex min-h-[100dvh] max-w-screen-lg flex-col items-center justify-center p-6">{(!hasFinishedInit || !hasDocumentLoaded) && <EmbedClientLoading />}- <div className="relative flex w-full flex-col gap-x-6 gap-y-12 md:flex-row">+ <div className="embed--DocumentContainer relative flex w-full flex-col gap-x-6 gap-y-12 md:flex-row">{/* Viewer */}- <div className="flex-1">+ <div className="embed--DocumentViewer flex-1"><LazyPDFViewerdocumentData={documentData}onDocumentLoad={() => setHasDocumentLoaded(true)}@@ -240,12 +240,12 @@ export const EmbedSignDocumentClientPage = ({{/* Widget */}<divkey={isExpanded ? 'expanded' : 'collapsed'}- className="group/document-widget fixed bottom-8 left-0 z-50 h-fit w-full flex-shrink-0 px-6 md:sticky md:top-4 md:z-auto md:w-[350px] md:px-0"+ className="embed--DocumentWidgetContainer group/document-widget fixed bottom-8 left-0 z-50 h-fit w-full flex-shrink-0 px-6 md:sticky md:top-4 md:z-auto md:w-[350px] md:px-0"data-expanded={isExpanded || undefined}>- <div className="border-border bg-widget flex w-full flex-col rounded-xl border px-4 py-4 md:py-6">+ <div className="embed--DocumentWidget border-border bg-widget flex w-full flex-col rounded-xl border px-4 py-4 md:py-6">{/* Header */}- <div>+ <div className="embed--DocumentWidgetHeader"><div className="flex items-center justify-between gap-x-2"><h3 className="text-foreground text-xl font-semibold md:text-2xl">{isAssistantMode ? (@@ -271,7 +271,7 @@ export const EmbedSignDocumentClientPage = ({</div></div>- <div className="hidden group-data-[expanded]/document-widget:block md:block">+ <div className="embed--DocumentWidgetContent hidden group-data-[expanded]/document-widget:block md:block"><p className="text-muted-foreground mt-2 text-sm">{isAssistantMode ? (<Trans>Help complete the document for other signers.</Trans>@@ -284,7 +284,7 @@ export const EmbedSignDocumentClientPage = ({</div>{/* Form */}- <div className="-mx-2 hidden px-2 group-data-[expanded]/document-widget:block md:block">+ <div className="embed--DocumentWidgetForm -mx-2 hidden px-2 group-data-[expanded]/document-widget:block md:block"><div className="flex flex-1 flex-col gap-y-4">{isAssistantMode && (<div>@@ -412,7 +412,7 @@ export const EmbedSignDocumentClientPage = ({<div className="hidden flex-1 group-data-[expanded]/document-widget:block md:block" />- <div className="mt-4 hidden w-full grid-cols-2 items-center group-data-[expanded]/document-widget:grid md:grid">+ <div className="embed--DocumentWidgetFooter mt-4 hidden w-full grid-cols-2 items-center group-data-[expanded]/document-widget:grid md:grid">{pendingFields.length > 0 ? (<Button className="col-start-2" onClick={() => onNextFieldClick()}><Trans>Next</Trans>diff --git a/apps/remix/app/components/embed/embed-document-waiting-for-turn.tsx b/apps/remix/app/components/embed/embed-document-waiting-for-turn.tsxindex a6c2bb199..a0c82cfc2 100644--- a/apps/remix/app/components/embed/embed-document-waiting-for-turn.tsx+++ b/apps/remix/app/components/embed/embed-document-waiting-for-turn.tsx@@ -24,7 +24,7 @@ export const EmbedDocumentWaitingForTurn = () => {}return (- <div className="relative mx-auto flex min-h-[100dvh] max-w-screen-lg flex-col items-center justify-center p-6">+ <div className="embed--WaitingForTurn relative mx-auto flex min-h-[100dvh] max-w-screen-lg flex-col items-center justify-center p-6"><h3 className="text-foreground text-center text-2xl font-bold"><Trans>Waiting for Your Turn</Trans></h3>diff --git a/packages/ui/components/field/field.tsx b/packages/ui/components/field/field.tsxindex bf0607e4d..bc648ccbf 100644--- a/packages/ui/components/field/field.tsx+++ b/packages/ui/components/field/field.tsx@@ -29,7 +29,8 @@ const getCardClassNames = (checkBoxOrRadio: boolean,cardClassName?: string,) => {- const baseClasses = 'field-card-container relative z-20 h-full w-full transition-all';+ const baseClasses =+ 'field--FieldRootContainer field-card-container relative z-20 h-full w-full transition-all';const insertedClasses ='bg-primary/20 border-primary ring-primary/20 ring-offset-primary/20 ring-2 ring-offset-2 dark:shadow-none';@@ -139,6 +140,7 @@ export function FieldRootContainer({ field, children, cardClassName }: FieldCont<Cardid={`field-${field.id}`}ref={ref}+ data-field-type={field.type}data-inserted={field.inserted ? 'true' : 'false'}className={cardClassNames}>