Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
+86
@@ -0,0 +1,86 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { Layout } from "../components/Layout.js";
|
||||
import { Button, Footer, Heading, Paragraph, Spacer } from "../components/primitives.js";
|
||||
|
||||
export interface GenericStepEmailCopy {
|
||||
readonly defaultCta: string;
|
||||
readonly fallbackRecipient: string;
|
||||
readonly footerReason: (productName: string) => ReactNode;
|
||||
readonly unsubscribe: string;
|
||||
readonly greeting: (recipientName: string) => ReactNode;
|
||||
readonly signoff: (productName: string) => ReactNode;
|
||||
}
|
||||
|
||||
export interface GenericStepEmailProps {
|
||||
readonly recipientName?: string;
|
||||
readonly productName: string;
|
||||
readonly headline: string;
|
||||
/**
|
||||
* Body paragraphs. Each entry is rendered as a separate <Paragraph>.
|
||||
* Markdown is intentionally NOT supported here — the admin UI passes
|
||||
* plain text and trusted variables only.
|
||||
*/
|
||||
readonly bodyParagraphs: readonly string[];
|
||||
readonly ctaUrl?: string;
|
||||
readonly ctaLabel?: string;
|
||||
readonly unsubscribeUrl: string;
|
||||
readonly preface?: ReactNode;
|
||||
readonly copy?: Partial<GenericStepEmailCopy>;
|
||||
}
|
||||
|
||||
const defaultCopy: GenericStepEmailCopy = {
|
||||
defaultCta: "Open dashboard",
|
||||
fallbackRecipient: "there",
|
||||
footerReason: (productName) => `You receive this email because you signed up at ${productName}.`,
|
||||
unsubscribe: "Unsubscribe",
|
||||
greeting: (recipientName) => `Hi ${recipientName},`,
|
||||
signoff: (productName) => `\u2014 The ${productName} team`,
|
||||
};
|
||||
|
||||
/**
|
||||
* Configurable step template used for the onboarding-drip and for any
|
||||
* generic-step in an operator-defined sequence. Variables are passed
|
||||
* pre-substituted by the engine; React escapes everything it renders
|
||||
* so there is no XSS risk from PII in `bodyParagraphs`.
|
||||
*/
|
||||
export function GenericStepEmail({
|
||||
recipientName,
|
||||
productName,
|
||||
headline,
|
||||
bodyParagraphs,
|
||||
ctaUrl,
|
||||
ctaLabel,
|
||||
unsubscribeUrl,
|
||||
preface,
|
||||
copy,
|
||||
}: GenericStepEmailProps) {
|
||||
const resolvedCopy = { ...defaultCopy, ...copy };
|
||||
const greetingTarget = recipientName?.trim() || resolvedCopy.fallbackRecipient;
|
||||
return (
|
||||
<Layout
|
||||
previewText={headline}
|
||||
title={headline}
|
||||
footer={
|
||||
<Footer>
|
||||
{resolvedCopy.footerReason(productName)}<br />
|
||||
<a href={unsubscribeUrl}>{resolvedCopy.unsubscribe}</a>
|
||||
</Footer>
|
||||
}
|
||||
>
|
||||
<Heading level={1}>{headline}</Heading>
|
||||
<Paragraph>{resolvedCopy.greeting(greetingTarget)}</Paragraph>
|
||||
{preface ?? null}
|
||||
{bodyParagraphs.map((line, idx) => (
|
||||
<Paragraph key={idx}>{line}</Paragraph>
|
||||
))}
|
||||
{ctaUrl ? (
|
||||
<>
|
||||
<Spacer size="md" />
|
||||
<Button href={ctaUrl}>{ctaLabel ?? resolvedCopy.defaultCta}</Button>
|
||||
<Spacer size="md" />
|
||||
</>
|
||||
) : null}
|
||||
<Paragraph>{resolvedCopy.signoff(productName)}</Paragraph>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user