From cae7d762069c437c7c93d6bf84344beaf0bd7350 Mon Sep 17 00:00:00 2001 From: JonKazama-Hellion Date: Tue, 5 May 2026 10:27:50 +0200 Subject: [PATCH] feat(themes): theme registry with built-in lookup and fallback --- HellionChat/Themes/ThemeRegistry.cs | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 HellionChat/Themes/ThemeRegistry.cs diff --git a/HellionChat/Themes/ThemeRegistry.cs b/HellionChat/Themes/ThemeRegistry.cs new file mode 100644 index 0000000..efb1768 --- /dev/null +++ b/HellionChat/Themes/ThemeRegistry.cs @@ -0,0 +1,42 @@ +using HellionChat.Themes.Builtin; + +namespace HellionChat.Themes; + +public sealed class ThemeRegistry +{ + public const string DefaultSlug = HellionArctic.Slug; + + private readonly Dictionary _builtIns; + private Theme _active; + + public ThemeRegistry() + { + _builtIns = new Dictionary(StringComparer.OrdinalIgnoreCase) + { + { HellionArctic.Slug, HellionArctic.Build() }, + { Chat2Classic.Slug, Chat2Classic.Build() }, + { EventHorizon.Slug, EventHorizon.Build() }, + { MoonlitBloom.Slug, MoonlitBloom.Build() }, + { MintGrove.Slug, MintGrove.Build() }, + }; + _active = _builtIns[DefaultSlug]; + } + + public Theme Active => _active; + + // Active-Lookup: liefert das angeforderte Theme oder fällt auf Hellion Arctic + // zurück, wenn der Slug unbekannt ist. + public Theme Get(string slug) + { + return _builtIns.TryGetValue(slug, out var theme) + ? theme + : _builtIns[DefaultSlug]; + } + + public IEnumerable AllBuiltIns() => _builtIns.Values; + + public void Switch(string slug) + { + _active = Get(slug); + } +}