-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blazor Web Component Blazor POC #15647
Closed
Closed
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
|
||
<Import Project="..\..\Directory.Build.props" /> | ||
<Import Project="..\OrchardCore.Build\OrchardCore.Commons.props" /> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>$(CommonTargetFrameworks)</TargetFrameworks> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
|
||
<Import Project="..\OrchardCore.Build\OrchardCore.Commons.targets" /> | ||
|
||
</Project> |
7 changes: 7 additions & 0 deletions
7
src/OrchardCore.Components/OrchardCore.Admin.Components/OrchardAdminApp.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@using Microsoft.AspNetCore.Components.Routing | ||
<Router AppAssembly="GetType().Assembly"> | ||
<Found Context="routeData"> | ||
<RouteView RouteData="routeData" /> | ||
<FocusOnNavigate RouteData="routeData" Selector="h1" /> | ||
</Found> | ||
</Router> |
21 changes: 21 additions & 0 deletions
21
src/OrchardCore.Components/OrchardCore.Admin.Components/OrchardCore.Admin.Components.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Razor"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>$(CommonTargetFrameworks)</TargetFrameworks> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
|
||
<ItemGroup> | ||
<SupportedPlatform Include="browser" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\OrchardCore.Common.Components\OrchardCore.Common.Components.csproj" /> | ||
</ItemGroup> | ||
</Project> |
8 changes: 8 additions & 0 deletions
8
src/OrchardCore.Components/OrchardCore.Admin.Components/_Imports.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@using System.Net.Http | ||
@using System.Net.Http.Json | ||
@using Microsoft.AspNetCore.Components.Forms | ||
@using Microsoft.AspNetCore.Components.Routing | ||
@using Microsoft.AspNetCore.Components.Web | ||
@using static Microsoft.AspNetCore.Components.Web.RenderMode | ||
@using Microsoft.AspNetCore.Components.Web.Virtualization | ||
@using Microsoft.JSInterop |
5 changes: 5 additions & 0 deletions
5
src/OrchardCore.Components/OrchardCore.Admin.WebAssembly.App/Initializer.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h3>Initializer</h3> | ||
|
||
@code { | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
...ore.Components/OrchardCore.Admin.WebAssembly.App/OrchardCore.Admin.WebAssembly.App.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>$(CommonTargetFrameworks)</TargetFrameworks> | ||
|
||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile> | ||
<StaticWebAssetProjectMode>Default</StaticWebAssetProjectMode> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.CustomElements" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\OrchardCore.Admin.Components\OrchardCore.Admin.Components.csproj" /> | ||
<ProjectReference Include="..\OrchardCore.Common.Components\OrchardCore.Common.Components.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
11 changes: 11 additions & 0 deletions
11
src/OrchardCore.Components/OrchardCore.Admin.WebAssembly.App/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Microsoft.AspNetCore.Components.Web; | ||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting; | ||
using OrchardCore.Admin.WebAssembly.App; | ||
using OrchardCore.Common.Components; | ||
|
||
var builder = WebAssemblyHostBuilder.CreateDefault(args); | ||
builder.RootComponents.RegisterCustomElement<OptionEditor>("option-editor"); | ||
builder.RootComponents.RegisterCustomElement<Initializer>("init"); | ||
|
||
|
||
await builder.Build().RunAsync(); |
9 changes: 9 additions & 0 deletions
9
src/OrchardCore.Components/OrchardCore.Admin.WebAssembly.App/_Imports.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@using System.Net.Http | ||
@using System.Net.Http.Json | ||
@using Microsoft.AspNetCore.Components.Forms | ||
@using Microsoft.AspNetCore.Components.Routing | ||
@using Microsoft.AspNetCore.Components.Web | ||
@using static Microsoft.AspNetCore.Components.Web.RenderMode | ||
@using Microsoft.AspNetCore.Components.Web.Virtualization | ||
@using Microsoft.JSInterop | ||
@using OrchardCore.Admin.WebAssembly.App |
43 changes: 43 additions & 0 deletions
43
src/OrchardCore.Components/OrchardCore.Common.Components/CollocatedJSComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.JSInterop; | ||
|
||
namespace OrchardCore.Common.Components; | ||
|
||
public class CollocatedJSComponent : ComponentBase, IAsyncDisposable | ||
{ | ||
[Inject] | ||
private IJSRuntime? JS { get; set; } | ||
|
||
[Parameter] | ||
public bool RaiseDomEvents { get; set; } | ||
|
||
protected IJSObjectReference? JSModule { get; private set; } | ||
|
||
protected override async Task OnAfterRenderAsync(bool firstRender) | ||
{ | ||
if (firstRender) | ||
{ | ||
var ns = GetType().Namespace; | ||
var cmp = GetType().Name; | ||
if (JS is not null) | ||
{ | ||
JSModule = await JS.InvokeAsync<IJSObjectReference>("import", | ||
$"./_content/{ns}/{cmp}.razor.js"); | ||
} | ||
} | ||
} | ||
|
||
async ValueTask IAsyncDisposable.DisposeAsync() | ||
{ | ||
if (JSModule is not null) | ||
{ | ||
await JSModule.DisposeAsync(); | ||
} | ||
} | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
src/OrchardCore.Components/OrchardCore.Common.Components/ModalDialog.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<div class="modal fade @IsOpenClass text-start" role="dialog" style="display:@IsOpenDisplayStyle" aria-hidden="true"> | ||
<div class="modal-dialog modal-dialog-centered" role="document"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title">@Title</h5> | ||
<button type="button" class="btn-close" aria-label="Close" @onclick="Close"></button> | ||
</div> | ||
<div class="modal-body"> | ||
@Body | ||
</div> | ||
<div class="modal-footer"> | ||
@Actions | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
@if (ShowBackdrop && IsOpen) | ||
{ | ||
<div class="modal-backdrop fade show"></div> | ||
} | ||
|
||
@code { | ||
|
||
[Parameter] | ||
public string? Title { get; set; } | ||
[Parameter] | ||
public bool ShowBackdrop { get; set; } | ||
[Parameter] | ||
public RenderFragment? Body { get; set; } | ||
[Parameter] | ||
public RenderFragment? Actions { get; set; } | ||
|
||
|
||
public bool IsOpen { get; set; } | ||
|
||
string IsOpenClass { get; set; } = string.Empty; | ||
|
||
string IsOpenDisplayStyle { get; set; } = "none"; | ||
|
||
public async Task Open() | ||
{ | ||
IsOpenDisplayStyle = "block"; | ||
IsOpen = true; | ||
await Task.Delay(100);//Delay allows bootstrap to perform nice fade animation | ||
IsOpenClass = "show"; | ||
StateHasChanged(); | ||
|
||
} | ||
|
||
public async Task Close() | ||
{ | ||
IsOpenClass = ""; | ||
IsOpen = false; | ||
await Task.Delay(250);//Delay allows bootstrap to perform nice fade animation | ||
IsOpenDisplayStyle = "none"; | ||
StateHasChanged(); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the ES6 module are imported based on their name. This should be renamed to .mjs to make a distinction or support it at least.