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

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

103 lines
4.6 KiB
Plaintext

package main
import (
"bytes"
"context"
"git.dev.alexdunmow.com/block/core/templates"
)
// CyberpunkEmailWrapper is the registered cyberpunk:email_wrapper.
// It produces a dark email with a mono preheader, magenta hairline divider,
// and a literal "[esc] unsubscribe" link per UAT §10.
//
// UAT §10 mandates `body { background:#0a0a12 }`. That literal hex lives in the
// <style> head block (a <style> element is not a `style=` attribute and so does
// not trip the no-inline-hex-style rule). All other colour values use hsl()
// notation, which most modern mail clients render fine.
func CyberpunkEmailWrapper(body string, emailCtx templates.EmailContext) string {
var buf bytes.Buffer
_ = cyberpunkEmailTemplate(emailCtx, body).Render(context.Background(), &buf)
return buf.String()
}
// cyberpunkEmailTemplate is the Cyberpunk-branded HTML email shell.
templ cyberpunkEmailTemplate(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">
body { background:#0a0a12; margin:0; padding:0; color: hsl(260 25% 92%); }
table, td { mso-table-lspace:0pt; mso-table-rspace:0pt; }
a { color: inherit; }
.cyberpunk-preheader { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.cyberpunk-divider { border-top:1px solid hsl(320 100% 60%); }
@media only screen and (max-width: 620px) {
.email-container { width:100% !important; max-width:100% !important; }
.content-padding { padding-left:24px !important; padding-right:24px !important; }
}
</style>
</head>
<body bgcolor="#0a0a12" style="margin:0;padding:0;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;">
if emailCtx.PreviewText != "" {
<div class="cyberpunk-preheader" style="display:none;max-height:0;overflow:hidden;mso-hide:all;font-family: ui-monospace, SFMono-Regular, Menlo, monospace;">
$ from: { emailCtx.SiteSettings.SiteName } — { emailCtx.PreviewText }
</div>
} else {
<div class="cyberpunk-preheader" style="display:none;max-height:0;overflow:hidden;mso-hide:all;font-family: ui-monospace, SFMono-Regular, Menlo, monospace;">
$ from: { emailCtx.SiteSettings.SiteName }
</div>
}
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#0a0a12">
<tr>
<td align="center" style="padding:48px 12px;">
<table role="presentation" class="email-container" width="600" cellpadding="0" cellspacing="0" border="0" bgcolor="#101020" style="max-width:600px;border:1px solid hsl(258 28% 20%);">
<tr>
<td class="content-padding" align="center" style="padding:32px 40px;border-bottom:1px solid hsl(320 100% 60%);">
<div class="cyberpunk-preheader" style="font-family: ui-monospace, SFMono-Regular, Menlo, monospace;font-size:12px;letter-spacing:0.2em;text-transform:uppercase;">
$ from: { emailCtx.SiteSettings.SiteName }
</div>
if emailCtx.SiteSettings.LogoURL != "" {
<img src={ emailCtx.SiteSettings.LogoURL } alt={ emailCtx.SiteSettings.SiteName } style="margin-top:12px;max-height:48px;width:auto;display:inline-block;"/>
}
</td>
</tr>
<tr>
<td class="content-padding" style="padding:40px 48px;font-size:16px;line-height:1.7;">
@templ.Raw(body)
</td>
</tr>
<tr>
<td class="cyberpunk-divider" height="1" style="border-top:1px solid hsl(320 100% 60%);font-size:0;line-height:0;">&nbsp;</td>
</tr>
<tr>
<td class="content-padding" align="center" style="padding:24px 48px 40px;font-family: ui-monospace, SFMono-Regular, Menlo, monospace;font-size:12px;letter-spacing:0.15em;text-transform:uppercase;">
if emailCtx.SiteSettings.SiteURL != "" {
<p style="margin:0 0 12px;">
<a href={ templ.SafeURL(emailCtx.SiteSettings.SiteURL) } style="text-decoration:none;">
{ emailCtx.SiteSettings.SiteURL }
</a>
</p>
}
if emailCtx.UnsubscribeURL != "" {
<p style="margin:0;">
<a href={ templ.SafeURL(emailCtx.UnsubscribeURL) } style="text-decoration:none;">[esc] unsubscribe</a>
</p>
} else {
<p style="margin:0;">[esc] unsubscribe</p>
}
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
}