Skip to content

Commit

Permalink
fix: load css for static render
Browse files Browse the repository at this point in the history
  • Loading branch information
SonicGD committed Dec 23, 2023
1 parent b90f442 commit 4b48bae
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 24 deletions.
1 change: 1 addition & 0 deletions src/Sitko.Blockly.MudBlazor/Display/MudBlocksList.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@inherits BlocksList<MudBlazorBlocklyListOptions>
<link rel="stylesheet" href="@MudBlazorBlocklyModule.CssUrl">
@foreach (var block in Blocks)
{
var blockDescriptor = Blockly.GetBlockDescriptor(block.GetType());
Expand Down
15 changes: 1 addition & 14 deletions src/Sitko.Blockly.MudBlazor/Display/MudBlocksList.razor.cs
Original file line number Diff line number Diff line change
@@ -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;
1 change: 1 addition & 0 deletions src/Sitko.Blockly.MudBlazor/Forms/MudBlocklyForm.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@inherits BlocklyForm<MudBlazorBlocklyFormOptions>
<link rel="stylesheet" href="@MudBlazorBlocklyModule.CssUrl">
<div class="blockly-form [email protected]().ToLowerInvariant()">
@if (!string.IsNullOrEmpty(Label))
{
Expand Down
9 changes: 1 addition & 8 deletions src/Sitko.Blockly.MudBlazor/Forms/MudBlocklyForm.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions src/Sitko.Blockly.MudBlazor/MudBlazorBlocklyModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ namespace Sitko.Blockly.MudBlazorComponents;

public class MudBlazorBlocklyModule : BlazorBlocklyModule<IBlazorBlockDescriptor, MudBlazorBlocklyModuleOptions>
{
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";

Expand Down

0 comments on commit 4b48bae

Please sign in to comment.