email: premium HTML template with accent colour and copy affordance

Redesigns the mail template (branded header bar, hero code block, copy
button, muted footer) and adds a configurable accent colour alongside the
brand name.
This commit is contained in:
Jean Chevronnet 2026-07-12 16:07:36 +00:00
parent 06e9da4dc8
commit 98630c7d36
No known key found for this signature in database
7 changed files with 63 additions and 22 deletions

View file

@ -9,15 +9,16 @@ pub struct Mail {
const BASE: &str = include_str!("../templates/email/base.html");
fn render(brand: &str, title: &str, message: &str, code: &str, note: &str) -> String {
fn render(brand: &str, accent: &str, title: &str, message: &str, code: &str, note: &str) -> String {
BASE.replace("{{brand}}", &escape(brand))
.replace("{{accent}}", &escape(accent))
.replace("{{title}}", &escape(title))
.replace("{{message}}", &escape(message))
.replace("{{code}}", &escape(code))
.replace("{{note}}", &escape(note))
}
pub fn reset(brand: &str, account: &str, code: &str) -> Mail {
pub fn reset(brand: &str, accent: &str, account: &str, code: &str) -> Mail {
Mail {
subject: format!("Password reset for {account}"),
text: format!(
@ -25,15 +26,16 @@ pub fn reset(brand: &str, account: &str, code: &str) -> Mail {
),
html: render(
brand,
accent,
"Password reset",
&format!("Use this code to reset the password for your account {account}."),
code,
"This code expires in 15 minutes.",
"This code expires in 15 minutes. If you didn't ask to reset it, ignore this email.",
),
}
}
pub fn confirm(brand: &str, account: &str, code: &str) -> Mail {
pub fn confirm(brand: &str, accent: &str, account: &str, code: &str) -> Mail {
Mail {
subject: format!("Confirm your {account} registration"),
text: format!(
@ -41,6 +43,7 @@ pub fn confirm(brand: &str, account: &str, code: &str) -> Mail {
),
html: render(
brand,
accent,
"Confirm your account",
&format!("Welcome! Confirm the email for your account {account} with the code below."),
code,