Skip to content

Commit d4833e1

Browse files
chore: update template and sample
1 parent 42d1495 commit d4833e1

File tree

83 files changed

+778
-2183
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+778
-2183
lines changed

src/BlazorDesktop.Sample/Shared/MainLayout.razor renamed to src/BlazorDesktop.Sample/Components/Layout/MainLayout.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@* Licensed to the Blazor Desktop Contributors under one or more agreements. *@
1+
@* Licensed to the Blazor Desktop Contributors under one or more agreements. *@
22
@* The Blazor Desktop Contributors licenses this file to you under the MIT license. *@
33
@* See the LICENSE file in the project root for more information. *@
44

@@ -11,7 +11,7 @@
1111

1212
<main>
1313
<div class="top-row px-4">
14-
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
14+
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
1515
</div>
1616

1717
<article class="content px-4">

src/BlazorDesktop.Sample/Shared/MainLayout.razor.css renamed to src/BlazorDesktop.Sample/Components/Layout/MainLayout.razor.css

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,17 @@ main {
3131
text-decoration: none;
3232
}
3333

34-
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
35-
text-decoration: underline;
36-
}
37-
38-
.top-row ::deep a:first-child {
39-
overflow: hidden;
40-
text-overflow: ellipsis;
41-
}
34+
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
35+
text-decoration: underline;
36+
}
4237

