@inject IJSRuntime JS @inject State State @inject RestService api @inject NavigationManager navigationManager
Choose a theme
@activeTheme?.Name

@((MarkupString)(activeTheme?.Description ?? string.Empty)) A theme by @activeTheme?.Author.

@if(themePreview != null) { }
@code { private Dictionary? themes; [Parameter] public string? id { get; set; } private string? previewId { get => $"{id}-preview"; } [Parameter] public bool Active { get; set; } [Parameter] public Action? onthemechanged { get; set; } private Theme? activeTheme { get; set; } private MarkupString? themePreview { get; set; } private ExternalPageComponent iframe { get; set; } protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); activeTheme = null; themes = await State.GetThemes(); await InvokeAsync(StateHasChanged); } public async Task ClickTheme(Theme theme) { activeTheme = theme; await InvokeAsync(StateHasChanged); await JS.InvokeVoidAsync("ui", "#" + id); await JS.InvokeVoidAsync("ui", "#" + previewId); themePreview = await api.GetThemePreview(theme.Id); await InvokeAsync(StateHasChanged); @* iframe.SrcString = themePreview.ToString(); *@ await iframe.Reload(); } public async Task CancelPreview() { activeTheme = null; await InvokeAsync(StateHasChanged); await JS.InvokeVoidAsync("ui", "#" + previewId); await JS.InvokeVoidAsync("ui", "#" + id); } public async Task UseTheme() { // todo: update theme onthemechanged?.Invoke(activeTheme); activeTheme = null; await InvokeAsync(StateHasChanged); await JS.InvokeVoidAsync("ui", "#" + previewId); } }