Mail-logo als vooraf samengestelde witte badge (geen grijze plaat); succes-toast bij rolwijziging
- themes/asf/logo-mail.png (+ make-mail-logo.py), geleverd als /admin/brand-logo-mail.png; ASF Email:LogoUrl wijst ernaar - Renderer: plaat weggehaald, licht logo 56px, dark-swap naar LogoDarkUrl blijft - UsersPage: toast na geslaagde rolwijziging (nl+en, ook Owner-bevestiging) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -84,7 +84,7 @@ public class HostConfigurationTests
|
||||
config["Email:Smtp:Username"].Should().BeNullOrEmpty();
|
||||
config["Email:Smtp:Password"].Should().BeNullOrEmpty();
|
||||
config["Email:FromAddress"].Should().NotBeNullOrEmpty();
|
||||
config["Email:LogoUrl"].Should().Be("/admin/brand-logo-on-light.png");
|
||||
config["Email:LogoUrl"].Should().Be("/admin/brand-logo-mail.png");
|
||||
config["Email:LogoDarkUrl"].Should().Be("/admin/brand-logo-on-dark.png");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
"FromAddress": "no-reply@slpsoftware.nl",
|
||||
"FromName": "Andrea Slop Fotografie",
|
||||
"AllowedFromAddresses": [],
|
||||
"LogoUrl": "/admin/brand-logo-on-light.png",
|
||||
"LogoUrl": "/admin/brand-logo-mail.png",
|
||||
"LogoDarkUrl": "/admin/brand-logo-on-dark.png",
|
||||
"BrandColor": "#5f6a58",
|
||||
"Smtp": {
|
||||
|
||||
@@ -240,17 +240,19 @@ public class MailTemplateRendererTests
|
||||
html.Should().MatchRegex("class=\"mail-logo-dark\"[^>]*display:none;[^>]*mso-hide:all");
|
||||
// ... and the dark block swaps them and drops the plate
|
||||
html.Should().Contain(".mail-logo-light{display:none !important").And.Contain(".mail-logo-dark{display:block !important")
|
||||
.And.Contain(".mail-plate{background:transparent !important");
|
||||
;
|
||||
html.Should().NotContain("mail-plate"); // no grey plate any more
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WithoutADarkLogo_ThereIsNoSwap_AndTheLightLogoKeepsItsLightPlate()
|
||||
public void WithoutADarkLogo_ThereIsNoSwap_AndNoPlateEither()
|
||||
{
|
||||
var html = _renderer.Render(MailKind.Invitation, "nl", Model()).Html;
|
||||
|
||||
html.Should().NotContain("mail-logo-dark").And.NotContain(".mail-logo-light{").And.NotContain(".mail-plate{");
|
||||
// the plate survives clients that invert backgrounds or ignore the media query
|
||||
html.Should().Contain("class=\"mail-plate\" bgcolor=\"#f3f4f6\"").And.Contain("background-image:linear-gradient(#f3f4f6,#f3f4f6)");
|
||||
html.Should().NotContain("mail-logo-dark").And.NotContain(".mail-logo-light{").And.NotContain("mail-plate")
|
||||
.And.NotContain("#f3f4f6;background-image");
|
||||
// the logo is shown as the image it is (a badge baked into the file), at its display height
|
||||
html.Should().Contain("class=\"mail-logo-light\" src=\"https://t.nl/admin/brand-logo-on-light.png\" alt=\"Andrea Slop Fotografie\" height=\"56\"");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -160,7 +160,6 @@ public sealed class MailTemplateRenderer : IMailTemplateRenderer
|
||||
|
||||
private const string DarkPage = "#111827";
|
||||
private const string DarkCard = "#1f2937";
|
||||
private const string PlateColour = "#f3f4f6";
|
||||
|
||||
private static string BuildHtml(
|
||||
MailModel model, string site, string colour, string? greeting, string heading, string intro,
|
||||
@@ -187,10 +186,9 @@ public sealed class MailTemplateRenderer : IMailTemplateRenderer
|
||||
sb.Append(".mail-muted{color:#9ca3af !important;}.mail-rule{border-color:#374151 !important;}");
|
||||
if (hasDarkLogo)
|
||||
{
|
||||
// Swap: hide the light logo and its plate, show the dark variant.
|
||||
// Swap: hide the light logo, show the dark variant.
|
||||
sb.Append(".mail-logo-light{display:none !important;max-height:0 !important;overflow:hidden !important;mso-hide:all !important;}");
|
||||
sb.Append(".mail-logo-dark{display:block !important;max-height:none !important;overflow:visible !important;mso-hide:none !important;}");
|
||||
sb.Append(".mail-plate{background:transparent !important;background-image:none !important;padding:0 !important;}");
|
||||
}
|
||||
sb.Append("}</style></head>");
|
||||
sb.Append("<body class=\"mail-page\" style=\"margin:0;padding:0;background:#f3f4f6;\">");
|
||||
@@ -199,15 +197,12 @@ public sealed class MailTemplateRenderer : IMailTemplateRenderer
|
||||
sb.Append($"<tr><td class=\"mail-accent\" style=\"padding:24px 32px;border-bottom:3px solid {colour};\">");
|
||||
if (!string.IsNullOrEmpty(model.LogoUrl))
|
||||
{
|
||||
// The light-background logo sits on a light plate (bgcolor + a flat gradient image, which clients that
|
||||
// invert backgrounds, like the Gmail and Outlook apps, leave alone), so it stays readable even when the
|
||||
// client ignores the dark-mode rules. With a dark variant, dark mode swaps the two and drops the plate.
|
||||
sb.Append("<table role=\"presentation\" cellpadding=\"0\" cellspacing=\"0\"><tr>");
|
||||
sb.Append($"<td class=\"mail-plate\" bgcolor=\"{PlateColour}\" style=\"background-color:{PlateColour};background-image:linear-gradient({PlateColour},{PlateColour});border-radius:8px;padding:8px 12px;\">");
|
||||
sb.Append($"<img class=\"mail-logo-light\" src=\"{E(model.LogoUrl)}\" alt=\"{E(site)}\" height=\"48\" style=\"display:block;height:48px;width:auto;border:0;\">");
|
||||
// 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.
|
||||
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></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