package main
import (
"bytes"
"context"
"fmt"
"git.dev.alexdunmow.com/block/core/templates"
)
// ArtDecoEmailWrapper wraps body content in the Art Deco email layout:
// ivory background, 600px column, jet-black masthead with flat-gold PNG sunburst,
// Cormorant body, gold hairline above footer, reservation phone postscript.
func ArtDecoEmailWrapper(body string, emailCtx templates.EmailContext) string {
var buf bytes.Buffer
_ = artDecoEmailTemplate(emailCtx, body).Render(context.Background(), &buf)
return buf.String()
}
// edColor returns a color from the email context or a hex fallback for the named token.
func edColor(value, fallback string) string {
if value != "" {
return value
}
return fallback
}
// edBg ivory background.
func edBg(emailCtx templates.EmailContext) string {
return edColor(emailCtx.Colors.Background, "#f6efe2")
}
// edCard jet-black masthead surface (uses Foreground as the dark masthead colour).
func edCardDark(emailCtx templates.EmailContext) string {
return edColor(emailCtx.Colors.Foreground, "#191510")
}
// edFg foreground text on the ivory body.
func edFg(emailCtx templates.EmailContext) string {
return edColor(emailCtx.Colors.Foreground, "#191510")
}
// edPrimary champagne-gold accent (used for the hairline and links).
func edPrimary(emailCtx templates.EmailContext) string {
return edColor(emailCtx.Colors.Primary, "#c9a14a")
}
// edMutedFg muted footer text.
func edMutedFg(emailCtx templates.EmailContext) string {
return edColor(emailCtx.Colors.MutedForeground, "#6c5b35")
}
// edBorder hairline gold border colour.
func edBorder(emailCtx templates.EmailContext) string {
return edColor(emailCtx.Colors.Border, "#c9a14a")
}
// flatGoldSunburstSVG is the inlined data: URI for the flat-gold sunburst image
// used as a fallback for the Outlook masthead (CSS conic-gradient is flattened by Outlook).
// We render via string concatenation so the URL-encoded %xx tokens are not misread as fmt verbs.
func flatGoldSunburstSVG(gold string) string {
g := stripHash(gold)
prefix := "data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%20600%2080%22%3E%3Crect%20width%3D%22600%22%20height%3D%2280%22%20fill%3D%22%23191510%22%2F%3E%3Cg%20stroke%3D%22%23"
rays := "%22%20stroke-width%3D%221%22%20fill%3D%22none%22%3E%3Cpath%20d%3D%22M300%2080%20L%20100%2010%22%2F%3E%3Cpath%20d%3D%22M300%2080%20L%20180%2010%22%2F%3E%3Cpath%20d%3D%22M300%2080%20L%20260%2010%22%2F%3E%3Cpath%20d%3D%22M300%2080%20L%20340%2010%22%2F%3E%3Cpath%20d%3D%22M300%2080%20L%20420%2010%22%2F%3E%3Cpath%20d%3D%22M300%2080%20L%20500%2010%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E"
return prefix + g + rays
}
// stripHash removes a leading '#' if present (defensive for the data URI).
func stripHash(s string) string {
if len(s) > 0 && s[0] == '#' {
return s[1:]
}
return s
}
// artDecoEmailTemplate renders the Art Deco email wrapper.
templ artDecoEmailTemplate(emailCtx templates.EmailContext, body string) {
{ emailCtx.SiteSettings.SiteName }
if emailCtx.PreviewText != "" {
{ emailCtx.PreviewText }
}
if emailCtx.SiteSettings.SiteName != "" {
{ emailCtx.SiteSettings.SiteName }
}
|
|
@templ.Raw(body)
|
|
|
{ emailCtx.SiteSettings.SiteName }
if emailCtx.SiteSettings.SiteURL != "" {
{ emailCtx.SiteSettings.SiteURL }
}
if emailCtx.SiteSettings.SupportEmail != "" {
P.S. Reservations & enquiries: { emailCtx.SiteSettings.SupportEmail }
}
if emailCtx.UnsubscribeURL != "" {
Unsubscribe
}
|
|
}