Reorganize repo structure and standards references

This commit is contained in:
david committed 2026-06-29 05:03:42 +02:00
1 parent 3cb93a81be
commit be2054274d
5885 files changed
+2588 -195

No files matched your search

@@ -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>
);
}
@@ -0,0 +1,83 @@
import type { ReactNode } from "react";
import { Layout } from "../components/Layout.js";
import { Button, Footer, Heading, Paragraph, Spacer } from "../components/primitives.js";
export interface ReActivationEmailCopy {
readonly fallbackRecipient: string;
readonly preview: (productName: string) => string;
readonly title: (productName: string) => string;
readonly footerReason: (productName: string) => ReactNode;
readonly unsubscribe: string;
readonly heading: (productName: string) => ReactNode;
readonly greeting: (recipientName: string) => ReactNode;
readonly intro: (productName: string) => ReactNode;
readonly highlightLabel: ReactNode;
readonly defaultCta: string;
readonly replyPrompt: ReactNode;
}
export interface ReActivationEmailProps {
readonly recipientName?: string;
readonly productName: string;
readonly returnUrl: string;
readonly highlight?: string;
readonly unsubscribeUrl: string;
readonly copy?: Partial<ReActivationEmailCopy>;
}
const defaultCopy: ReActivationEmailCopy = {
fallbackRecipient: "there",
preview: (productName) => `We miss you at ${productName}`,
title: (productName) => `We miss you at ${productName}`,
footerReason: (productName) => `We sent this because you previously signed up at ${productName}.`,
unsubscribe: "Unsubscribe",
heading: (productName) => `We miss you at ${productName}`,
greeting: (recipientName) => `Hi ${recipientName},`,
intro: (productName) => `It has been a while since we last saw you at ${productName}. A lot has changed since then.`,
highlightLabel: "What is new:",
defaultCta: "Take another look",
replyPrompt:
"If we are no longer the right fit, no hard feelings - reply with the one feature you wished we had and we will note it.",
};
/**
* "Lost Lead Re-Activation" — triggered by the daily stale-lead cron
* (`lead.stale_60d`). Highlights one new thing since the lead went
* dark and offers a single high-intent CTA to come back.
*/
export function ReActivationEmail({
recipientName,
productName,
returnUrl,
highlight,
unsubscribeUrl,
copy,
}: ReActivationEmailProps) {
const resolvedCopy = { ...defaultCopy, ...copy };
const greetingTarget = recipientName?.trim() || resolvedCopy.fallbackRecipient;
return (
<Layout
previewText={resolvedCopy.preview(productName)}
title={resolvedCopy.title(productName)}
footer={
<Footer>
{resolvedCopy.footerReason(productName)}<br />
<a href={unsubscribeUrl}>{resolvedCopy.unsubscribe}</a>
</Footer>
}
>
<Heading level={1}>{resolvedCopy.heading(productName)}</Heading>
<Paragraph>{resolvedCopy.greeting(greetingTarget)}</Paragraph>
<Paragraph>{resolvedCopy.intro(productName)}</Paragraph>
{highlight ? (
<Paragraph>
<strong>{resolvedCopy.highlightLabel}</strong> {highlight}
</Paragraph>
) : null}
<Spacer size="md" />
<Button href={returnUrl}>{resolvedCopy.defaultCta}</Button>
<Spacer size="md" />
<Paragraph>{resolvedCopy.replyPrompt}</Paragraph>
</Layout>
);
}
@@ -0,0 +1,85 @@
import type { ReactNode } from "react";
import { Layout } from "../components/Layout.js";
import { Button, Footer, Heading, Paragraph, Spacer } from "../components/primitives.js";
export interface TrialReminderEmailCopy {
readonly daySingular: string;
readonly dayPlural: string;
readonly fallbackRecipient: string;
readonly preview: (productName: string, daysRemaining: number, dayWord: string) => string;
readonly title: (daysRemaining: number, dayWord: string) => string;
readonly footerReason: (productName: string) => ReactNode;
readonly unsubscribe: string;
readonly heading: (daysRemaining: number, dayWord: string) => ReactNode;
readonly greeting: (recipientName: string) => ReactNode;
readonly intro: (productName: string, daysRemaining: number, dayWord: string) => ReactNode;
readonly defaultCta: string;
readonly extensionPrompt: ReactNode;
}
export interface TrialReminderEmailProps {
readonly recipientName?: string;
readonly productName: string;
readonly daysRemaining: number;
readonly upgradeUrl: string;
readonly unsubscribeUrl: string;
readonly copy?: Partial<TrialReminderEmailCopy>;
}
const defaultCopy: TrialReminderEmailCopy = {
daySingular: "day",
dayPlural: "days",
fallbackRecipient: "there",
preview: (productName, daysRemaining, dayWord) => `Your ${productName} trial ends in ${daysRemaining} ${dayWord}`,
title: (daysRemaining, dayWord) => `Trial reminder - ${daysRemaining} ${dayWord} left`,
footerReason: (productName) => `Trial reminder from ${productName}.`,
unsubscribe: "Unsubscribe",
heading: (daysRemaining, dayWord) => `${daysRemaining} ${dayWord} left in your trial`,
greeting: (recipientName) => `Hi ${recipientName},`,
intro: (productName, daysRemaining, dayWord) => (
<>
Your {productName} trial ends in <strong>{daysRemaining} {dayWord}</strong>.
Upgrade now to keep your data, integrations and saved workflows.
</>
),
defaultCta: "Upgrade my plan",
extensionPrompt: "Need more time? Reply to this email and we will extend your trial - no questions asked.",
};
/**
* "Trial Expiring" — triggered by `tenant.trial_expiring`. The
* sequence schedules 3 steps (7d, 3d, 1d before expiry) with the same
* template but different `daysRemaining` values.
*/
export function TrialReminderEmail({
recipientName,
productName,
daysRemaining,
upgradeUrl,
unsubscribeUrl,
copy,
}: TrialReminderEmailProps) {
const resolvedCopy = { ...defaultCopy, ...copy };
const greetingTarget = recipientName?.trim() || resolvedCopy.fallbackRecipient;
const dayWord = daysRemaining === 1 ? resolvedCopy.daySingular : resolvedCopy.dayPlural;
return (
<Layout
previewText={resolvedCopy.preview(productName, daysRemaining, dayWord)}
title={resolvedCopy.title(daysRemaining, dayWord)}
footer={
<Footer>
{resolvedCopy.footerReason(productName)}<br />
<a href={unsubscribeUrl}>{resolvedCopy.unsubscribe}</a>
</Footer>
}
>
<Heading level={1}>{resolvedCopy.heading(daysRemaining, dayWord)}</Heading>
<Paragraph>{resolvedCopy.greeting(greetingTarget)}</Paragraph>
<Paragraph>{resolvedCopy.intro(productName, daysRemaining, dayWord)}</Paragraph>
<Spacer size="md" />
<Button href={upgradeUrl}>{resolvedCopy.defaultCta}</Button>
<Spacer size="md" />
<Paragraph>{resolvedCopy.extensionPrompt}</Paragraph>
</Layout>
);
}
@@ -0,0 +1,81 @@
import type { ReactNode } from "react";
import { Layout } from "../components/Layout.js";
import { Button, Footer, Heading, Paragraph, Spacer } from "../components/primitives.js";
export interface WelcomeEmailCopy {
readonly defaultCta: string;
readonly fallbackRecipient: string;
readonly preview: (productName: string) => string;
readonly title: (productName: string) => string;
readonly footerReason: (productName: string) => ReactNode;
readonly unsubscribe: string;
readonly heading: (productName: string) => ReactNode;
readonly greeting: (recipientName: string) => ReactNode;
readonly intro: (productName: string) => ReactNode;
readonly replyPrompt: ReactNode;
readonly signoff: (senderName: string | undefined, productName: string) => ReactNode;
}
export interface WelcomeEmailProps {
readonly recipientName?: string;
readonly productName: string;
readonly ctaUrl: string;
readonly ctaLabel?: string;
readonly unsubscribeUrl: string;
readonly senderName?: string;
readonly copy?: Partial<WelcomeEmailCopy>;
}
const defaultCopy: WelcomeEmailCopy = {
defaultCta: "Get started",
fallbackRecipient: "there",
preview: (productName) => `Welcome to ${productName} - here is what to do next`,
title: (productName) => `Welcome to ${productName}`,
footerReason: (productName) => `You received this email because you signed up at ${productName}.`,
unsubscribe: "Unsubscribe",
heading: (productName) => `Welcome to ${productName}`,
greeting: (recipientName) => `Hi ${recipientName},`,
intro: (productName) =>
`Thanks for joining ${productName}. We help teams ship faster by automating the work that does not need a human. Click the button below to take the first step.`,
replyPrompt: "Reply to this email if you have any questions - a real person is on the other end.",
signoff: (senderName, productName) => `\u2014 ${senderName ?? `The ${productName} team`}`,
};
/**
* "New Lead Welcome" — day-0 introduction email triggered by
* `lead.captured`. Subsequent steps of the same sequence reuse
* `GenericStepEmail` for body variants.
*/
export function WelcomeEmail({
recipientName,
productName,
ctaUrl,
ctaLabel,
unsubscribeUrl,
senderName,
copy,
}: WelcomeEmailProps) {
const resolvedCopy = { ...defaultCopy, ...copy };
const greetingTarget = recipientName?.trim() || resolvedCopy.fallbackRecipient;
return (
<Layout
previewText={resolvedCopy.preview(productName)}
title={resolvedCopy.title(productName)}
footer={
<Footer>
{resolvedCopy.footerReason(productName)}<br />
<a href={unsubscribeUrl}>{resolvedCopy.unsubscribe}</a>
</Footer>
}
>
<Heading level={1}>{resolvedCopy.heading(productName)}</Heading>
<Paragraph>{resolvedCopy.greeting(greetingTarget)}</Paragraph>
<Paragraph>{resolvedCopy.intro(productName)}</Paragraph>
<Spacer size="md" />
<Button href={ctaUrl}>{ctaLabel ?? resolvedCopy.defaultCta}</Button>
<Spacer size="md" />
<Paragraph>{resolvedCopy.replyPrompt}</Paragraph>
<Paragraph>{resolvedCopy.signoff(senderName, productName)}</Paragraph>
</Layout>
);
}