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

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

138 lines
5.3 KiB
Plaintext

package main
import (
"fmt"
"git.dev.alexdunmow.com/block/core/templates"
)
// scifiEmailBgColor / scifiEmailCardColor / scifiEmailBorderColor pull from the
// caller-provided EmailColors so the wrapper inherits the active preset.
func scifiEmailBgColor(c templates.EmailContext) string {
if c.Colors.Background != "" {
return c.Colors.Background
}
return "#F6F7F8"
}
func scifiEmailCardColor(c templates.EmailContext) string {
if c.Colors.Card != "" {
return c.Colors.Card
}
return "#FFFFFF"
}
func scifiEmailBorderColor(c templates.EmailContext) string {
if c.Colors.Border != "" {
return c.Colors.Border
}
return "#D6D9DD"
}
func scifiEmailFgColor(c templates.EmailContext) string {
if c.Colors.Foreground != "" {
return c.Colors.Foreground
}
return "#16202E"
}
func scifiEmailMutedColor(c templates.EmailContext) string {
if c.Colors.MutedForeground != "" {
return c.Colors.MutedForeground
}
return "#5C6776"
}
func scifiEmailCallsign(c templates.EmailContext) string {
if c.SiteSettings.SiteName != "" {
return "SCF / " + c.SiteSettings.SiteName
}
return "SCF-CLN"
}
// scifiEmailTemplate is the Sci-Fi Clean branded email wrapper.
templ scifiEmailTemplate(emailCtx templates.EmailContext, body string) {
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="x-apple-disable-message-reformatting"/>
<title>{ emailCtx.SiteSettings.SiteName }</title>
<style type="text/css">
body, table, td, p, a, li {
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
img { border: 0; height: auto; outline: none; text-decoration: none; }
body { margin: 0 !important; padding: 0 !important; width: 100% !important; }
/* Mono numeral preservation across clients. */
.scifi-num {
font-family: ui-monospace, "JetBrains Mono", "Menlo", monospace !important;
font-variant-numeric: tabular-nums;
}
@media only screen and (max-width: 620px) {
.scifi-email-container { width: 100% !important; max-width: 100% !important; }
.scifi-pad { padding-left: 20px !important; padding-right: 20px !important; }
}
</style>
</head>
<body style={ fmt.Sprintf("background-color: %s; margin: 0; padding: 0; font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: %s;", scifiEmailBgColor(emailCtx), scifiEmailFgColor(emailCtx)) }>
if emailCtx.PreviewText != "" {
<div style="display: none; max-height: 0; overflow: hidden;">{ emailCtx.PreviewText }</div>
}
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td align="center" style={ fmt.Sprintf("padding: 32px 12px; background-color: %s;", scifiEmailBgColor(emailCtx)) }>
<table
role="presentation"
class="scifi-email-container"
width="600"
cellspacing="0"
cellpadding="0"
border="0"
style={ fmt.Sprintf("max-width: 600px; background-color: %s; border: 1px solid %s;", scifiEmailCardColor(emailCtx), scifiEmailBorderColor(emailCtx)) }
>
<tr>
<td class="scifi-pad" style={ fmt.Sprintf("padding: 20px 28px; border-bottom: 1px solid %s;", scifiEmailBorderColor(emailCtx)) }>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td align="left" style={ fmt.Sprintf("font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 600; font-size: 16px; letter-spacing: 0.02em; color: %s;", scifiEmailFgColor(emailCtx)) }>
{ emailCtx.SiteSettings.SiteName }
</td>
<td align="right" class="scifi-num" style={ fmt.Sprintf("font-family: ui-monospace, 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: %s;", scifiEmailMutedColor(emailCtx)) }>
{ scifiEmailCallsign(emailCtx) }
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="scifi-pad" style={ fmt.Sprintf("padding: 28px; font-size: 15px; line-height: 1.55; color: %s;", scifiEmailFgColor(emailCtx)) }>
@templ.Raw(body)
</td>
</tr>
<tr>
<td class="scifi-pad" style={ fmt.Sprintf("padding: 16px 28px; border-top: 1px solid %s; background-color: %s;", scifiEmailBorderColor(emailCtx), scifiEmailCardColor(emailCtx)) }>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td class="scifi-num" align="left" style={ fmt.Sprintf("font-family: ui-monospace, 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: %s;", scifiEmailMutedColor(emailCtx)) }>
{ emailCtx.SiteSettings.SiteURL }
</td>
if emailCtx.UnsubscribeURL != "" {
<td class="scifi-num" align="right" style={ fmt.Sprintf("font-family: ui-monospace, 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;") }>
<a href={ templ.SafeURL(emailCtx.UnsubscribeURL) } style={ fmt.Sprintf("color: %s; text-decoration: underline;", scifiEmailMutedColor(emailCtx)) }>Unsubscribe</a>
</td>
}
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
}