feat: responsive mobile email layouts with native dark mode support
This commit is contained in:
1 parent
fe2f82244d
commit
dad8e07ec5
2 files changed
+60
-18
No files matched your search
@@ -14,33 +14,54 @@ const transporter = nodemailer.createTransport({
|
|||||||
|
|
||||||
function buildHtml(title: string, content: string, button?: { text: string, url: string }) {
|
function buildHtml(title: string, content: string, button?: { text: string, url: string }) {
|
||||||
return `<!DOCTYPE html>
|
return `<!DOCTYPE html>
|
||||||
<html>
|
<html lang="de">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta name="color-scheme" content="light dark">
|
||||||
|
<meta name="supported-color-schemes" content="light dark">
|
||||||
<style>
|
<style>
|
||||||
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background-color: #f4f4f5; color: #18181b; line-height: 1.6; padding: 20px; }
|
:root {
|
||||||
|
color-scheme: light dark;
|
||||||
|
}
|
||||||
|
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background-color: #f4f4f5; color: #18181b; line-height: 1.6; padding: 20px; margin: 0; -webkit-font-smoothing: antialiased; }
|
||||||
.container { max-width: 600px; margin: 0 auto; background: #ffffff; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
|
.container { max-width: 600px; margin: 0 auto; background: #ffffff; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
|
||||||
.header { padding: 32px 32px 0 32px; text-align: center; }
|
.header { padding: 32px 32px 0 32px; text-align: center; }
|
||||||
.header img { max-height: 64px; }
|
.header img { max-height: 64px; max-width: 100%; height: auto; display: block; margin: 0 auto; }
|
||||||
.content { padding: 32px; font-size: 16px; }
|
.dark-logo { display: none; }
|
||||||
|
.content { padding: 32px 20px; font-size: 16px; }
|
||||||
.title { font-size: 24px; font-weight: 700; margin-bottom: 24px; text-align: center; }
|
.title { font-size: 24px; font-weight: 700; margin-bottom: 24px; text-align: center; }
|
||||||
.button { display: inline-block; background-color: #18181b; color: #ffffff !important; padding: 14px 28px; text-decoration: none; border-radius: 8px; font-weight: 600; margin-top: 32px; }
|
.button { display: inline-block; background-color: #18181b; color: #ffffff !important; padding: 14px 28px; text-decoration: none; border-radius: 8px; font-weight: 600; margin-top: 32px; }
|
||||||
.footer { padding: 32px; text-align: center; font-size: 14px; color: #71717a; border-top: 1px solid #e4e4e7; background: #fafafa; }
|
.footer { padding: 32px 20px; text-align: center; font-size: 14px; color: #71717a; border-top: 1px solid #e4e4e7; background: #fafafa; }
|
||||||
.footer a { color: #71717a; text-decoration: underline; margin: 0 8px; }
|
.footer a { color: #71717a; text-decoration: underline; margin: 0 8px; display: inline-block; }
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
body { background-color: #09090b !important; color: #f4f4f5 !important; }
|
||||||
|
.container { background-color: #18181b !important; border: 1px solid #27272a; box-shadow: none !important; }
|
||||||
|
.light-logo { display: none !important; }
|
||||||
|
.dark-logo { display: block !important; }
|
||||||
|
.button { background-color: #fafafa !important; color: #18181b !important; }
|
||||||
|
.footer { background-color: #09090b !important; border-top-color: #27272a !important; color: #a1a1aa !important; }
|
||||||
|
.footer a { color: #a1a1aa !important; }
|
||||||
|
p { color: #d4d4d8 !important; }
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<img src="${env.BETTER_AUTH_URL}/brand/logo-black.png" alt="Logo" />
|
<img src="${env.BETTER_AUTH_URL}/brand/logo-black.png" alt="Logo" class="light-logo" />
|
||||||
|
<!--[if !mso]><!---->
|
||||||
|
<img src="${env.BETTER_AUTH_URL}/brand/logo-white.png" alt="Logo" class="dark-logo" />
|
||||||
|
<!--<![endif]-->
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="title">${title}</div>
|
<div class="title">${title}</div>
|
||||||
<p style="white-space: pre-line; color: #3f3f46; text-align: center;">${content}</p>
|
<p style="white-space: pre-line; text-align: center; margin: 0;">${content}</p>
|
||||||
${button ? `<div style="text-align: center;"><a href="${button.url}" class="button">${button.text}</a></div>` : ''}
|
${button ? `<div style="text-align: center;"><a href="${button.url}" class="button">${button.text}</a></div>` : ''}
|
||||||
</div>
|
</div>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<p>
|
<p style="margin: 0;">
|
||||||
<a href="${env.LEGAL_IMPRINT_URL}">Impressum</a> |
|
<a href="${env.LEGAL_IMPRINT_URL}">Impressum</a> |
|
||||||
<a href="${env.LEGAL_PRIVACY_URL}">Datenschutz</a> |
|
<a href="${env.LEGAL_PRIVACY_URL}">Datenschutz</a> |
|
||||||
<a href="${env.LEGAL_TERMS_URL}">AGB</a>
|
<a href="${env.LEGAL_TERMS_URL}">AGB</a>
|
||||||
|
|||||||
@@ -33,33 +33,54 @@ export function createMailer({ from, transport }: { from: string; transport: Mai
|
|||||||
|
|
||||||
function buildHtml(title: string, content: string, button?: { text: string, url: string }) {
|
function buildHtml(title: string, content: string, button?: { text: string, url: string }) {
|
||||||
return `<!DOCTYPE html>
|
return `<!DOCTYPE html>
|
||||||
<html>
|
<html lang="de">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta name="color-scheme" content="light dark">
|
||||||
|
<meta name="supported-color-schemes" content="light dark">
|
||||||
<style>
|
<style>
|
||||||
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background-color: #f4f4f5; color: #18181b; line-height: 1.6; padding: 20px; }
|
:root {
|
||||||
|
color-scheme: light dark;
|
||||||
|
}
|
||||||
|
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background-color: #f4f4f5; color: #18181b; line-height: 1.6; padding: 20px; margin: 0; -webkit-font-smoothing: antialiased; }
|
||||||
.container { max-width: 600px; margin: 0 auto; background: #ffffff; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
|
.container { max-width: 600px; margin: 0 auto; background: #ffffff; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
|
||||||
.header { padding: 32px 32px 0 32px; text-align: center; }
|
.header { padding: 32px 32px 0 32px; text-align: center; }
|
||||||
.header img { max-height: 64px; }
|
.header img { max-height: 64px; max-width: 100%; height: auto; display: block; margin: 0 auto; }
|
||||||
.content { padding: 32px; font-size: 16px; }
|
.dark-logo { display: none; }
|
||||||
|
.content { padding: 32px 20px; font-size: 16px; }
|
||||||
.title { font-size: 24px; font-weight: 700; margin-bottom: 24px; text-align: center; }
|
.title { font-size: 24px; font-weight: 700; margin-bottom: 24px; text-align: center; }
|
||||||
.button { display: inline-block; background-color: #18181b; color: #ffffff !important; padding: 14px 28px; text-decoration: none; border-radius: 8px; font-weight: 600; margin-top: 32px; }
|
.button { display: inline-block; background-color: #18181b; color: #ffffff !important; padding: 14px 28px; text-decoration: none; border-radius: 8px; font-weight: 600; margin-top: 32px; }
|
||||||
.footer { padding: 32px; text-align: center; font-size: 14px; color: #71717a; border-top: 1px solid #e4e4e7; background: #fafafa; }
|
.footer { padding: 32px 20px; text-align: center; font-size: 14px; color: #71717a; border-top: 1px solid #e4e4e7; background: #fafafa; }
|
||||||
.footer a { color: #71717a; text-decoration: underline; margin: 0 8px; }
|
.footer a { color: #71717a; text-decoration: underline; margin: 0 8px; display: inline-block; }
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
body { background-color: #09090b !important; color: #f4f4f5 !important; }
|
||||||
|
.container { background-color: #18181b !important; border: 1px solid #27272a; box-shadow: none !important; }
|
||||||
|
.light-logo { display: none !important; }
|
||||||
|
.dark-logo { display: block !important; }
|
||||||
|
.button { background-color: #fafafa !important; color: #18181b !important; }
|
||||||
|
.footer { background-color: #09090b !important; border-top-color: #27272a !important; color: #a1a1aa !important; }
|
||||||
|
.footer a { color: #a1a1aa !important; }
|
||||||
|
p { color: #d4d4d8 !important; }
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<img src="${env.BETTER_AUTH_URL}/brand/logo-black.png" alt="Logo" />
|
<img src="${env.BETTER_AUTH_URL}/brand/logo-black.png" alt="Logo" class="light-logo" />
|
||||||
|
<!--[if !mso]><!---->
|
||||||
|
<img src="${env.BETTER_AUTH_URL}/brand/logo-white.png" alt="Logo" class="dark-logo" />
|
||||||
|
<!--<![endif]-->
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="title">${title}</div>
|
<div class="title">${title}</div>
|
||||||
<p style="white-space: pre-line; color: #3f3f46; text-align: center;">${content}</p>
|
<p style="white-space: pre-line; text-align: center; margin: 0;">${content}</p>
|
||||||
${button ? `<div style="text-align: center;"><a href="${button.url}" class="button">${button.text}</a></div>` : ''}
|
${button ? `<div style="text-align: center;"><a href="${button.url}" class="button">${button.text}</a></div>` : ''}
|
||||||
</div>
|
</div>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<p>
|
<p style="margin: 0;">
|
||||||
<a href="${env.LEGAL_IMPRINT_URL}">Impressum</a> |
|
<a href="${env.LEGAL_IMPRINT_URL}">Impressum</a> |
|
||||||
<a href="${env.LEGAL_PRIVACY_URL}">Datenschutz</a> |
|
<a href="${env.LEGAL_PRIVACY_URL}">Datenschutz</a> |
|
||||||
<a href="${env.LEGAL_TERMS_URL}">AGB</a>
|
<a href="${env.LEGAL_TERMS_URL}">AGB</a>
|
||||||
|
|||||||
Reference in new issue
Block a user