Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create new a new Razor Class Library project
- Loading branch information
1 parent
9506b28
commit 7eeb63f
Showing
9 changed files
with
98 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
|
||
.net core 3.x | ||
https://www.iaspnetcore.com/blog/blogpost/5cb3269642993a0a84f2298e/aspnet-core-blazor6creating-a-reusable-a-reusable-grid-component |
25 changes: 25 additions & 0 deletions
25
src/5.x/iAspNetCore.RazorComponents/iAspNetCore.RazorComponents.sln
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,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.30907.101 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "iAspNetCore.RazorComponents", "iAspNetCore.RazorComponents\iAspNetCore.RazorComponents.csproj", "{E4E5E040-F2B2-411B-9579-DC02588A68BD}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{E4E5E040-F2B2-411B-9579-DC02588A68BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{E4E5E040-F2B2-411B-9579-DC02588A68BD}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{E4E5E040-F2B2-411B-9579-DC02588A68BD}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{E4E5E040-F2B2-411B-9579-DC02588A68BD}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {D1B85B48-6806-4D79-8749-F95C3BDD3B09} | ||
EndGlobalSection | ||
EndGlobal |
3 changes: 3 additions & 0 deletions
3
src/5.x/iAspNetCore.RazorComponents/iAspNetCore.RazorComponents/Component1.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,3 @@ | ||
<div class="my-component"> | ||
This Blazor component is defined in the <strong>iAspNetCore.RazorComponents</strong> package. | ||
</div> |
6 changes: 6 additions & 0 deletions
6
src/5.x/iAspNetCore.RazorComponents/iAspNetCore.RazorComponents/Component1.razor.css
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,6 @@ | ||
.my-component { | ||
border: 2px dashed red; | ||
padding: 1em; | ||
margin: 1em 0; | ||
background-image: url('background.png'); | ||
} |
39 changes: 39 additions & 0 deletions
39
src/5.x/iAspNetCore.RazorComponents/iAspNetCore.RazorComponents/ExampleJsInterop.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,39 @@ | ||
using Microsoft.JSInterop; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace iAspNetCore.RazorComponents | ||
{ | ||
// This class provides an example of how JavaScript functionality can be wrapped | ||
// in a .NET class for easy consumption. The associated JavaScript module is | ||
// loaded on demand when first needed. | ||
// | ||
// This class can be registered as scoped DI service and then injected into Blazor | ||
// components for use. | ||
|
||
public class ExampleJsInterop : IAsyncDisposable | ||
{ | ||
private readonly Lazy<Task<IJSObjectReference>> moduleTask; | ||
|
||
public ExampleJsInterop(IJSRuntime jsRuntime) | ||
{ | ||
moduleTask = new(() => jsRuntime.InvokeAsync<IJSObjectReference>( | ||
"import", "./_content/iAspNetCore.RazorComponents/exampleJsInterop.js").AsTask()); | ||
} | ||
|
||
public async ValueTask<string> Prompt(string message) | ||
{ | ||
var module = await moduleTask.Value; | ||
return await module.InvokeAsync<string>("showPrompt", message); | ||
} | ||
|
||
public async ValueTask DisposeAsync() | ||
{ | ||
if (moduleTask.IsValueCreated) | ||
{ | ||
var module = await moduleTask.Value; | ||
await module.DisposeAsync(); | ||
} | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/5.x/iAspNetCore.RazorComponents/iAspNetCore.RazorComponents/_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 @@ | ||
@using Microsoft.AspNetCore.Components.Web |
16 changes: 16 additions & 0 deletions
16
...AspNetCore.RazorComponents/iAspNetCore.RazorComponents/iAspNetCore.RazorComponents.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,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Razor"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net5.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
|
||
<ItemGroup> | ||
<SupportedPlatform Include="browser" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="5.0.2" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Binary file added
BIN
+378 Bytes
.../iAspNetCore.RazorComponents/iAspNetCore.RazorComponents/wwwroot/background.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions
6
src/5.x/iAspNetCore.RazorComponents/iAspNetCore.RazorComponents/wwwroot/exampleJsInterop.js
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,6 @@ | ||
// This is a JavaScript module that is loaded on demand. It can export any number of | ||
// functions, and may import other JavaScript modules if required. | ||
|
||
export function showPrompt(message) { | ||
return prompt(message, 'Type anything here'); | ||
} |