themes-corporate-modernist/email_wrapper.templ
Alex Dunmow 4713787bbd initial: theme plugin corporate-modernist
Bootstrapped during the 2026-06-06 BlockNinja consolidation. Was previously
an unversioned directory inside ~/src/blockninja-themes/corporate-modernist.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-06 14:11:24 +08:00

118 lines
6.0 KiB
Plaintext

package main
import "git.dev.alexdunmow.com/block/core/templates"
// emailWrapperComponent renders the Corporate Modernist email wrapper.
//
// The wrapper is locked to the navy-classic light preset regardless of the
// active site preset (per spec §10) for email-client compatibility. CSS
// custom properties are declared in <head>; every inline `style="…"`
// references them via var(--cm-email-*) with the navy-classic HSL triple
// as the fallback, so:
// - email clients that strip <style> still get the navy-classic colour;
// - the check-safety inline-colour rule is satisfied (each line uses
// var(--…)).
templ emailWrapperComponent(emailCtx templates.EmailContext, body string) {
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="x-apple-disable-message-reformatting"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title>{ emailCtx.SiteSettings.SiteName }</title>
<style type="text/css">
:root {
--cm-email-bg: hsl(220 14% 96%);
--cm-email-surface: hsl(0 0% 100%);
--cm-email-fg: hsl(220 20% 12%);
--cm-email-muted-fg: hsl(220 10% 40%);
--cm-email-border: hsl(220 14% 90%);
--cm-email-accent: hsl(218 65% 22%);
}
body, table, td, p, a, li, blockquote { -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
table, td { mso-table-lspace: 0pt; mso-table-rspace: 0pt; }
img { -ms-interpolation-mode: bicubic; border: 0; height: auto; line-height: 100%; outline: none; text-decoration: none; }
body { margin: 0 !important; padding: 0 !important; width: 100% !important; }
a[x-apple-data-detectors] { color: inherit !important; text-decoration: none !important; }
h1, h2, h3, h4, h5, h6 { font-family: 'Inter Tight', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-weight: 600; letter-spacing: -0.02em; }
@media only screen and (max-width: 620px) {
.cm-email-container { width: 100% !important; max-width: 100% !important; }
.cm-email-padding { padding-left: 24px !important; padding-right: 24px !important; }
}
</style>
</head>
<body style="background-color: var(--cm-email-bg, hsl(220 14% 96%)); margin: 0; padding: 0; font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;">
if emailCtx.PreviewText != "" {
<div style="display: none; max-height: 0; overflow: hidden; mso-hide: all;">
{ emailCtx.PreviewText }
</div>
}
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td align="center" style="padding: 32px 12px; background-color: var(--cm-email-bg, hsl(220 14% 96%));">
<table role="presentation" class="cm-email-container" width="600" cellspacing="0" cellpadding="0" border="0" style="max-width: 600px; width: 600px; background-color: var(--cm-email-surface, hsl(0 0% 100%)); border: 1px solid var(--cm-email-border, hsl(220 14% 90%)); border-collapse: separate;">
<!-- Header: title + single accent rule -->
<tr>
<td class="cm-email-padding" style="padding: 32px 48px 16px 48px; background-color: var(--cm-email-surface, hsl(0 0% 100%));">
if emailCtx.SiteSettings.LogoURL != "" {
<img src={ emailCtx.SiteSettings.LogoURL } alt={ emailCtx.SiteSettings.SiteName } style="max-height: 36px; width: auto; display: block;"/>
} else if emailCtx.SiteSettings.SiteName != "" {
<h1 style="margin: 0; font-size: 20px; font-weight: 600; color: var(--cm-email-fg, hsl(220 20% 12%)); letter-spacing: -0.02em; font-family: 'Inter Tight', 'Inter', sans-serif;">
{ emailCtx.SiteSettings.SiteName }
</h1>
}
</td>
</tr>
<tr>
<td style="padding: 0 48px;">
<div style="height: 2px; background-color: var(--cm-email-accent, hsl(218 65% 22%)); line-height: 2px; font-size: 0;">&nbsp;</div>
</td>
</tr>
<!-- Body -->
<tr>
<td class="cm-email-padding" style="padding: 32px 48px; color: var(--cm-email-fg, hsl(220 20% 12%)); font-size: 16px; line-height: 1.6; font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;">
@templ.Raw(body)
</td>
</tr>
<!-- Footer: legal line + unsubscribe -->
<tr>
<td class="cm-email-padding" style="padding: 24px 48px 32px 48px; border-top: 1px solid var(--cm-email-border, hsl(220 14% 90%));">
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td align="left">
if emailCtx.SiteSettings.SiteName != "" {
<p style="margin: 0 0 6px 0; font-size: 13px; color: var(--cm-email-fg, hsl(220 20% 12%)); font-family: 'Inter Tight', 'Inter', sans-serif; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;">
{ emailCtx.SiteSettings.SiteName }
</p>
}
<p style="margin: 0 0 12px 0; font-size: 12px; color: var(--cm-email-muted-fg, hsl(220 10% 40%)); font-family: 'Inter', sans-serif;">
You are receiving this email because you subscribed to updates.
</p>
if emailCtx.SiteSettings.SiteURL != "" {
<p style="margin: 0 0 8px 0; font-size: 12px;">
<a href={ templ.SafeURL(emailCtx.SiteSettings.SiteURL) } style="color: var(--cm-email-accent, hsl(218 65% 22%)); text-decoration: none;">
{ emailCtx.SiteSettings.SiteURL }
</a>
</p>
}
if emailCtx.UnsubscribeURL != "" {
<p style="margin: 0; font-size: 11px;">
<a href={ templ.SafeURL(emailCtx.UnsubscribeURL) } style="color: var(--cm-email-muted-fg, hsl(220 10% 40%)); text-decoration: underline;">
Unsubscribe
</a>
</p>
}
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
}