From 4b48bae7889af86575a78b354b0cc33dde038c26 Mon Sep 17 00:00:00 2001 From: George Drak Date: Sat, 23 Dec 2023 14:57:02 +0500 Subject: [PATCH] fix: load css for static render --- .../Display/MudBlocksList.razor | 1 + .../Display/MudBlocksList.razor.cs | 15 +-------------- .../Forms/MudBlocklyForm.razor | 1 + .../Forms/MudBlocklyForm.razor.cs | 9 +-------- .../MudBlazorBlocklyModule.cs | 3 +-- 5 files changed, 5 insertions(+), 24 deletions(-) diff --git a/src/Sitko.Blockly.MudBlazor/Display/MudBlocksList.razor b/src/Sitko.Blockly.MudBlazor/Display/MudBlocksList.razor index 84248a8..7266d0b 100644 --- a/src/Sitko.Blockly.MudBlazor/Display/MudBlocksList.razor +++ b/src/Sitko.Blockly.MudBlazor/Display/MudBlocksList.razor @@ -1,4 +1,5 @@ @inherits BlocksList + @foreach (var block in Blocks) { var blockDescriptor = Blockly.GetBlockDescriptor(block.GetType()); diff --git a/src/Sitko.Blockly.MudBlazor/Display/MudBlocksList.razor.cs b/src/Sitko.Blockly.MudBlazor/Display/MudBlocksList.razor.cs index 24a4496..8e783a0 100644 --- a/src/Sitko.Blockly.MudBlazor/Display/MudBlocksList.razor.cs +++ b/src/Sitko.Blockly.MudBlazor/Display/MudBlocksList.razor.cs @@ -1,18 +1,5 @@ using Microsoft.AspNetCore.Components; -using Sitko.Blazor.ScriptInjector; namespace Sitko.Blockly.MudBlazorComponents.Display; -public partial class MudBlocksList -{ - [Inject] protected IScriptInjector ScriptInjector { get; set; } = null!; - - protected override async Task OnAfterRenderAsync(bool firstRender) - { - await base.OnAfterRenderAsync(firstRender); - if (firstRender) - { - await ScriptInjector.InjectAsync(MudBlazorBlocklyModule.MudBlazorBlocklyCssRequest); - } - } -} +public partial class MudBlocksList; diff --git a/src/Sitko.Blockly.MudBlazor/Forms/MudBlocklyForm.razor b/src/Sitko.Blockly.MudBlazor/Forms/MudBlocklyForm.razor index 0ce3d91..9175621 100644 --- a/src/Sitko.Blockly.MudBlazor/Forms/MudBlocklyForm.razor +++ b/src/Sitko.Blockly.MudBlazor/Forms/MudBlocklyForm.razor @@ -1,4 +1,5 @@ @inherits BlocklyForm +
@if (!string.IsNullOrEmpty(Label)) { diff --git a/src/Sitko.Blockly.MudBlazor/Forms/MudBlocklyForm.razor.cs b/src/Sitko.Blockly.MudBlazor/Forms/MudBlocklyForm.razor.cs index 107ed7f..52e1330 100644 --- a/src/Sitko.Blockly.MudBlazor/Forms/MudBlocklyForm.razor.cs +++ b/src/Sitko.Blockly.MudBlazor/Forms/MudBlocklyForm.razor.cs @@ -13,14 +13,7 @@ public partial class MudBlocklyForm [Parameter] public string? Label { get; set; } private Guid? _openBlockId; - protected override async Task OnAfterRenderAsync(bool firstRender) - { - await base.OnAfterRenderAsync(firstRender); - if (firstRender) - { - await ScriptInjector.InjectAsync(MudBlazorBlocklyModule.MudBlazorBlocklyCssRequest); - } - } + private void ToggleOpen(Guid blockId) { if (_openBlockId == blockId) diff --git a/src/Sitko.Blockly.MudBlazor/MudBlazorBlocklyModule.cs b/src/Sitko.Blockly.MudBlazor/MudBlazorBlocklyModule.cs index fdd1bfc..c9d46af 100644 --- a/src/Sitko.Blockly.MudBlazor/MudBlazorBlocklyModule.cs +++ b/src/Sitko.Blockly.MudBlazor/MudBlazorBlocklyModule.cs @@ -11,8 +11,7 @@ namespace Sitko.Blockly.MudBlazorComponents; public class MudBlazorBlocklyModule : BlazorBlocklyModule { - public static readonly CssInjectRequest MudBlazorBlocklyCssRequest = CssInjectRequest.FromUrl( - "blocklyMud", "/_content/Sitko.Blockly.MudBlazor/Sitko.Blockly.MudBlazor.bundle.scp.css"); + public static readonly string CssUrl = "/_content/Sitko.Blockly.MudBlazor/Sitko.Blockly.MudBlazor.bundle.scp.css"; public override string OptionsKey => "Blockly:MudBlazor";