| | | 1 | | namespace Allyaria.Theming.BrandTypes; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Represents a complete color palette for a brand theme, including background, foreground, accent, border, and decorat |
| | | 5 | | /// colors derived from a base background color. |
| | | 6 | | /// </summary> |
| | | 7 | | public sealed record BrandPalette |
| | | 8 | | { |
| | | 9 | | /// <summary> |
| | | 10 | | /// Initializes a new instance of the <see cref="BrandPalette" /> struct using the specified background color. |
| | | 11 | | /// </summary> |
| | | 12 | | /// <param name="color">The base background <see cref="HexColor" /> from which all related palette colors are derive |
| | 56423 | 13 | | public BrandPalette(HexColor color) |
| | | 14 | | { |
| | 56423 | 15 | | var backgroundColor = color.SetAlpha(alpha: 255); |
| | | 16 | | |
| | 56423 | 17 | | BackgroundColor = backgroundColor; |
| | 56423 | 18 | | ForegroundColor = BackgroundColor.ToForeground().EnsureContrast(background: BackgroundColor); |
| | 56423 | 19 | | CaretColor = ForegroundColor; |
| | 56423 | 20 | | AccentColor = ForegroundColor.ToAccent().EnsureContrast(background: BackgroundColor); |
| | 56423 | 21 | | BorderColor = BackgroundColor.ToAccent().EnsureContrast(background: BackgroundColor); |
| | 56423 | 22 | | OutlineColor = AccentColor; |
| | 56423 | 23 | | TextDecorationColor = AccentColor; |
| | 56423 | 24 | | } |
| | | 25 | | |
| | | 26 | | /// <summary>Gets the accent color used for highlights or emphasized elements.</summary> |
| | 113591 | 27 | | public HexColor AccentColor { get; } |
| | | 28 | | |
| | | 29 | | /// <summary>Gets the base background color of the palette.</summary> |
| | 282668 | 30 | | public HexColor BackgroundColor { get; } |
| | | 31 | | |
| | | 32 | | /// <summary>Gets the border color, typically derived from the background’s accent tone.</summary> |
| | 743 | 33 | | public HexColor BorderColor { get; } |
| | | 34 | | |
| | | 35 | | /// <summary>Gets the caret color used for text input cursors, matching the foreground for consistency.</summary> |
| | 743 | 36 | | public HexColor CaretColor { get; } |
| | | 37 | | |
| | | 38 | | /// <summary>Gets the primary foreground color that provides sufficient contrast against the background.</summary> |
| | 116226 | 39 | | public HexColor ForegroundColor { get; } |
| | | 40 | | |
| | | 41 | | /// <summary> |
| | | 42 | | /// Gets the outline color, typically aligned with the accent color for accessibility focus indicators. |
| | | 43 | | /// </summary> |
| | 1037 | 44 | | public HexColor OutlineColor { get; } |
| | | 45 | | |
| | | 46 | | /// <summary>Gets the text decoration color (e.g., underline) used for links and emphasized text.</summary> |
| | 743 | 47 | | public HexColor TextDecorationColor { get; } |
| | | 48 | | } |