Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
fix(email): emails read correctly in Outlook; every template on the same rules (#2029)
Sidf37d2b4d1f91
diff --git a/.claude/rules/email-design.md b/.claude/rules/email-design.mdindex bc352d1ba1..4551792b00 100644--- a/.claude/rules/email-design.md+++ b/.claude/rules/email-design.md@@ -34,7 +34,7 @@ are label/value details. Every piece below is load-bearing:1. `<EmailThemeProvider preview={<Preview>…</Preview>} additionalHeadContent={<style>{notificationStyles}</style>}>` — the `Preview` is the inbox snippet; the `notificationStyles` are what make dark mode work.2. `<Body className="my-auto mx-auto font-sans nf-body …themeClasses.body">`.-3. `<Container className="my-[40px] mx-auto p-[36px] max-w-[560px] rounded-[16px] nf-card …" style={{ borderRadius: 16, borderStyle: "solid", borderWidth: 1 }}>` — 560px, radius 16, 1px border. On a phone (≤ 600px) the card is the whole screen: `flatCardOnPhones` (`notificationStyles.ts`) drops its border, corners and outer margin and tightens the padding; an email with its own card class (`WeeklyReminderEmail`, `GetStartedEmail`) appends it to its styles.+3. `<Container className="my-[40px] mx-auto p-[36px] max-w-[560px] rounded-[16px] nf-card …" style={{ borderRadius: 16, borderStyle: "solid", borderWidth: 1 }}>` — 560px, radius 16, 1px border. On a phone (≤ 600px) the card is the whole screen: `flatCardOnPhones` (`notificationStyles.ts`) drops its border, corners and outer margin and tightens the padding; an email with its own card class (`WeeklyReminderEmail`, `GetStartedEmail`) appends it to its styles, and the document emails include `documentCardStyles` (`DocumentCard.tsx`).4. `<Logo />` — `carbon-email-mark.png` (ERP `public/`): the white mark on its own dark 80px tile, one image for every client and mode. Gmail's apps and classic Outlook recolour an email themselves and never run the dark CSS, but never recolour an image, so a light/dark logo swap is not used. Its `src` must be PUBLICLY reachable (the recipient's mail client fetches it): production/preview use `getAppUrl()`, anything else (a `crbn up` dev origin, localhost) falls back to `https://app.carbon.ms`. Never delete an image an email has referenced (`carbon-word-dark-outline.png`): mail already sent still loads it.5. **Eyebrow** — `text-[11px] uppercase … nf-eyebrow`, `letterSpacing: "0.14em"`, `mt-[40px] mb-[10px]`. Names the category: "New notification", "Security", "Changelog".6. **Heading** — `text-[26px] font-medium text-center tracking-tight … mb-[32px]`. The action or title, one line.@@ -47,7 +47,8 @@ are label/value details. Every piece below is load-bearing:## Rules that are not style- **No background images, and no page colour in light mode.** Gmail's iOS app ignores the dark-mode media queries and inverts the email's colours itself, but never a background image: a `linear-gradient` card stayed white while its text turned white. `.nf-body` has a colour only in dark mode, and `.nf-card` is a bordered box on the mail app's own background in light mode.-- **The dark palette is Gmail's inversion of the light one.** `emailTheme.dark` (`components/Theme.tsx`) holds the colours Gmail's iOS app produced from the light palette (page `#131314`, callout `#242527`, button `#f3f3f3` on `#202124`, muted `#9fa7b6`), measured from a real screenshot, so Apple Mail and Outlook (which run the dark CSS) show the same email Gmail does. In dark mode the card is the page's colour, set off by its border. `notificationStyles` and `WeeklyReminderEmail` read the palette, never hex literals. Change a light colour and its dark twin changes in Gmail on its own: re-measure and update `emailTheme.dark` to match.+- **The dark palette is Gmail's inversion of the light one.** `emailTheme.dark` (`components/Theme.tsx`) holds the colours Gmail's iOS app produced from the light palette (page `#131314`, callout `#242527`, button `#f3f3f3` on `#202124`, muted `#9fa7b6`), measured from a real screenshot, so Apple Mail (which runs the dark CSS) shows the same email Gmail does. In dark mode the card is the page's colour, set off by its border. `notificationStyles` and `WeeklyReminderEmail` read the palette, never hex literals. Change a light colour and its dark twin changes in Gmail on its own: re-measure and update `emailTheme.dark` to match.+- **Every dark rule sits inside a `prefers-color-scheme: dark` media query.** Outlook (web and the new app) strips that query and recolours the email itself, tagging elements `data-ogsc` / `data-ogsb` as it does. Rules keyed on those tags (and the folklore `.gmail_dark` / `[data-darkmode]` selectors) also fired with the message shown on a light background: a purchase order's panel went dark and its heading and greeting turned white on white. Let Outlook and Gmail do their own dark mode.- **Dark mode is done by CLASS, not inline style.** Backgrounds go through `nf-*` classes so the `!important` media-query overrides in `notificationStyles` can flip them; an inline `background-color` beats them and renders a white card on a black Gmail. Text colors use `getEmailThemeClasses()` (`email-text`, `email-muted`, …). Off-black `#0e0e0e` and off-white `#fefefe`, never pure `#000`/`#fff` — pure values get auto-inverted by some clients.- **No sample defaults on content props.** `NotificationEmail` deliberately gives `heading`/`message` no defaults: fabricated data must never reach a real recipient. Sample data lives in the preview fixture only. (Some older templates — `VerificationEmail` — still default their props; don't copy that, or their pre-card layout.)- **Always send a `text` alternative** alongside `html` — the job builds it from the same content (see `entryEmailContent` in `packages/jobs/src/inngest/functions/tasks/changelog-dispatch.feed.ts`).diff --git a/packages/documents/src/email/InviteEmail.tsx b/packages/documents/src/email/InviteEmail.tsxindex 6e2a62aba2..f5177ab3b5 100644--- a/packages/documents/src/email/InviteEmail.tsx+++ b/packages/documents/src/email/InviteEmail.tsx@@ -6,17 +6,20 @@ import {Body,Container,Heading,+ Hr,Link,Preview,Section,Text} from "react-email";+import { Button } from "./components/Button";import { Logo } from "./components/Logo";+import { notificationStyles } from "./components/notificationStyles";import {- Button,EmailThemeProvider,- getEmailInlineStyles,- getEmailThemeClasses+ emailTheme,+ getEmailThemeClasses,+ HeadStyle} from "./components/Theme";interface Props {@@ -31,6 +34,7 @@ interface Props {controlledEnvironment?: boolean;}+// Sent when an admin invites someone to a company (user-admin job).export const InviteEmail = ({invitedByEmail = "[email protected]",invitedByName = "Tom Sawyer",@@ -42,122 +46,121 @@ export const InviteEmail = ({location = "Tombstone, AZ",controlledEnvironment = false}: Props) => {- const preview = <Preview>{`Join ${companyName} on Carbon`}</Preview>;const themeClasses = getEmailThemeClasses();- const lightStyles = getEmailInlineStyles("light");return (- <EmailThemeProvider preview={preview}>+ <EmailThemeProvider+ preview={<Preview>{`Join ${companyName} on Carbon`}</Preview>}+ additionalHeadContent={<HeadStyle css={notificationStyles} />}+ ><Body- className={`my-auto mx-auto font-sans ${themeClasses.body}`}- style={lightStyles.body}+ className={`my-auto mx-auto font-sans nf-body ${themeClasses.body}`}><Container- className={`my-[40px] mx-auto p-[20px] max-w-[600px] ${themeClasses.container}`}+ className={`my-[40px] mx-auto p-[36px] max-w-[560px] rounded-[16px] nf-card ${themeClasses.container}`}style={{+ borderRadius: 16,borderStyle: "solid",- borderWidth: 1,- borderColor: lightStyles.container.borderColor+ borderWidth: 1}}><Logo />- <Heading- className={`mx-0 my-[30px] p-0 text-[24px] font-normal ${themeClasses.text} text-center`}- style={{ color: lightStyles.text.color }}- >- Join <strong>{companyName}</strong> on <strong>Carbon</strong>- </Heading><Text- className={`text-[14px] leading-[24px] ${themeClasses.text}`}- style={{ color: lightStyles.text.color }}+ className={`text-[11px] leading-[16px] uppercase text-center font-medium m-0 mt-[40px] mb-[10px] nf-eyebrow ${themeClasses.mutedText}`}+ style={{ letterSpacing: "0.14em" }}>- Hi {name ?? ""},+ Invitation</Text>- <Text- className={`text-[14px] leading-[24px] ${themeClasses.text}`}- style={{ color: lightStyles.text.color }}+ <Heading+ className={`text-[26px] font-medium text-center tracking-tight p-0 mt-0 mb-[32px] mx-0 ${themeClasses.heading}`}>- {invitedByName} (- <Link- href={`mailto:${invitedByEmail}`}- className={`${themeClasses.text} no-underline`}- style={{ color: lightStyles.text.color }}- >- {invitedByEmail}- </Link>- ) has invited you to join <strong>{companyName}</strong> on{" "}- <strong>Carbon</strong>.- </Text>- {controlledEnvironment ? (- <Text- className={`text-[14px] leading-[24px] ${themeClasses.text}`}- style={{ color: lightStyles.text.color }}- >- This is an ITAR-controlled environment. Access is restricted to- U.S. Persons.- </Text>+ Join {companyName} on Carbon+ </Heading>++ {name ? (+ <Section>+ <Text+ className={`text-[15px] leading-[26px] m-0 mb-[16px] ${themeClasses.text}`}+ >+ Hi {name},+ </Text>+ </Section>) : null}- <Section className="mb-[42px] mt-[32px] text-center">- <Button href={inviteLink}>Accept Invite</Button>+ <Section+ className="nf-callout"+ style={{+ backgroundColor: "#fafafa",+ borderColor: "#ececef",+ borderRadius: 12,+ borderStyle: "solid",+ borderWidth: 1,+ marginBottom: 28,+ padding: "18px 20px"+ }}+ >+ <table+ role="presentation"+ cellPadding={0}+ cellSpacing={0}+ width="100%"+ style={{ borderCollapse: "collapse", width: "100%" }}+ >+ <tr>+ <td style={{ verticalAlign: "middle" }}>+ <Text+ className={`text-[15px] leading-[24px] m-0 ${themeClasses.text}`}+ >+ {invitedByName} (+ <Link+ href={`mailto:${invitedByEmail}`}+ className={`${themeClasses.text} no-underline`}+ style={{ color: emailTheme.light.foreground }}+ >+ {invitedByEmail}+ </Link>+ ) has invited you to join {companyName} on Carbon.+ </Text>+ {controlledEnvironment ? (+ <Text+ className={`text-[15px] leading-[24px] m-0 mt-[12px] ${themeClasses.text}`}+ >+ This is an ITAR-controlled environment. Access is+ restricted to U.S. Persons.+ </Text>+ ) : null}+ </td>+ </tr>+ </table>+ </Section>++ <Section className="text-center mb-[24px]">+ <Button href={inviteLink}>Accept invite</Button></Section><Text- className={`text-[14px] leading-[24px] ${themeClasses.mutedText} break-all`}- style={{ color: lightStyles.mutedText.color }}+ className={`text-[13px] leading-[20px] m-0 text-center break-all nf-fallback ${themeClasses.mutedText}`}>- You can accept this invite by clicking the button above or by- copying and pasting the following link into your browser:{" "}+ Button not working? Open this link in your browser:{" "}<Linkhref={inviteLink}- className={`${themeClasses.mutedText} underline`}- style={{ color: lightStyles.mutedText.color }}+ className={`${themeClasses.mutedText} underline nf-fallback`}>{inviteLink}</Link></Text>- <br />- <Section>- <Text- className={`text-[12px] leading-[24px] ${themeClasses.mutedText}`}- style={{ color: lightStyles.mutedText.color }}- >- This invitation was intended for{" "}- <span- className={themeClasses.text}- style={{ color: lightStyles.text.color }}- >- {email}- </span>- . This invite was sent from{" "}- <span- className={themeClasses.text}- style={{ color: lightStyles.text.color }}- >- {ip}- </span>{" "}- located in{" "}- <span- className={themeClasses.text}- style={{ color: lightStyles.text.color }}- >- {location}- </span>- . If you were not expecting this invitation, you can ignore this- email. If you are concerned about your account's safety, please- get in touch with us at{" "}- <span- className={themeClasses.text}- style={{ color: lightStyles.text.color }}- >- </span>- .- </Text>- </Section>+ <Hr className={`my-[32px] nf-divider ${themeClasses.border}`} />+ <Text+ className={`text-[12px] leading-[18px] m-0 nf-fallback ${themeClasses.mutedText}`}+ >+ This invite was meant for {email} and was sent from {ip}, located in{" "}+ {location}. If you weren't expecting it, you can ignore this email.+ If you're concerned about your account's safety, contact+ </Text></Container></Body></EmailThemeProvider>diff --git a/packages/documents/src/email/PurchaseOrderEmail.tsx b/packages/documents/src/email/PurchaseOrderEmail.tsxindex d3f89b73da..d62c4a05cd 100644--- a/packages/documents/src/email/PurchaseOrderEmail.tsx+++ b/packages/documents/src/email/PurchaseOrderEmail.tsx@@ -22,7 +22,7 @@ import {getTotal} from "../utils/purchase-order";import { getMoneyFormatter, getRateFormatter } from "../utils/shared";-import { DocumentCard } from "./components/DocumentCard";+import { DocumentCard, documentCardStyles } from "./components/DocumentCard";import {detailText,labelText,@@ -33,7 +33,8 @@ import ExternalNotes from "./components/ExternalNotes";import {EmailThemeProvider,getEmailInlineStyles,- getEmailThemeClasses+ getEmailThemeClasses,+ HeadStyle} from "./components/Theme";interface PurchaseOrderEmailProps extends Email {@@ -100,7 +101,10 @@ const PurchaseOrderEmail = ({);return (- <EmailThemeProvider preview={preview}>+ <EmailThemeProvider+ preview={preview}+ additionalHeadContent={<HeadStyle css={documentCardStyles} />}+ ><BodyclassName={`my-auto mx-auto font-sans ${themeClasses.body}`}style={lightStyles.body}diff --git a/packages/documents/src/email/QuoteEmail.tsx b/packages/documents/src/email/QuoteEmail.tsxindex 987b03aeb6..2315e04738 100644--- a/packages/documents/src/email/QuoteEmail.tsx+++ b/packages/documents/src/email/QuoteEmail.tsx@@ -8,14 +8,15 @@ import { formatDate } from "@carbon/utils";import { Body, Column, Img, Preview, Row, Section, Text } from "react-email";import type { CompanySettings, Email } from "../types";import { getQuoteDisplayId } from "../utils/quote";-import { DocumentCard } from "./components/DocumentCard";+import { DocumentCard, documentCardStyles } from "./components/DocumentCard";import { detailText, labelText } from "./components/documentStyles";import ExternalNotes from "./components/ExternalNotes";import {Button,EmailThemeProvider,getEmailInlineStyles,- getEmailThemeClasses+ getEmailThemeClasses,+ HeadStyle} from "./components/Theme";interface QuoteEmailProps extends Email {@@ -43,7 +44,10 @@ const QuoteEmail = ({const lightStyles = getEmailInlineStyles("light");return (- <EmailThemeProvider preview={preview}>+ <EmailThemeProvider+ preview={preview}+ additionalHeadContent={<HeadStyle css={documentCardStyles} />}+ ><BodyclassName={`my-auto mx-auto font-sans ${themeClasses.body}`}style={lightStyles.body}diff --git a/packages/documents/src/email/SalesInvoiceEmail.tsx b/packages/documents/src/email/SalesInvoiceEmail.tsxindex de3ba44104..27e02649d9 100644--- a/packages/documents/src/email/SalesInvoiceEmail.tsx+++ b/packages/documents/src/email/SalesInvoiceEmail.tsx@@ -26,7 +26,7 @@ import {getTotal} from "../utils/sales-invoice";import { getMoneyFormatter, getRateFormatter } from "../utils/shared";-import { DocumentCard } from "./components/DocumentCard";+import { DocumentCard, documentCardStyles } from "./components/DocumentCard";import {detailText,labelText,@@ -37,7 +37,8 @@ import ExternalNotes from "./components/ExternalNotes";import {EmailThemeProvider,getEmailInlineStyles,- getEmailThemeClasses+ getEmailThemeClasses,+ HeadStyle} from "./components/Theme";interface SalesInvoiceEmailProps extends Email {@@ -89,7 +90,10 @@ const SalesInvoiceEmail = ({const lightStyles = getEmailInlineStyles("light");return (- <EmailThemeProvider preview={preview}>+ <EmailThemeProvider+ preview={preview}+ additionalHeadContent={<HeadStyle css={documentCardStyles} />}+ ><BodyclassName={`my-auto mx-auto font-sans ${themeClasses.body}`}style={lightStyles.body}diff --git a/packages/documents/src/email/SalesOrderEmail.tsx b/packages/documents/src/email/SalesOrderEmail.tsxindex 07d97ddabd..7bc7280491 100644--- a/packages/documents/src/email/SalesOrderEmail.tsx+++ b/packages/documents/src/email/SalesOrderEmail.tsx@@ -22,7 +22,7 @@ import {getTotal} from "../utils/sales-order";import { getMoneyFormatter, getRateFormatter } from "../utils/shared";-import { DocumentCard } from "./components/DocumentCard";+import { DocumentCard, documentCardStyles } from "./components/DocumentCard";import {detailText,labelText,@@ -33,7 +33,8 @@ import ExternalNotes from "./components/ExternalNotes";import {EmailThemeProvider,getEmailInlineStyles,- getEmailThemeClasses+ getEmailThemeClasses,+ HeadStyle} from "./components/Theme";interface SalesOrderEmailProps extends Email {@@ -98,7 +99,10 @@ const SalesOrderEmail = ({);return (- <EmailThemeProvider preview={preview}>+ <EmailThemeProvider+ preview={preview}+ additionalHeadContent={<HeadStyle css={documentCardStyles} />}+ ><BodyclassName={`my-auto mx-auto font-sans ${themeClasses.body}`}style={lightStyles.body}diff --git a/packages/documents/src/email/VerificationEmail.tsx b/packages/documents/src/email/VerificationEmail.tsxindex 425a95d301..66bac8437c 100644--- a/packages/documents/src/email/VerificationEmail.tsx+++ b/packages/documents/src/email/VerificationEmail.tsx@@ -2,12 +2,21 @@// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,// including ports, remain AGPLv3; serving them over a network requires releasing their source.-import { Body, Container, Heading, Preview, Section, Text } from "react-email";+import {+ Body,+ Container,+ Heading,+ Hr,+ Preview,+ Section,+ Text+} from "react-email";import { Logo } from "./components/Logo";+import { notificationStyles } from "./components/notificationStyles";import {EmailThemeProvider,- getEmailInlineStyles,- getEmailThemeClasses+ getEmailThemeClasses,+ HeadStyle} from "./components/Theme";interface Props {@@ -15,88 +24,91 @@ interface Props {verificationCode?: string;}+// The email-verification code (packages/auth verification.server.ts). It+// has no link to follow, so no button: the code is the whole message.export const VerificationEmail = ({email = "[email protected]",verificationCode = "123456"}: Props) => {- const text = `Your verification code is ${verificationCode}`;const themeClasses = getEmailThemeClasses();- const lightStyles = getEmailInlineStyles("light");return (- <EmailThemeProvider preview={<Preview>{text}</Preview>}>+ <EmailThemeProvider+ preview={+ <Preview>{`Your verification code is ${verificationCode}`}</Preview>+ }+ additionalHeadContent={<HeadStyle css={notificationStyles} />}+ ><Body- className={`my-auto mx-auto font-sans ${themeClasses.body}`}- style={lightStyles.body}+ className={`my-auto mx-auto font-sans nf-body ${themeClasses.body}`}><Container- className={`my-[40px] mx-auto p-[20px] max-w-[600px] text-center ${themeClasses.container}`}+ className={`my-[40px] mx-auto p-[36px] max-w-[560px] rounded-[16px] nf-card ${themeClasses.container}`}style={{+ borderRadius: 16,borderStyle: "solid",- borderWidth: 1,- borderColor: lightStyles.container.borderColor+ borderWidth: 1}}><Logo />++ <Text+ className={`text-[11px] leading-[16px] uppercase text-center font-medium m-0 mt-[40px] mb-[10px] nf-eyebrow ${themeClasses.mutedText}`}+ style={{ letterSpacing: "0.14em" }}+ >+ Security+ </Text>+<Heading- className={`text-[21px] font-normal text-center p-0 my-[30px] mx-0 ${themeClasses.heading}`}- style={{ color: lightStyles.text.color }}+ className={`text-[26px] font-medium text-center tracking-tight p-0 mt-0 mb-[32px] mx-0 ${themeClasses.heading}`}>Verify your email address</Heading>- <Text- className={`text-center ${themeClasses.text}`}- style={{ color: lightStyles.text.color }}+ <Section+ className="nf-callout"+ style={{+ backgroundColor: "#fafafa",+ borderColor: "#ececef",+ borderRadius: 12,+ borderStyle: "solid",+ borderWidth: 1,+ marginBottom: 28,+ padding: "18px 20px"+ }}>- We've sent this verification code to{" "}- <span className="font-medium">{email}</span>- </Text>-- <Section className="text-center my-[40px]">- <div- className="email-panel"- style={{- display: "inline-block",- padding: "20px 40px",- backgroundColor: "#f8f9fa",- borderRadius: "8px",- border: "1px solid #e9ecef"- }}+ <table+ role="presentation"+ cellPadding={0}+ cellSpacing={0}+ width="100%"+ style={{ borderCollapse: "collapse", width: "100%" }}>- <Text- className="text-center font-mono email-panel-text"- style={{- fontSize: "32px",- fontWeight: "bold",- letterSpacing: "8px",- color: "#333",- margin: 0- }}- >- {verificationCode}- </Text>- </div>+ <tr>+ <td style={{ verticalAlign: "middle" }}>+ <Text+ className={`text-[15px] leading-[24px] m-0 ${themeClasses.text}`}+ >+ Here is the verification code for {email}.+ </Text>+ <Text+ className={`text-[32px] leading-[40px] font-mono font-medium text-center m-0 mt-[16px] ${themeClasses.heading}`}+ style={{ letterSpacing: "0.3em" }}+ >+ {verificationCode}+ </Text>+ </td>+ </tr>+ </table></Section>+ <Hr className={`my-[32px] nf-divider ${themeClasses.border}`} /><Text- className={`text-center ${themeClasses.text}`}- style={{ color: lightStyles.text.color }}- >- This code will expire in 10 minutes. If you didn't request this- verification code, please ignore this email.- </Text>-- <Text- className={`text-center text-sm mt-[40px] ${themeClasses.text}`}- style={{- color: lightStyles.text.color,- fontSize: "14px",- opacity: 0.7- }}+ className={`text-[12px] leading-[18px] m-0 nf-fallback ${themeClasses.mutedText}`}>- If you're having trouble, you can reply to this email or contact us- at [email protected]+ This code expires in 10 minutes. If you didn't ask for it, you can+ ignore this email. Having trouble? Reply to this email or contact</Text></Container></Body>diff --git a/packages/documents/src/email/WeeklyReminderEmail.tsx b/packages/documents/src/email/WeeklyReminderEmail.tsxindex 98d41fe79d..847d12a14b 100644--- a/packages/documents/src/email/WeeklyReminderEmail.tsx+++ b/packages/documents/src/email/WeeklyReminderEmail.tsx@@ -111,75 +111,6 @@ const weeklyReminderStyles = `color: ${dark.muted} !important;}}-- /* Gmail desktop dark mode targeting */- .gmail_dark .wr-body,- .gmail_dark_theme .wr-body,- [data-darkmode="true"] .wr-body {- background-color: ${dark.background} !important;- }- .gmail_dark .wr-card,- .gmail_dark_theme .wr-card,- [data-darkmode="true"] .wr-card {- background-color: ${dark.background} !important;- border-color: ${dark.border} !important;- }- .gmail_dark .wr-callout,- .gmail_dark_theme .wr-callout,- [data-darkmode="true"] .wr-callout {- background-color: ${dark.panel} !important;- border-color: ${dark.border} !important;- }- .gmail_dark .wr-row-divider,- .gmail_dark_theme .wr-row-divider,- [data-darkmode="true"] .wr-row-divider {- border-top-color: ${dark.border} !important;- }- .gmail_dark .wr-eyebrow,- .gmail_dark_theme .wr-eyebrow,- [data-darkmode="true"] .wr-eyebrow {- color: ${dark.muted} !important;- }- .gmail_dark .wr-status,- .gmail_dark_theme .wr-status,- [data-darkmode="true"] .wr-status {- color: ${dark.muted} !important;- }- .gmail_dark .wr-status-overdue,- .gmail_dark_theme .wr-status-overdue,- [data-darkmode="true"] .wr-status-overdue {- color: #f87171 !important;- }- .gmail_dark .wr-fallback,- .gmail_dark_theme .wr-fallback,- [data-darkmode="true"] .wr-fallback {- color: ${dark.muted} !important;- }-- /* Outlook web/mobile dark mode targeting */- [data-ogsb] .wr-body {- background-color: ${dark.background} !important;- }- [data-ogsb] .wr-card {- background-color: ${dark.background} !important;- border-color: ${dark.border} !important;- }- [data-ogsb] .wr-callout {- background-color: ${dark.panel} !important;- border-color: ${dark.border} !important;- }- [data-ogsc] .wr-eyebrow {- color: ${dark.muted} !important;- }- [data-ogsc] .wr-status {- color: ${dark.muted} !important;- }- [data-ogsc] .wr-status-overdue {- color: #f87171 !important;- }- [data-ogsc] .wr-fallback {- color: ${dark.muted} !important;- }${flatCardOnPhones("wr-card")}`;diff --git a/packages/documents/src/email/components/DocumentCard.tsx b/packages/documents/src/email/components/DocumentCard.tsxindex 775bfc966a..9dd5a70f6d 100644--- a/packages/documents/src/email/components/DocumentCard.tsx+++ b/packages/documents/src/email/components/DocumentCard.tsx@@ -4,8 +4,12 @@import type React from "react";import { Container } from "react-email";+import { flatCardOnPhones } from "./notificationStyles";import { getEmailInlineStyles, getEmailThemeClasses } from "./Theme";+/** The card's phone-width rule, for the document email's <head>. */+export const documentCardStyles = flatCardOnPhones("doc-card", "20px 16px");+// The bordered card a document email sits in. Classic Outlook ignores// max-width, so an MSO-only ghost table holds it to 600px there; every// other client skips the conditional comments. The spans host the comments@@ -20,7 +24,7 @@ export function DocumentCard({ children }: { children: React.ReactNode }) {}}/><Container- className={`mx-auto py-5 px-5 w-full max-w-[600px] ${getEmailThemeClasses().container}`}+ className={`mx-auto py-5 px-5 w-full max-w-[600px] doc-card ${getEmailThemeClasses().container}`}style={{borderStyle: "solid",borderWidth: "1px",diff --git a/packages/documents/src/email/components/Theme.tsx b/packages/documents/src/email/components/Theme.tsxindex 472f5dcbc6..eab45a3c4b 100644--- a/packages/documents/src/email/components/Theme.tsx+++ b/packages/documents/src/email/components/Theme.tsx@@ -164,54 +164,12 @@ export const getEmailDarkModeCSS = () => {}}- /* Outlook Web App and Outlook mobile targeting */- [data-ogsc] .email-text {- color: ${emailTheme.dark.foreground} !important;- }- [data-ogsc] .email-muted {- color: ${emailTheme.dark.muted} !important;- }- [data-ogsc] .email-accent {- color: ${emailTheme.dark.accent} !important;- border-color: ${emailTheme.dark.accent} !important;- }- [data-ogsc] .dark-mode-hide {- display: none !important;- }- [data-ogsc] .dark-mode-show {- display: block !important;- }- [data-ogsc] .email-button {- color: ${emailTheme.dark.accentForeground} !important;- }- [data-ogsb] .email-button {- background-color: ${emailTheme.dark.accent} !important;- border-color: ${emailTheme.dark.accent} !important;- }-- /* Outlook background targeting */- [data-ogsb] .email-body,- [data-ogsb] .email-body > table > tbody > tr > td {- background-color: ${emailTheme.dark.background} !important;- }- [data-ogsb] .email-panel {- background-color: ${emailTheme.dark.panel} !important;- border-color: ${emailTheme.dark.border} !important;- }- [data-ogsc] .email-panel-text {- color: ${emailTheme.dark.foreground} !important;- }- /* Gmail dark mode */- [data-darkmode="true"] .email-panel {- background-color: ${emailTheme.dark.panel} !important;- border-color: ${emailTheme.dark.border} !important;- }- [data-darkmode="true"] .email-panel-text {- color: ${emailTheme.dark.foreground} !important;- }- [data-ogsb] .email-container {- border-color: ${emailTheme.dark.border} !important;- }+ /* Nothing outside a dark media query. Outlook (web and the new app) and+ Gmail's apps recolour an email for dark mode themselves. Outlook tags+ the email with data-ogsc / data-ogsb when it does, and rules keyed on+ those tags also fired with the message shown on a light background: a+ purchase order's panel went dark and its heading turned white on+ white. */`;};diff --git a/packages/documents/src/email/components/notificationStyles.ts b/packages/documents/src/email/components/notificationStyles.tsindex dafa98354b..acf31418dc 100644--- a/packages/documents/src/email/components/notificationStyles.ts+++ b/packages/documents/src/email/components/notificationStyles.ts@@ -11,7 +11,7 @@ const dark = emailTheme.dark;* margin, and less padding. A rounded border hugging the screen's edges* reads as a mistake.*/-export function flatCardOnPhones(card: string) {+export function flatCardOnPhones(card: string, padding = "32px 20px") {return `@media only screen and (max-width: 600px) {.${card} {@@ -21,7 +21,7 @@ export function flatCardOnPhones(card: string) {margin-bottom: 0 !important;}.${card} > tbody > tr > td {- padding: 32px 20px !important;+ padding: ${padding} !important;}}`;@@ -89,69 +89,4 @@ export const notificationStyles = `color: ${dark.muted} !important;}}-- /* Gmail desktop dark mode targeting */- .gmail_dark .nf-body,- .gmail_dark .nf-body > table > tbody > tr > td,- .gmail_dark_theme .nf-body,- .gmail_dark_theme .nf-body > table > tbody > tr > td,- [data-darkmode="true"] .nf-body,- [data-darkmode="true"] .nf-body > table > tbody > tr > td {- background-color: ${dark.background} !important;- }- .gmail_dark .nf-card,- .gmail_dark_theme .nf-card,- [data-darkmode="true"] .nf-card {- background-color: ${dark.background} !important;- border-color: ${dark.border} !important;- }- .gmail_dark .nf-divider,- .gmail_dark_theme .nf-divider,- [data-darkmode="true"] .nf-divider {- border-color: ${dark.border} !important;- }- .gmail_dark .nf-eyebrow,- .gmail_dark_theme .nf-eyebrow,- [data-darkmode="true"] .nf-eyebrow {- color: ${dark.muted} !important;- }- .gmail_dark .nf-callout,- .gmail_dark_theme .nf-callout,- [data-darkmode="true"] .nf-callout {- background-color: ${dark.panel} !important;- border-color: ${dark.border} !important;- }- .gmail_dark .nf-callout-accent,- .gmail_dark_theme .nf-callout-accent,- [data-darkmode="true"] .nf-callout-accent {- background-color: #fefefe !important;- }- .gmail_dark .nf-fallback,- .gmail_dark_theme .nf-fallback,- [data-darkmode="true"] .nf-fallback {- color: ${dark.muted} !important;- }-- /* Outlook web/mobile dark mode targeting */- [data-ogsb] .nf-body,- [data-ogsb] .nf-body > table > tbody > tr > td {- background-color: ${dark.background} !important;- }- [data-ogsb] .nf-card {- background-color: ${dark.background} !important;- border-color: ${dark.border} !important;- }- [data-ogsb] .nf-callout {- background-color: ${dark.panel} !important;- border-color: ${dark.border} !important;- }- [data-ogsc] .nf-eyebrow {- color: ${dark.muted} !important;- }- [data-ogsc] .nf-callout-accent {- background-color: #fefefe !important;- }- [data-ogsc] .nf-fallback {- color: ${dark.muted} !important;- }${flatCardOnPhones("nf-card")}`;