package main
import (
"bytes"
"context"
"fmt"
"git.dev.alexdunmow.com/block/core/templates"
)
// PastelEmailWrapper wraps body content in the Pastel Dream branded email
// frame: cream paper background, watercolor blob watermark, 560px centered
// frame, Caveat Brush masthead, Nunito body, mint CTA pill, unsubscribe and a
// closing affirmation in the footer.
func PastelEmailWrapper(body string, emailCtx templates.EmailContext) string {
var buf bytes.Buffer
_ = pastelEmailTemplate(emailCtx, body).Render(context.Background(), &buf)
return buf.String()
}
// emailColorOr falls back to the supplied default when the EmailContext has
// not been populated with the preset color (e.g. for raw previews).
// All defaults pull from the blush-morning palette, expressed as hex because
// email clients cannot resolve CSS custom properties.
func emailColorOr(value, fallback string) string {
if value == "" {
return fallback
}
return value
}
func pastelEmailBg(c templates.EmailColors) string {
// blush-morning background: hsl(25 60% 98%) ≈ #fdf7f1
return emailColorOr(c.Background, "#fdf7f1")
}
func pastelEmailCard(c templates.EmailColors) string {
return emailColorOr(c.Card, "#ffffff")
}
func pastelEmailForeground(c templates.EmailColors) string {
// hsl(340 20% 22%) ≈ #432e36
return emailColorOr(c.Foreground, "#432e36")
}
func pastelEmailMutedFg(c templates.EmailColors) string {
// hsl(340 12% 48%) ≈ #80707a
return emailColorOr(c.MutedForeground, "#80707a")
}
func pastelEmailPrimary(c templates.EmailColors) string {
// hsl(350 65% 72%) ≈ #e9a1ad
return emailColorOr(c.Primary, "#e9a1ad")
}
func pastelEmailPrimaryFg(c templates.EmailColors) string {
return emailColorOr(c.PrimaryForeground, "#432e36")
}
func pastelEmailBorder(c templates.EmailColors) string {
return emailColorOr(c.Border, "#f0d8de")
}
// pastelEmailTemplate is the Pastel Dream email body template.
templ pastelEmailTemplate(emailCtx templates.EmailContext, body string) {
{ emailCtx.SiteSettings.SiteName }
if emailCtx.PreviewText != "" {
{ emailCtx.PreviewText }
}
if emailCtx.SiteSettings.LogoURL != "" {
} else if emailCtx.SiteSettings.SiteName != "" {
{ emailCtx.SiteSettings.SiteName }
}
|
|
@templ.Raw(body)
|
|
Be gentle with yourself today.
if emailCtx.SiteSettings.SiteURL != "" {
{ emailCtx.SiteSettings.SiteURL }
}
if emailCtx.UnsubscribeURL != "" {
Unsubscribe
}
|
|
}
// pastelEmailPillStyle returns the inline CSS for the mint-tinted CTA pill
// that templates may use inside the body slot. The wrapper exposes it as a
// reusable token because the body is opaque pre-rendered HTML.
func pastelEmailPillStyle(c templates.EmailColors) string {
primary := pastelEmailPrimary(c)
primaryFg := pastelEmailPrimaryFg(c)
return fmt.Sprintf(
"display: inline-block; padding: 12px 28px; border-radius: 9999px; background-color: %s; color: %s; font-family: 'Nunito', Helvetica, Arial, sans-serif; font-weight: 600; text-decoration: none;",
primary,
primaryFg,
)
}