feat(cv): rebuild professional resume studio
This commit is contained in:
@@ -20,6 +20,25 @@ public sealed class CvVariantSettings
|
||||
public string? Language { get; set; }
|
||||
public string? Headline { get; set; } // override the contact headline for this variant
|
||||
|
||||
// Normalized design overrides. Null keeps the selected theme's value, which means old variants
|
||||
// retain their exact appearance while new editor controls can be added without a schema change.
|
||||
public string? TextColor { get; set; }
|
||||
public string? MutedColor { get; set; }
|
||||
public string? HeadingColor { get; set; }
|
||||
public string? BackgroundColor { get; set; }
|
||||
public double? BaseFontSizePt { get; set; }
|
||||
public double? HeadingSizePt { get; set; }
|
||||
public double? LineHeight { get; set; }
|
||||
public double? PageMarginMm { get; set; }
|
||||
public double? SectionGapMm { get; set; }
|
||||
public double? EntryGapMm { get; set; }
|
||||
public string? HeadingStyle { get; set; } // caps-rule | underline | plain | bar
|
||||
public string? HeaderStyle { get; set; } // plain | band | centered | kicker
|
||||
public string? SkillsStyle { get; set; } // tags | text
|
||||
public string? Layout { get; set; } // single | sidebar-left | sidebar-right | header-band
|
||||
public double? SidebarWidthMm { get; set; }
|
||||
public List<string>? SidebarSections { get; set; }
|
||||
|
||||
public bool ShowPhoto { get; set; }
|
||||
public bool ShowPageNumbers { get; set; }
|
||||
public bool ShowIcons { get; set; } = true;
|
||||
@@ -94,8 +113,36 @@ public static class CvVariantSettingsJson
|
||||
s ??= new CvVariantSettings();
|
||||
s.ThemeId = string.IsNullOrWhiteSpace(s.ThemeId) ? "modern" : s.ThemeId.Trim().ToLowerInvariant();
|
||||
s.AccentColor = NormalizeColor(s.AccentColor);
|
||||
s.TextColor = NormalizeColor(s.TextColor);
|
||||
s.MutedColor = NormalizeColor(s.MutedColor);
|
||||
s.HeadingColor = NormalizeColor(s.HeadingColor);
|
||||
s.BackgroundColor = NormalizeColor(s.BackgroundColor);
|
||||
s.HeadingFont = NormalizeFont(s.HeadingFont);
|
||||
s.BodyFont = NormalizeFont(s.BodyFont);
|
||||
s.BaseFontSizePt = Clamp(s.BaseFontSizePt, 7, 13);
|
||||
s.HeadingSizePt = Clamp(s.HeadingSizePt, 9, 20);
|
||||
s.LineHeight = Clamp(s.LineHeight, 1.1, 1.8);
|
||||
s.PageMarginMm = Clamp(s.PageMarginMm, 8, 28);
|
||||
s.SectionGapMm = Clamp(s.SectionGapMm, 2, 14);
|
||||
s.EntryGapMm = Clamp(s.EntryGapMm, 1, 10);
|
||||
s.SidebarWidthMm = Clamp(s.SidebarWidthMm, 45, 85);
|
||||
s.HeadingStyle = NormalizeChoice(s.HeadingStyle, "caps-rule", "underline", "plain", "bar");
|
||||
s.HeaderStyle = NormalizeChoice(s.HeaderStyle, "plain", "band", "centered", "kicker");
|
||||
s.SkillsStyle = NormalizeChoice(s.SkillsStyle, "tags", "text");
|
||||
s.Layout = NormalizeChoice(s.Layout, "single", "sidebar-left", "sidebar-right", "header-band");
|
||||
s.DateFormat = NormalizeChoice(s.DateFormat, "long", "short", "numeric", "year");
|
||||
if (!string.IsNullOrWhiteSpace(s.Language))
|
||||
{
|
||||
var language = s.Language.Trim().ToLowerInvariant();
|
||||
s.Language = language[..Math.Min(12, language.Length)];
|
||||
}
|
||||
else s.Language = null;
|
||||
s.SidebarSections = s.SidebarSections?
|
||||
.Where(key => !string.IsNullOrWhiteSpace(key))
|
||||
.Select(key => key.Trim().ToLowerInvariant())
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.Take(20)
|
||||
.ToList();
|
||||
s.Sections ??= new();
|
||||
s.Overrides ??= new();
|
||||
s.CustomSections ??= new();
|
||||
@@ -117,4 +164,15 @@ public static class CvVariantSettingsJson
|
||||
var candidate = value?.Trim();
|
||||
return candidate is not null && AllowedFonts.Contains(candidate) ? candidate : null;
|
||||
}
|
||||
|
||||
private static double? Clamp(double? value, double min, double max) =>
|
||||
value is null || double.IsNaN(value.Value) || double.IsInfinity(value.Value)
|
||||
? null
|
||||
: Math.Clamp(value.Value, min, max);
|
||||
|
||||
private static string? NormalizeChoice(string? value, params string[] choices)
|
||||
{
|
||||
var candidate = value?.Trim().ToLowerInvariant();
|
||||
return candidate is not null && choices.Contains(candidate, StringComparer.Ordinal) ? candidate : null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user