- 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
38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
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();
|
|
}
|
|
}
|