Skip to content

Commit b41f96b

Browse files
committed
Added RCL Example
1 parent 8edf51f commit b41f96b

14 files changed

+89
-3
lines changed

BlazorBookExamples.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BookWasm", "BookWasm\BookWa
77
EndProject
88
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BookServer", "BookServer\BookServer.csproj", "{F62FB0EB-CA4F-4F79-A153-F1FB1C80C3B1}"
99
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RazorClassLibrary1", "RazorClassLibrary1\RazorClassLibrary1.csproj", "{DDEE9C71-BA61-4B50-9C74-0F15C78C212E}"
11+
EndProject
1012
Global
1113
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1214
Debug|Any CPU = Debug|Any CPU
@@ -21,6 +23,10 @@ Global
2123
{F62FB0EB-CA4F-4F79-A153-F1FB1C80C3B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
2224
{F62FB0EB-CA4F-4F79-A153-F1FB1C80C3B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
2325
{F62FB0EB-CA4F-4F79-A153-F1FB1C80C3B1}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{DDEE9C71-BA61-4B50-9C74-0F15C78C212E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27+
{DDEE9C71-BA61-4B50-9C74-0F15C78C212E}.Debug|Any CPU.Build.0 = Debug|Any CPU
28+
{DDEE9C71-BA61-4B50-9C74-0F15C78C212E}.Release|Any CPU.ActiveCfg = Release|Any CPU
29+
{DDEE9C71-BA61-4B50-9C74-0F15C78C212E}.Release|Any CPU.Build.0 = Release|Any CPU
2430
EndGlobalSection
2531
GlobalSection(SolutionProperties) = preSolution
2632
HideSolutionNode = FALSE

BookWasm/BookWasm.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@
1111
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0-preview3.20168.3" PrivateAssets="all" />
1212
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.2.0-preview3.20168.3" />
1313
</ItemGroup>
14+
15+
<ItemGroup>
16+
<ProjectReference Include="..\RazorClassLibrary1\RazorClassLibrary1.csproj" />
17+
</ItemGroup>
1418
</Project>

BookWasm/Pages/ClassLibConsumer.razor

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@page "/classlib"
2+
@inject IJSRuntime js
3+
4+
<h3>ClassLib Consumer</h3>
5+
6+
<h1>Hello, @message!</h1>
7+
<Component1></Component1>
8+
9+
<button @onclick="ShowPrompt">Show Prompt</button>
10+
11+
@code {
12+
string message = "world";
13+
async Task ShowPrompt()
14+
{
15+
message = await ExampleJsInterop.Prompt(js, "Say hello:");
16+
}
17+
}

BookWasm/Pages/Index.razor

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,3 @@ Welcome to your new app.
77
This repo contains examples from the <a href="https://www.telerik.com/whitepapers/blazor-ui/blazor-ebook">
88
Free Blazor Ebook
99
</a>
10-
11-
<SurveyPrompt Title="How is Blazor working for you?" />

BookWasm/Shared/NavMenu.razor

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@
3737
<span class="oi oi-list" aria-hidden="true"></span> RenderTree Example
3838
</NavLink>
3939
</li>
40+
<li class="nav-item px-3">
41+
<NavLink class="nav-link" href="classlib">
42+
<span class="oi oi-puzzle-piece" aria-hidden="true"></span> RCL Example
43+
</NavLink>
44+
</li>
4045
</ul>
4146
</div>
4247

BookWasm/_Imports.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
@using BookWasm
77
@using BookWasm.Shared
88
@using BookWasm.Data
9+
@using RazorClassLibrary1

BookWasm/wwwroot/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!DOCTYPE html>
22
<html>
33

44
<head>
@@ -8,6 +8,8 @@
88
<base href="/" />
99
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
1010
<link href="css/site.css" rel="stylesheet" />
11+
<link href="_content/RazorClassLibrary1/styles.css" rel="stylesheet" />
12+
<script src="_content/RazorClassLibrary1/exampleJsInterop.js"></script>
1113
</head>
1214

1315
<body>

RazorClassLibrary1/Component1.razor

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<div class="my-component">
2+
This Blazor component is defined in the <strong>RazorClassLibrary1</strong> package.
3+
</div>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using Microsoft.JSInterop;
2+
using System.Threading.Tasks;
3+
4+
namespace RazorClassLibrary1
5+
{
6+
public class ExampleJsInterop
7+
{
8+
public static ValueTask<string> Prompt(IJSRuntime jsRuntime, string message)
9+
{
10+
// Implemented in exampleJsInterop.js
11+
return jsRuntime.InvokeAsync<string>(
12+
"exampleJsFunctions.showPrompt",
13+
message);
14+
}
15+
}
16+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Razor">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<RazorLangVersion>3.0</RazorLangVersion>
6+
</PropertyGroup>
7+
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.AspNetCore.Components" Version="3.1.3" />
11+
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.3" />
12+
</ItemGroup>
13+
14+
</Project>

0 commit comments

Comments
 (0)