using Microsoft.JSInterop; namespace AuthorBuddy.Web.Services; public class ThemeService : IThemeService { private readonly IJSRuntime _js; public ThemeService(IJSRuntime js) { _js = js; } public async Task ApplyTheme(string theme) { await _js.InvokeVoidAsync("eval", $"document.getElementById('theme-css')?.remove(); " + $"var link = document.createElement('link'); " + $"link.id = 'theme-css'; " + $"link.rel = 'stylesheet'; " + $"link.href = 'css/themes/{theme}.css'; " + $"document.head.appendChild(link);"); } }