diff --git a/src/SlpModularCms.Api.AndreaSlopFotografie.Tests/HostConfigurationTests.cs b/src/SlpModularCms.Api.AndreaSlopFotografie.Tests/HostConfigurationTests.cs
index cfc1588..de0ea90 100644
--- a/src/SlpModularCms.Api.AndreaSlopFotografie.Tests/HostConfigurationTests.cs
+++ b/src/SlpModularCms.Api.AndreaSlopFotografie.Tests/HostConfigurationTests.cs
@@ -85,5 +85,6 @@ public class HostConfigurationTests
config["Email:Smtp:Password"].Should().BeNullOrEmpty();
config["Email:FromAddress"].Should().NotBeNullOrEmpty();
config["Email:LogoUrl"].Should().Be("/admin/brand-logo-on-light.png");
+ config["Email:LogoDarkUrl"].Should().Be("/admin/brand-logo-on-dark.png");
}
}
diff --git a/src/SlpModularCms.Api.AndreaSlopFotografie/appsettings.json b/src/SlpModularCms.Api.AndreaSlopFotografie/appsettings.json
index 6343757..9840e68 100644
--- a/src/SlpModularCms.Api.AndreaSlopFotografie/appsettings.json
+++ b/src/SlpModularCms.Api.AndreaSlopFotografie/appsettings.json
@@ -58,6 +58,7 @@
"FromName": "Andrea Slop Fotografie",
"AllowedFromAddresses": [],
"LogoUrl": "/admin/brand-logo-on-light.png",
+ "LogoDarkUrl": "/admin/brand-logo-on-dark.png",
"BrandColor": "#5f6a58",
"Smtp": {
"Host": "",
diff --git a/src/SlpModularCms.Core.Tests/Email/EmailRulesAndRendererTests.cs b/src/SlpModularCms.Core.Tests/Email/EmailRulesAndRendererTests.cs
index 813f5be..d8c27b2 100644
--- a/src/SlpModularCms.Core.Tests/Email/EmailRulesAndRendererTests.cs
+++ b/src/SlpModularCms.Core.Tests/Email/EmailRulesAndRendererTests.cs
@@ -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\">" }).Html;
+
+ html.Should().NotContain("