Skip to content

Commit 31c4f66

Browse files
First beta release
1 parent bcba4de commit 31c4f66

File tree

11 files changed

+46
-29
lines changed

11 files changed

+46
-29
lines changed

BlazorEmbedLibrary/BlazorEmbedLibrary.csproj

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,15 @@
1111
<BlazorLinkOnBuild>true</BlazorLinkOnBuild>
1212
<Authors>Mister Magoo</Authors>
1313
<Company>MM</Company>
14-
<Description>A Blazor Component that has embedded content</Description>
14+
<Description>A Blazor Component that brings Blazor-style static content to Razor Components</Description>
1515
<Copyright>Completely Free For Non-Profit</Copyright>
16-
<PackageProjectUrl>https://github.com/SQL-MisterMagoo/BlazorScrollBar</PackageProjectUrl>
17-
<RepositoryUrl>https://github.com/SQL-MisterMagoo/BlazorScrollBar</RepositoryUrl>
16+
<PackageProjectUrl>https://github.com/SQL-MisterMagoo/BlazorEmbedLibrary</PackageProjectUrl>
17+
<RepositoryUrl>https://github.com/SQL-MisterMagoo/BlazorEmbedLibrary</RepositoryUrl>
1818
<PackageTags>Blazor,Embed,Content,Component</PackageTags>
1919
<Version>$(ReleaseVersion)</Version>
2020
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
2121
</PropertyGroup>
2222

23-
<ItemGroup>
24-
<None Remove="test.css" />
25-
<None Remove="TestJS.js" />
26-
</ItemGroup>
27-
2823
<ItemGroup>
2924
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="$(BlazorVersion)" />
3025
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="$(BlazorVersion)" PrivateAssets="all" />
@@ -33,9 +28,4 @@
3328
<DotNetCliToolReference Include="Microsoft.AspNetCore.Blazor.Cli" Version="$(BlazorVersion)" />
3429
</ItemGroup>
3530

36-
<ItemGroup>
37-
<EmbeddedResource Include="test.css" />
38-
<EmbeddedResource Include="TestJS.js" />
39-
</ItemGroup>
40-
4131
</Project>

BlazorEmbedLibrary/TestJS.js

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

BlazorEmbedLibrary/test.css

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

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,8 @@ Then add the component to whichever page you want e.g. MainLayout
4747
```
4848

4949
This will read any CSS or Js files, which are embedded resources, from the Component1 library and add them to the `head` of the document.
50+
51+
## Examples
52+
53+
I have included Blazored.LocalStorage and Blazored.Toast examples in the Razorcomponents App
54+
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
@page "/counter"
2+
@inject Blazored.LocalStorage.ILocalStorageService localStorage
23

34
<h1>Counter</h1>
45

56
<p>Current count: @currentCount</p>
67

78
<button class="btn btn-primary" onclick="@IncrementCount">Click me</button>
9+
<EmbeddedContent BaseType="@(typeof(Blazored.LocalStorage.ILocalStorageService))" />
810

911
@functions {
1012
int currentCount = 0;
1113

12-
void IncrementCount()
14+
Task IncrementCount()
1315
{
1416
currentCount++;
17+
return localStorage.SetItem("counter", currentCount);
1518
}
16-
}
19+
20+
protected override async Task OnInitAsync()
21+
{
22+
currentCount = await localStorage.GetItem<int>("counter");
23+
}
24+
25+
}

RazorComponentsSample/RazorComponentsSample.App/Pages/Index.cshtml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,17 @@
55
Welcome to your new app.
66

77
<EmbeddedContent BaseType="@(typeof(Component1))" />
8-
<EmbeddedContent BaseType="@(typeof(EmbeddedContent))" />
98

109
<Component1 />
1110

11+
@inject IToastService toastService
12+
13+
<h1>Toast Demo</h1>
14+
15+
To show a toast just click one of the buttons below.
16+
17+
<button class="btn btn-info" onclick="@(() => toastService.ShowToast(ToastLevel.Info, "I'm an INFO message"))">Info Toast</button>
18+
<button class="btn btn-success" onclick="@(() => toastService.ShowToast(ToastLevel.Success, "I'm a SUCCESS message with a custom title", "Congratulations!"))">Success Toast</button>
19+
<button class="btn btn-warning" onclick="@(() => toastService.ShowToast(ToastLevel.Warning, "I'm a WARNING message"))">Warning Toast</button>
20+
<button class="btn btn-danger" onclick="@(() => toastService.ShowToast(ToastLevel.Error, "I'm an ERROR message"))">Error Toast</button>
21+
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
11
@layout MainLayout
2-
@using BlazorEmbedLibrary
3-
@using BlazorComponentSample
4-
@addTagHelper *, BlazorEmbedLibrary
5-
@addTagHelper *, BlazorComponentSample

RazorComponentsSample/RazorComponentsSample.App/RazorComponentsSample.App.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9+
<PackageReference Include="Blazored.LocalStorage" Version="1.0.2" />
10+
<PackageReference Include="Blazored.Toast" Version="1.0.2" />
911
<PackageReference Include="Microsoft.AspNetCore.Components.Browser" Version="3.0.0-preview-19075-0444" />
1012
<PackageReference Include="Microsoft.AspNetCore.Components.Build" Version="3.0.0-preview-19075-0444" PrivateAssets="all" />
1113
</ItemGroup>

RazorComponentsSample/RazorComponentsSample.App/Shared/MainLayout.cshtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@inherits LayoutComponentBase
2-
2+
<EmbeddedContent BaseType="@(typeof(Blazored.Toast.BlazoredToasts))" Debug="false"/>
3+
<BlazoredToasts />
34
<div class="sidebar">
45
<NavMenu />
56
</div>

RazorComponentsSample/RazorComponentsSample.App/Startup.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
using Blazored.LocalStorage;
2+
using Blazored.Toast;
3+
using Blazored.Toast.Services;
14
using Microsoft.AspNetCore.Components.Builder;
25
using Microsoft.Extensions.DependencyInjection;
36
using RazorComponentsSample.App.Services;
@@ -10,6 +13,8 @@ public void ConfigureServices(IServiceCollection services)
1013
{
1114
// Example of a data service
1215
services.AddSingleton<WeatherForecastService>();
16+
services.AddScoped<ILocalStorageService, LocalStorageService>();
17+
services.AddScoped<IToastService, ToastService>();
1318
}
1419

1520
public void Configure(IComponentsApplicationBuilder app)

0 commit comments

Comments
 (0)