Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/packages/mail/src/templates-react/_layout/BaseLayout.tsx
T

90 lines
2.5 KiB
TypeScript

import type { CSSProperties, ReactNode } from "react";
import { Header } from "./Header.js";
import { Footer, type MailFooterCopy, type MailLanguage } from "./Footer.js";
import type { MailBrand } from "./theme.js";
/**
* BaseLayout — root layout for transactional emails. Renders a 560px
* centred card with brand-themed header and footer, plus a hidden
* preview-text harvested by Gmail/Apple Mail as the inbox snippet.
*/
export interface BaseLayoutProps {
readonly brand: MailBrand;
readonly title: string;
readonly previewText?: string;
readonly unsubscribeUrl?: string;
readonly language?: MailLanguage;
readonly footerCopy?: MailFooterCopy;
readonly children: ReactNode;
}
const bodyStyle = (brand: MailBrand): CSSProperties => ({
margin: 0,
padding: 0,
backgroundColor: brand.backgroundColor,
color: brand.textColor,
fontFamily: brand.fontFamily,
fontSize: "16px",
lineHeight: "1.5",
});
const containerStyle: CSSProperties = {
width: "100%",
maxWidth: "560px",
margin: "0 auto",
padding: "32px 14px",
};
const cardStyle = (brand: MailBrand): CSSProperties => ({
backgroundColor: brand.surfaceColor,
border: `1px solid ${brand.borderColor}`,
borderRadius: "22px",
boxShadow: "0 16px 48px rgba(35, 31, 32, 0.08)",
overflow: "hidden",
});
const accentStyle = (brand: MailBrand): CSSProperties => ({
backgroundColor: brand.primaryColor,
height: "7px",
lineHeight: "7px",
});
const contentStyle: CSSProperties = {
padding: "34px 34px 30px",
};
const previewStyle: CSSProperties = {
display: "none",
fontSize: "1px",
lineHeight: "1px",
maxHeight: 0,
maxWidth: 0,
opacity: 0,
overflow: "hidden",
} as CSSProperties;
export function BaseLayout({ brand, title, previewText, unsubscribeUrl, language = "en", footerCopy, children }: BaseLayoutProps) {
return (
<html lang={language}>
<head>
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>{title}</title>
</head>
<body style={bodyStyle(brand)}>
{previewText ? <div style={previewStyle}>{previewText}</div> : null}
<div style={containerStyle}>
<div style={cardStyle(brand)}>
<div style={accentStyle(brand)}>&nbsp;</div>
<div style={contentStyle}>
<Header brand={brand} />
{children}
<Footer brand={brand} unsubscribeUrl={unsubscribeUrl} copy={footerCopy} />
</div>
</div>
</div>
</body>
</html>
);
}