forked from dotnet/blazor-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Blazor WebAssembly 8.0 sample updates (dotnet#141)
- Loading branch information
Showing
209 changed files
with
1,048 additions
and
779 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
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
8.0/BlazorSample_BlazorWebApp/Components/Pages/Example.razor
This file was deleted.
Oops, something went wrong.
47 changes: 0 additions & 47 deletions
47
8.0/BlazorSample_BlazorWebApp/Components/Pages/FetchData.razor
This file was deleted.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
...omponents/Pages/home/RouteParameter.razor → .../Components/Pages/OptionalParameter.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
@page "/route-parameter/{text?}" | ||
@page "/optional-parameter/{text?}" | ||
|
||
<h1>Blazor is @Text!</h1> | ||
|
||
|
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
33 changes: 33 additions & 0 deletions
33
8.0/BlazorSample_BlazorWebApp/Components/Pages/ThemedCounter.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,33 @@ | ||
@page "/themed-counter" | ||
|
||
<PageTitle>Themed Counter</PageTitle> | ||
|
||
<h1>Themed Counter Example</h1> | ||
|
||
<p>Current count: @currentCount</p> | ||
|
||
<p> | ||
<button @onclick="IncrementCount"> | ||
Increment Counter (Unthemed) | ||
</button> | ||
</p> | ||
|
||
<p> | ||
<button | ||
class="btn @(ThemeInfo is not null ? ThemeInfo.ButtonClass : string.Empty)" | ||
@onclick="IncrementCount"> | ||
Increment Counter (Themed) | ||
</button> | ||
</p> | ||
|
||
@code { | ||
private int currentCount = 0; | ||
|
||
[CascadingParameter] | ||
protected ThemeInfo? ThemeInfo { get; set; } | ||
|
||
private void IncrementCount() | ||
{ | ||
currentCount++; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...e_WebAssembly/UIThemeClasses/ThemeInfo.cs → 8.0/BlazorSample_BlazorWebApp/ThemeInfo.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace BlazorSample.UIThemeClasses; | ||
namespace BlazorSample; | ||
|
||
public class ThemeInfo | ||
{ | ||
|
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,6 +1,7 @@ | ||
public class ComponentMetadata | ||
namespace BlazorSample; | ||
|
||
public class ComponentMetadata | ||
{ | ||
public string? Name { get; set; } | ||
public Dictionary<string, object> Parameters { get; set; } = | ||
new Dictionary<string, object>(); | ||
public Dictionary<string, object> Parameters { get; set; } = []; | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
1 change: 0 additions & 1 deletion
1
8.0/BlazorSample_WebAssembly/Components/Layout/MainLayout.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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
@inherits LayoutComponentBase | ||
@using BlazorSample.UIThemeClasses | ||
|
||
<div class="page"> | ||
<div class="sidebar"> | ||
|
56 changes: 33 additions & 23 deletions
56
8.0/BlazorSample_WebAssembly/Components/Layout/NavMenu.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 |
---|---|---|
@@ -1,39 +1,49 @@ | ||
<div class="top-row ps-3 navbar navbar-dark"> | ||
@using System.Reflection | ||
@using System.Text.RegularExpressions | ||
|
||
<div class="top-row ps-3 navbar navbar-dark"> | ||
<div class="container-fluid"> | ||
<a class="navbar-brand" href="">BlazorSample</a> | ||
<button title="Navigation menu" class="navbar-toggler" @onclick="ToggleNavMenu"> | ||
<span class="navbar-toggler-icon"></span> | ||
</button> | ||
<a class="navbar-brand" href="">Blazor Sample</a> | ||
</div> | ||
</div> | ||
|
||
<div class="@NavMenuCssClass nav-scrollable" @onclick="ToggleNavMenu"> | ||
<input type="checkbox" title="Navigation menu" class="navbar-toggler" /> | ||
|
||
<div class="nav-scrollable" | ||
onclick="document.querySelector('.navbar-toggler').click()"> | ||
<nav class="flex-column"> | ||
<div class="nav-item px-3"> | ||
<NavLink class="nav-link" href="" Match="NavLinkMatch.All"> | ||
<span class="bi bi-house-door-fill" aria-hidden="true"></span> Home | ||
</NavLink> | ||
</div> | ||
<div class="nav-item px-3"> | ||
<NavLink class="nav-link" href="counter"> | ||
<span class="bi bi-plus-square-fill" aria-hidden="true"></span> Counter | ||
</NavLink> | ||
</div> | ||
<div class="nav-item px-3"> | ||
<NavLink class="nav-link" href="weather"> | ||
<span class="bi bi-list-nested" aria-hidden="true"></span> Weather | ||
<span class="bi bi-house-door-fill-nav-menu" | ||
aria-hidden="true"></span> Home | ||
</NavLink> | ||
</div> | ||
|
||
@foreach (var name in GetRoutableComponents()) | ||
{ | ||
<div class="nav-item px-3"> | ||
<NavLink class="nav-link" | ||
href="@Regex.Replace(name, @"(\B[A-Z]|\d+)", "-$1").ToLower()"> | ||
@Regex.Replace(name, @"(\B[A-Z]|\d+)", " $1") | ||
</NavLink> | ||
</div> | ||
} | ||
|
||
</nav> | ||
</div> | ||
|
||
@code { | ||
private bool collapseNavMenu = true; | ||
|
||
private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; | ||
|
||
private void ToggleNavMenu() | ||
public IEnumerable<string> GetRoutableComponents() | ||
{ | ||
collapseNavMenu = !collapseNavMenu; | ||
return Assembly.GetExecutingAssembly() | ||
.ExportedTypes | ||
.Where(t => t.IsSubclassOf(typeof(ComponentBase))) | ||
.Where(c => c.GetCustomAttributes(inherit: true) | ||
.OfType<RouteAttribute>() | ||
.ToArray() | ||
.Count() > 0) | ||
.Where(c => c.Name != "Home" && c.Name != "Error") | ||
.OrderBy(o => o.Name) | ||
.Select(c => c.Name); | ||
} | ||
} |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.