Files
outline/server/emails/templates/components/EmailLayout.tsx
T
Tom Moor ba7b6e88e7 fix: Translate access request emails and set email language and direction (#14147)
* fix: Allow every mention notification to be turned off and unsubscribed

- The Mentioned and Group mentions settings now control both the document and comment event types.
- Mention, share, collection invite, and access request emails now have an unsubscribe link and List-Unsubscribe header.

* fix: Translate access request emails and set email language and direction

- The access request email now uses the language of the recipient.
- Emails now set lang and dir on the HTML document, and RTL emails align content to the right.
2026-10-20 20:23:21 -04:00

92 lines
2.1 KiB
TypeScript

import { Table, TBody, TR, TD } from "oy-vey";
import * as React from "react";
import theme from "@shared/styles/theme";
import { DirectionContext } from "./Direction";
const EmailLayout: React.FC<
React.PropsWithChildren<{
bgcolor?: string;
previewText: string;
goToAction?: { url: string; name: string };
}>
> = ({ previewText, bgcolor = "#FFFFFF", goToAction, children }) => {
const dir = React.useContext(DirectionContext);
let markup;
if (goToAction) {
markup = JSON.stringify({
"@context": "http://schema.org",
"@type": "EmailMessage",
potentialAction: {
"@type": "ViewAction",
url: goToAction.url,
name: goToAction.name,
},
});
}
return (
<>
{markup ? (
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: markup }}
/>
) : null}
<Table
bgcolor={bgcolor}
id="__bodyTable__"
width="100%"
style={{
WebkitFontSmoothing: "antialiased",
width: "100% !important",
background: `${bgcolor}`,
WebkitTextSizeAdjust: "none",
margin: 0,
padding: 0,
minWidth: "100%",
}}
>
<TR>
<TD align="center">
<span
style={{
display: "none !important",
color: `${bgcolor}`,
margin: 0,
padding: 0,
fontSize: "1px",
lineHeight: "1px",
}}
>
{previewText}
</span>
<Table width="550">
<TBody>
<TR>
<TD align={dir === "rtl" ? "right" : "left"}>{children}</TD>
</TR>
</TBody>
</Table>
</TD>
</TR>
</Table>
</>
);
};
export default EmailLayout;
export const baseStyles = `
#__bodyTable__ {
font-family: ${theme.fontFamily};
font-size: 16px;
line-height: 1.5;
}
@media (prefers-color-scheme: dark) {
.email-button {
background: #FFFFFF !important;
color: #000000 !important;
}
}
`;