diff --git a/EnvelopeGenerator.Server/EnvelopeGenerator.Server.Client/Models/CustomImagesDto.cs b/EnvelopeGenerator.Server/EnvelopeGenerator.Server.Client/Models/CustomImagesDto.cs new file mode 100644 index 00000000..799ddd24 --- /dev/null +++ b/EnvelopeGenerator.Server/EnvelopeGenerator.Server.Client/Models/CustomImagesDto.cs @@ -0,0 +1,23 @@ +using System.Net.Http.Json; +using System.Text.Json; + +namespace EnvelopeGenerator.Server.Client.Services; + +/// +/// Client-side DTO mirroring CustomImageEntry on the server. +/// Height is a CSS value string (e.g. "28px") set in appsettings.json. +/// +public sealed record CustomImageDto(string Src, string Height, Dictionary Classes) +{ + public CustomImageDto() : this(string.Empty, "28px", new()) { } + + /// Returns the CSS class for the given context key, or empty string if absent. + public string GetClass(string key) => + Classes.TryGetValue(key, out var cls) && cls is not null ? cls : string.Empty; +} + +/// Client-side DTO for the full CustomImages config (App + Company logos). +public sealed record CustomImagesDto(CustomImageDto App, CustomImageDto Company) +{ + public CustomImagesDto() : this(new(), new()) { } +} diff --git a/EnvelopeGenerator.Server/EnvelopeGenerator.Server/Models/CustomImages.cs b/EnvelopeGenerator.Server/EnvelopeGenerator.Server/Models/CustomImages.cs index 862edf8d..dce5c484 100644 --- a/EnvelopeGenerator.Server/EnvelopeGenerator.Server/Models/CustomImages.cs +++ b/EnvelopeGenerator.Server/EnvelopeGenerator.Server/Models/CustomImages.cs @@ -1,6 +1,36 @@ namespace EnvelopeGenerator.Server.Models; -public class CustomImages : Dictionary +/// +/// A single image asset entry — source path and optional per-context CSS classes. +/// Height controls the rendered size in CSS units (e.g. "28px", "2rem"). +/// Change Src and Height in appsettings.json per deployment; no code change required. +/// +public sealed class CustomImageEntry { - public new Image this[string key] => TryGetValue(key, out var img) && img is not null ? img : new(); -} \ No newline at end of file + public string Src { get; set; } = string.Empty; + + /// + /// CSS height value, e.g. "28px" or "2rem". + /// Allows different-sized logos across deployments without CSS changes. + /// + public string Height { get; set; } = "28px"; + + public Dictionary Classes { get; set; } = new(); + + /// Returns the CSS class for the given context key, or empty string if absent. + public string GetClass(string key) => + Classes.TryGetValue(key, out var cls) && cls is not null ? cls : string.Empty; +} + +/// +/// Bound from appsettings.json "CustomImages" section via Options Pattern. +/// App = signFLOW application logo. +/// Company = customer/company logo (Digital Data GmbH by default). +/// +public sealed class CustomImagesOptions +{ + public const string SectionName = "CustomImages"; + + public CustomImageEntry App { get; set; } = new(); + public CustomImageEntry Company { get; set; } = new(); +}