Skip to content

Commit 852e23a

Browse files
Version 1
1 parent a6de699 commit 852e23a

21 files changed

+130
-101
lines changed

Directory.Build.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup>
3-
<BlazorVersion>0.9.0-preview3-19154-02</BlazorVersion>
4-
<AspNetCoreVersion>3.0.0-preview3-19153-02</AspNetCoreVersion>
5-
<ReleaseVersion>0.1.0-beta-4</ReleaseVersion>
3+
<BlazorVersion>3.0.0-preview9.19424.4</BlazorVersion>
4+
<AspNetCoreVersion>3.0.0-preview9.19424.4</AspNetCoreVersion>
5+
<ReleaseVersion>1.0.0</ReleaseVersion>
66
</PropertyGroup>
77
</Project>

README.md

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33

44
This is a component library that provides Blazor-style static file embedding for Razor Components/Blazor.
55

6-
Chanegelog:
6+
Changelog:
7+
8+
#### Version 1.0.0
9+
- Update to Preview9
710

811
#### Version 0.1.0-beta-4
912
- Add BlazorFileProvider : Static File Provider that serves embedded files from Blazor Libraries
@@ -38,17 +41,34 @@ https://www.nuget.org/packages/BlazorEmbedLibrary/
3841

3942
#### Using the EmbeddedComponent to extract CSS/JS files
4043

41-
Add a *Using* and an *addTagHelper* to the __ViewImports file
44+
I recommend placing this in your MainLayout (or equivalent), but you can do it on individual pages if that suits your project.
4245

