feat(11-01): add ReportBranding model and BrandingHtmlHelper with tests
- Add ReportBranding positional record bundling MspLogo and ClientLogo - Add BrandingHtmlHelper static class generating flex branding header HTML - Add BrandingHtmlHelperTests covering all 4 logo states (null, both null, single, both) - Add InternalsVisibleTo for SharepointToolbox.Tests in project file
This commit is contained in:
8
SharepointToolbox/Core/Models/ReportBranding.cs
Normal file
8
SharepointToolbox/Core/Models/ReportBranding.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace SharepointToolbox.Core.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Bundles MSP and client logos for passing to export services.
|
||||
/// Export services receive this as a simple DTO — they don't know
|
||||
/// about IBrandingService or ProfileService.
|
||||
/// </summary>
|
||||
public record ReportBranding(LogoData? MspLogo, LogoData? ClientLogo);
|
||||
37
SharepointToolbox/Services/Export/BrandingHtmlHelper.cs
Normal file
37
SharepointToolbox/Services/Export/BrandingHtmlHelper.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Text;
|
||||
using SharepointToolbox.Core.Models;
|
||||
|
||||
namespace SharepointToolbox.Services.Export;
|
||||
|
||||
/// <summary>
|
||||
/// Generates the branding header HTML fragment for HTML reports.
|
||||
/// Called by each HTML export service between <body> and <h1>.
|
||||
/// Returns empty string when no logos are configured (no broken images).
|
||||
/// </summary>
|
||||
internal static class BrandingHtmlHelper
|
||||
{
|
||||
public static string BuildBrandingHeader(ReportBranding? branding)
|
||||
{
|
||||
if (branding is null) return string.Empty;
|
||||
|
||||
var msp = branding.MspLogo;
|
||||
var client = branding.ClientLogo;
|
||||
|
||||
if (msp is null && client is null) return string.Empty;
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("<div style=\"display:flex;gap:16px;align-items:center;padding:12px 24px 0;\">");
|
||||
|
||||
if (msp is not null)
|
||||
sb.AppendLine($" <img src=\"data:{msp.MimeType};base64,{msp.Base64}\" alt=\"\" style=\"max-height:60px;max-width:200px;object-fit:contain;\">");
|
||||
|
||||
if (msp is not null && client is not null)
|
||||
sb.AppendLine(" <div style=\"flex:1\"></div>");
|
||||
|
||||
if (client is not null)
|
||||
sb.AppendLine($" <img src=\"data:{client.MimeType};base64,{client.Base64}\" alt=\"\" style=\"max-height:60px;max-width:200px;object-fit:contain;\">");
|
||||
|
||||
sb.AppendLine("</div>");
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,12 @@
|
||||
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
|
||||
<_Parameter1>SharepointToolbox.Tests</_Parameter1>
|
||||
</AssemblyAttribute>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Remove="App.xaml" />
|
||||
<Page Include="App.xaml" />
|
||||
|
||||
Reference in New Issue
Block a user