43-
@media (max-width: 640.98px) {
44-
.top-row:not(.auth) {
45-
display: none;
38+
.top-row ::deep a:first-child {
39+
overflow: hidden;
40+
text-overflow: ellipsis;
4641
}
4742

48-
.top-row.auth {
43+
@media (max-width: 640.98px) {
44+
.top-row {
4945
justify-content: space-between;
5046
}
5147

@@ -72,6 +68,12 @@ main {
7268
z-index: 1;
7369
}
7470

71+
.top-row.auth ::deep a:first-child {
72+
flex: 1;
73+
text-align: right;
74+
width: 0;
75+
}
76+
7577
.top-row, article {
7678
padding-left: 2rem !important;
7779
padding-right: 1.5rem !important;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
@* Licensed to the Blazor Desktop Contributors under one or more agreements. *@
2+
@* The Blazor Desktop Contributors licenses this file to you under the MIT license. *@
3+
@* See the LICENSE file in the project root for more information. *@
4+
5+
<div class="top-row ps-3 navbar navbar-dark">
6+
<div class="container-fluid">
7+
<a class="navbar-brand" href="">BlazorDesktop.Sample</a>
8+
</div>
9+
</div>
10+
11+
<input type="checkbox" title="Navigation menu" class="navbar-toggler" />
12+
13+
<div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">
14+
<nav class="flex-column">
15+
<div class="nav-item px-3">
16+
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
17+
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Home
18+
</NavLink>
19+
</div>
20+
21+
<div class="nav-item px-3">
22+
<NavLink class="nav-link" href="counter">
23+
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Counter
24+
</NavLink>
25+
</div>
26+
27+
<div class="nav-item px-3">
28+
<NavLink class="nav-link" href="weather">
29+
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> Weather
30+
</NavLink>
31+
</div>
32+
</nav>
33+
</div>
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/* Licensed to the Blazor Desktop Contributors under one or more agreements. */
2+
/* The Blazor Desktop Contributors licenses this file to you under the MIT license. */
3+
/* See the LICENSE file in the project root for more information. */
4+
5+
.navbar-toggler {
6+
appearance: none;
7+
cursor: pointer;
8+
width: 3.5rem;
9+
height: 2.5rem;
10+
color: white;
11+
position: absolute;
12+
top: 0.5rem;
13+
right: 1rem;
14+
border: 1px solid rgba(255, 255, 255, 0.1);
15+
background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") no-repeat center/1.75rem rgba(255, 255, 255, 0.1);
16+
}
17+
18+
.navbar-toggler:checked {
19+
background-color: rgba(255, 255, 255, 0.5);
20+
}
21+
22+
.top-row {
23+
height: 3.5rem;
24+
background-color: rgba(0,0,0,0.4);
25+
}
26+
27+
.navbar-brand {
28+
font-size: 1.1rem;
29+
}
30+
31+
.bi {
32+
display: inline-block;
33+
position: relative;
34+
width: 1.25rem;
35+
height: 1.25rem;
36+
margin-right: 0.75rem;
37+
top: -1px;
38+
background-size: cover;
39+
}
40+
41+
.bi-house-door-fill-nav-menu {
42+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-house-door-fill' viewBox='0 0 16 16'%3E%3Cpath d='M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z'/%3E%3C/svg%3E");
43+
}
44+
45+
.bi-plus-square-fill-nav-menu {
46+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-plus-square-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm6.5 4.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3a.5.5 0 0 1 1 0z'/%3E%3C/svg%3E");
47+
}
48+
49+
.bi-list-nested-nav-menu {
50+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E");
51+
}
52+
53+
.nav-item {
54+
font-size: 0.9rem;
55+
padding-bottom: 0.5rem;
56+
}
57+
58+
.nav-item:first-of-type {
59+
padding-top: 1rem;
60+
}
61+
62+
.nav-item:last-of-type {
63+
padding-bottom: 1rem;
64+
}
65+
66+
.nav-item ::deep .nav-link {
67+
color: #d7d7d7;
68+
background: none;
69+
border: none;
70+
border-radius: 4px;
71+
height: 3rem;
72+
display: flex;
73+
align-items: center;
74+
line-height: 3rem;
75+
width: 100%;
76+
}
77+
78+
.nav-item ::deep a.active {
79+
background-color: rgba(255,255,255,0.37);
80+
color: white;
81+
}
82+
83+
.nav-item ::deep .nav-link:hover {
84+
background-color: rgba(255,255,255,0.1);
85+
color: white;
86+
}
87+
88+
.nav-scrollable {
89+
display: none;
90+
}
91+
92+
.navbar-toggler:checked ~ .nav-scrollable {
93+
display: block;
94+
}
95+
96+
@media (min-width: 641px) {
97+
.navbar-toggler {
98+
display: none;
99+
}
100+
101+
.nav-scrollable {
102+
/* Never collapse the sidebar for wide screens */
103+
display: block;
104+
105+
/* Allow sidebar to scroll for tall menus */
106+
height: calc(100vh - 3.5rem);
107+
overflow-y: auto;
108+
}
109+
}

src/BlazorDesktop.Sample/Pages/Counter.razor renamed to src/BlazorDesktop.Sample/Components/Pages/Counter.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@* Licensed to the Blazor Desktop Contributors under one or more agreements. *@
1+
@* Licensed to the Blazor Desktop Contributors under one or more agreements. *@
22
@* The Blazor Desktop Contributors licenses this file to you under the MIT license. *@
33
@* See the LICENSE file in the project root for more information. *@
44

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@* Licensed to the Blazor Desktop Contributors under one or more agreements. *@
1+
@* Licensed to the Blazor Desktop Contributors under one or more agreements. *@
22
@* The Blazor Desktop Contributors licenses this file to you under the MIT license. *@
33
@* See the LICENSE file in the project root for more information. *@
44

@@ -7,5 +7,3 @@
77
<h1>Hello, world!</h1>
88

99
Welcome to your new app.
10-
11-
<SurveyPrompt Title="How is Blazor working for you?" />
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
@* Licensed to the Blazor Desktop Contributors under one or more agreements. *@
2+
@* The Blazor Desktop Contributors licenses this file to you under the MIT license. *@
3+
@* See the LICENSE file in the project root for more information. *@
4+
5+
@page "/weather"
6+
7+
<h1>Weather</h1>
8+
9+
<p>This component demonstrates showing data.</p>
10+
11+
@if (forecasts == null)
12+
{
13+
<p><em>Loading...</em></p>
14+
}
15+
else
16+
{
17+
<table class="table">
18+
<thead>
19+
<tr>
20+
<th>Date</th>
21+
<th>Temp. (C)</th>
22+
<th>Temp. (F)</th>
23+
<th>Summary</th>
24+
</tr>
25+
</thead>
26+
<tbody>
27+
@foreach (var forecast in forecasts)
28+
{
29+
<tr>
30+
<td>@forecast.Date.ToShortDateString()</td>
31+
<td>@forecast.TemperatureC</td>
32+
<td>@forecast.TemperatureF</td>
33+
<td>@forecast.Summary</td>
34+
</tr>
35+
}
36+
</tbody>
37+
</table>
38+
}
39+
40+
@code {
41+
private WeatherForecast[]? forecasts;
42+
43+
protected override async Task OnInitializedAsync()
44+
{
45+
// Simulate asynchronous loading to demonstrate a loading indicator
46+
await Task.Delay(500);
47+
48+
var startDate = DateOnly.FromDateTime(DateTime.Now);
49+
var summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" };
50+
forecasts = Enumerable.Range(1, 5).Select(index => new WeatherForecast
51+
{
52+
Date = startDate.AddDays(index),
53+
TemperatureC = Random.Shared.Next(-20, 55),
54+
Summary = summaries[Random.Shared.Next(summaries.Length)]
55+
}).ToArray();
56+
}
57+
58+
private class WeatherForecast
59+
{
60+
public DateOnly Date { get; set; }
61+
public int TemperatureC { get; set; }
62+
public string? Summary { get; set; }
63+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
64+
}
65+
}

src/BlazorDesktop.Sample/App.razor renamed to src/BlazorDesktop.Sample/Components/Routes.razor

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
@* Licensed to the Blazor Desktop Contributors under one or more agreements. *@
1+
@* Licensed to the Blazor Desktop Contributors under one or more agreements. *@
22
@* The Blazor Desktop Contributors licenses this file to you under the MIT license. *@
33
@* See the LICENSE file in the project root for more information. *@
44

5-
<Router AppAssembly="@typeof(App).Assembly">
5+
<Router AppAssembly="typeof(Program).Assembly">
66
<Found Context="routeData">
7-
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
8-
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
7+
<RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)" />
8+
<FocusOnNavigate RouteData="routeData" Selector="h1" />
99
</Found>
1010
<NotFound>
11-
<LayoutView Layout="@typeof(MainLayout)">
11+
<LayoutView Layout="@typeof(Layout.MainLayout)">
1212
<p role="alert">Sorry, there's nothing at this address.</p>
1313
</LayoutView>
1414
</NotFound>
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
@* Licensed to the Blazor Desktop Contributors under one or more agreements. *@
1+
@* Licensed to the Blazor Desktop Contributors under one or more agreements. *@
22
@* The Blazor Desktop Contributors licenses this file to you under the MIT license. *@
33
@* See the LICENSE file in the project root for more information. *@
44

55
@using System.Net.Http
6+
@using System.Net.Http.Json
67
@using Microsoft.AspNetCore.Components.Forms
78
@using Microsoft.AspNetCore.Components.Routing
89
@using Microsoft.AspNetCore.Components.Web
910
@using Microsoft.AspNetCore.Components.Web.Virtualization
1011
@using Microsoft.JSInterop
1112
@using BlazorDesktop.Sample
12-
@using BlazorDesktop.Sample.Shared
13+
@using BlazorDesktop.Sample.Components

src/BlazorDesktop.Sample/Data/WeatherForecast.cs

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

0 commit comments

Comments
 (0)