43-
```
46+
Add a *Using* statement to the page to make it easier to reference the component
47+
48+
*MainLayout.razor*
49+
``` C#
4450
@using BlazorEmbedLibrary
45-
@addTagHelper *, BlazorEmbedLibrary
4651
```
4752

48-
Then add the component to whichever page you want e.g. MainLayout, Index.cshtml - wherever makes sense for your project/needs.
53+
...add the component :
4954

55+
``` HTML
56+
<EmbeddedContent BaseType="@(typeof(Component1))" />
5057
```
51-
<EmbeddedContent BaseType="@(typeof(Component1))" />
58+
``` C#
59+
@code
60+
{
61+
bool hasConnected = false;
62+
protected override void OnAfterRender(bool firstRender)
63+
{
64+
base.OnAfterRender(firstRender);
65+
if (firstRender)
66+
{
67+
StateHasChanged();
68+
hasConnected = true;
69+
}
70+
}
71+
}
5272
```
5373

5474
Note, by default the EmbeddedContent component has Debug turned off - if you enable it by setting Debug=true, it outputs the list of embedded resources.
@@ -62,7 +82,7 @@ From version 0.1.0-beta-3 onwards, you can now handle multiple component librari
6282
```
6383
<EmbeddedContent Assemblies="@Assemblies" />
6484
65-
@functions
85+
@code
6686
{
6787
List<System.Reflection.Assembly> Assemblies = new List<System.Reflection.Assembly>()
6888
{
@@ -82,7 +102,7 @@ This example will load content from Blazored.Toast and Component1, but will bloc
82102
```
83103
<EmbeddedContent Assemblies="@Assemblies" BlockCssFiles="@BlockCss" />
84104
85-
@functions
105+
@code
86106
{
87107
List<string> BlockCss = new List<string>()
88108
{
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5-
<OutputType>Library</OutputType>
65
<IsPackable>true</IsPackable>
76
<BlazorLinkOnBuild>false</BlazorLinkOnBuild>
87
<LangVersion>latest</LangVersion>
8+
<RazorLangVersion>3.0</RazorLangVersion>
9+
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
10+
<EnableDefaultContentItems>false</EnableDefaultContentItems>
911
</PropertyGroup>
1012

1113
<ItemGroup>
@@ -16,10 +18,15 @@
1618
</ItemGroup>
1719

1820
<ItemGroup>
19-
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="$(BlazorVersion)" />
20-
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="$(BlazorVersion)" PrivateAssets="all" />
21+
<None Remove="Component1.razor" />
22+
</ItemGroup>
2123

22-
<DotNetCliToolReference Include="Microsoft.AspNetCore.Blazor.Cli" Version="$(BlazorVersion)" />
24+
<ItemGroup>
25+
<Content Include="Component1.razor" />
26+
</ItemGroup>
27+
28+
<ItemGroup>
29+
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.0.0-preview9.19424.4" />
2330
</ItemGroup>
2431

2532
</Project>

samples/BlazorComponentSample/Component1.cshtml renamed to samples/BlazorComponentSample/Component1.razor

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
@using Microsoft.AspNetCore.Components
2-
@inherits ComponentBase
1+
@using Microsoft.AspNetCore.Components.Web
32
@using Microsoft.JSInterop
3+
@inherits ComponentBase
44
@inject IJSRuntime jSRuntime
5+
56
<div class="my-component">
67
This Blazor component is defined in the <strong>BlazorComponentSample</strong> package.
78
</div>
89

9-
<button onclick="@OnClick">Click Me!</button>
10+
<button @onclick="()=>OnClick()">Click Me!</button>
11+
1012

11-
@functions
13+
@code
1214
{
13-
Task OnClick(UIMouseEventArgs args)
15+
ValueTask<string> OnClick()
1416
{
1517
return ExampleJsInterop.Prompt(jSRuntime,"you clicked me");
1618
}

samples/BlazorComponentSample/ExampleJsInterop.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace BlazorComponentSample
66
{
77
public class ExampleJsInterop
88
{
9-
public static Task<string> Prompt(IJSRuntime jSRuntime, string message)
9+
public static ValueTask<string> Prompt(IJSRuntime jSRuntime, string message)
1010
{
1111
// Implemented in exampleJsInterop.js
1212
return jSRuntime.InvokeAsync<string>(

samples/BlazorEmbedContent/App.cshtml

Lines changed: 0 additions & 5 deletions
This file was deleted.

samples/BlazorEmbedContent/App.razor

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Router AppAssembly="@typeof(Program).Assembly">
2+
<Found Context="routeData">
3+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
4+
</Found>
5+
<NotFound>
6+
<LayoutView Layout="@typeof(MainLayout)">
7+
<p>Sorry, there's nothing at this address.</p>
8+
</LayoutView>
9+
</NotFound>
10+
</Router>

samples/BlazorEmbedContent/BlazorEmbedContent.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5-
<RunCommand>dotnet</RunCommand>
6-
<RunArguments>blazor serve</RunArguments>
5+
<OutputType>Exe</OutputType>
76
<LangVersion>7.3</LangVersion>
7+
<RazorLangVersion>3.0</RazorLangVersion>
8+
<BlazorLinkOnBuild>false</BlazorLinkOnBuild>
89
</PropertyGroup>
910

1011
<ItemGroup>
11-
<PackageReference Include="Blazored.Toast" Version="1.0.3" />
12-
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="$(BlazorVersion)" />
13-
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="$(BlazorVersion)" PrivateAssets="all" />
14-
15-
<DotNetCliToolReference Include="Microsoft.AspNetCore.Blazor.Cli" Version="$(BlazorVersion)" />
12+
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview9.19424.4" />
13+
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview9.19424.4" PrivateAssets="all" />
14+
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.0.0-preview9.19424.4" PrivateAssets="all" />
15+
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.0.0-preview9.19424.4" />
1616
</ItemGroup>
1717

1818
<ItemGroup>

samples/BlazorEmbedContent/Pages/Counter.cshtml renamed to samples/BlazorEmbedContent/Pages/Counter.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<p>Current count: @currentCount</p>
66

7-
<button class="btn btn-primary" onclick="@IncrementCount">Click me</button>
7+
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
88

99
@functions {
1010
int currentCount = 0;

samples/BlazorEmbedContent/Pages/FetchData.cshtml renamed to samples/BlazorEmbedContent/Pages/FetchData.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ else
3737
@functions {
3838
WeatherForecast[] forecasts;
3939

40-
protected override async Task OnInitAsync()
40+
protected override async Task OnInitializedAsync()
4141
{
4242
forecasts = await Http.GetJsonAsync<WeatherForecast[]>("sample-data/weather.json");
4343
}

0 commit comments

Comments
 (0)