mirror of
https://github.com/outline/outline.git
synced 2026-11-27 16:08:58 +03:00
82 lines
2.2 KiB
TypeScript
82 lines
2.2 KiB
TypeScript
import * as React from "react";
|
|
import theme from "@shared/styles/theme";
|
|
import { DirectionContext } from "./Direction";
|
|
import { Table, TBody, TR, TD } from "./Table";
|
|
|
|
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;
|
|
|
|
// Minified by hand to keep the delivered head styles small.
|
|
const fontFamily = theme.fontFamily.replace(/,\s+/g, ",");
|
|
|
|
export const baseStyles = `#__bodyTable__{font-family:${fontFamily};font-size:16px;line-height:1.5}@media (prefers-color-scheme:dark){.email-button{background:#fff!important;color:#000!important}}`;
|