Mail: donker logo voor dark mode (Email:LogoDarkUrl) en lichte plaat achter het logo
- Optionele Email:LogoDarkUrl, zelfde validatie als LogoUrl; leeg = geen swap - Twee img-klassen; dark-blok verbergt het lichte logo (incl. mso-hide) en toont het donkere - Lichte afgeronde plaat (bgcolor + vlak verloop) achter het logo als vangnet voor clients die media queries negeren of inverteren - ASF: LogoDarkUrl = /admin/brand-logo-on-dark.png (publiek bereikbaar gecontroleerd); SLP leeg (geen on-dark logo) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -227,6 +227,48 @@ public class MailTemplateRendererTests
|
||||
html.Should().Contain($".mail-accent{{color:{dark} !important;");
|
||||
}
|
||||
|
||||
private const string DarkLogo = "https://t.nl/admin/brand-logo-on-dark.png";
|
||||
|
||||
[Fact]
|
||||
public void WithADarkLogo_BothImagesAreThere_AndDarkModeSwapsThem()
|
||||
{
|
||||
var html = _renderer.Render(MailKind.Invitation, "nl", Model() with { LogoDarkUrl = DarkLogo }).Html;
|
||||
|
||||
html.Should().Contain("class=\"mail-logo-light\" src=\"https://t.nl/admin/brand-logo-on-light.png\"")
|
||||
.And.Contain($"class=\"mail-logo-dark\" src=\"{DarkLogo}\"");
|
||||
// the dark logo is hidden by default (with the Outlook safety net) ...
|
||||
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");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WithoutADarkLogo_ThereIsNoSwap_AndTheLightLogoKeepsItsLightPlate()
|
||||
{
|
||||
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)");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ADarkLogoWithoutALightLogo_IsIgnored_AndTheSiteNameIsShown()
|
||||
{
|
||||
var html = _renderer.Render(MailKind.Invitation, "nl", Model() with { LogoUrl = null, LogoDarkUrl = DarkLogo }).Html;
|
||||
|
||||
html.Should().NotContain("brand-logo-on-dark").And.NotContain("mail-logo-dark");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ADarkLogoUrl_IsHtmlEncoded_NotInterpreted()
|
||||
{
|
||||
var html = _renderer.Render(MailKind.Invitation, "nl", Model() with { LogoDarkUrl = "https://t.nl/x.png\"><script>alert(1)</script>" }).Html;
|
||||
|
||||
html.Should().NotContain("<script>").And.Contain("<script>");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheSlpRed_GivesAWhiteButtonText()
|
||||
{
|
||||
|
||||
@@ -116,6 +116,8 @@ public class MailSoftFailureTests
|
||||
[InlineData("Email:Smtp:TimeoutSeconds", "121", "Email:Smtp:TimeoutSeconds")]
|
||||
[InlineData("Email:Smtp:Password", "", "Email:Smtp:Password")]
|
||||
[InlineData("Email:LogoUrl", "javascript:x", "Email:LogoUrl")]
|
||||
[InlineData("Email:LogoDarkUrl", "javascript:x", "Email:LogoDarkUrl")]
|
||||
[InlineData("Email:LogoDarkUrl", "//evil.example/x.png", "Email:LogoDarkUrl")]
|
||||
[InlineData("App:PublicBaseUrl", "", "App:PublicBaseUrl")]
|
||||
[InlineData("App:PublicBaseUrl", "http://example.nl", "App:PublicBaseUrl")]
|
||||
[InlineData("App:DefaultLanguage", "xx", "App:DefaultLanguage")]
|
||||
|
||||
Reference in New Issue
Block a user