Mail: sitenaam naast het logo; dark mode: card zichtbaar lichter dan de pagina plus rand
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -158,8 +158,12 @@ public sealed class MailTemplateRenderer : IMailTemplateRenderer
|
||||
|
||||
private static string E(string value) => WebUtility.HtmlEncode(value);
|
||||
|
||||
private const string DarkPage = "#111827";
|
||||
private const string DarkCard = "#1f2937";
|
||||
// Dark mode mirrors the light layout: the outer page is the darker surface and the card stands out against it
|
||||
// (the earlier #111827 / #1f2937 pair was nearly the same shade, so the card vanished). A 1px border keeps the
|
||||
// edge visible in clients that re-colour the mail themselves (Gmail app, Outlook) and flatten the two backgrounds.
|
||||
public const string DarkPage = "#0a0e14";
|
||||
public const string DarkCard = "#273244";
|
||||
private const string DarkCardBorder = "#475569";
|
||||
|
||||
private static string BuildHtml(
|
||||
MailModel model, string site, string colour, string? greeting, string heading, string intro,
|
||||
@@ -179,7 +183,7 @@ public sealed class MailTemplateRenderer : IMailTemplateRenderer
|
||||
sb.Append("<style>:root{color-scheme:light dark;supported-color-schemes:light dark;}");
|
||||
sb.Append("@media (prefers-color-scheme: dark){");
|
||||
sb.Append($".mail-page{{background:{DarkPage} !important;}}");
|
||||
sb.Append($".mail-card{{background:{DarkCard} !important;color:#f3f4f6 !important;}}");
|
||||
sb.Append($".mail-card{{background:{DarkCard} !important;color:#f3f4f6 !important;border:1px solid {DarkCardBorder} !important;}}");
|
||||
sb.Append($".mail-accent{{color:{dark} !important;border-color:{dark} !important;}}");
|
||||
sb.Append($".mail-btn{{background:{dark} !important;border-color:{dark} !important;}}");
|
||||
sb.Append($".mail-btn a{{background:{dark} !important;color:{darkText} !important;border-color:{darkText} !important;}}");
|
||||
@@ -200,9 +204,13 @@ public sealed class MailTemplateRenderer : IMailTemplateRenderer
|
||||
// The default logo is meant to be a self-contained image (ASF: a white badge baked into the PNG), so it is
|
||||
// readable in every client, also those that invert colours themselves and ignore the dark-mode rules.
|
||||
// With a dark variant, clients that support prefers-color-scheme swap to it.
|
||||
// The site name stands next to the logo (the logo alone does not always say who is writing), so the
|
||||
// name is a separate text cell and the alt text of the images stays the plain site name too.
|
||||
sb.Append("<table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"vertical-align:middle;padding:0 14px 0 0;\">");
|
||||
sb.Append($"<img class=\"mail-logo-light\" src=\"{E(model.LogoUrl)}\" alt=\"{E(site)}\" height=\"56\" style=\"display:block;height:56px;width:auto;border:0;\">");
|
||||
if (hasDarkLogo)
|
||||
sb.Append($"<img class=\"mail-logo-dark\" src=\"{E(model.LogoDarkUrl!)}\" alt=\"{E(site)}\" height=\"48\" style=\"display:none;max-height:0;overflow:hidden;mso-hide:all;height:48px;width:auto;border:0;\">");
|
||||
sb.Append($"</td><td class=\"mail-accent mail-site-name\" style=\"vertical-align:middle;font-size:20px;font-weight:bold;color:{colour};\">{E(site)}</td></tr></table>");
|
||||
}
|
||||
else
|
||||
sb.Append($"<span class=\"mail-accent\" style=\"font-size:20px;font-weight:bold;color:{colour};\">{E(site)}</span>");
|
||||
|
||||
Reference in New Issue
Block a user