Skip to content

Commit

Permalink
Update to .NET 8 RC1
Browse files Browse the repository at this point in the history
  • Loading branch information
danroth27 committed Sep 19, 2023
1 parent 8e0ce62 commit 870a835
Show file tree
Hide file tree
Showing 27 changed files with 235 additions and 1,028 deletions.
23 changes: 2 additions & 21 deletions App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,7 @@
</head>

<body>

<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>

<div id="blazor-error-ui">
An unhandled error has occurred.
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>

<script src="_framework/blazor.web.js" suppress-error="BL9992"></script>
<Routes />
<script src="_framework/blazor.web.js"></script>
</body>
</html>
4 changes: 4 additions & 0 deletions BlazorSSR.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.QuickGrid" Version="8.0.0-rc.1.23421.29" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@
</article>
</main>
</div>

<div id="blazor-error-ui">
An unhandled error has occurred.
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ main {
text-decoration: none;
}

.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
text-decoration: underline;
}
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
text-decoration: underline;
}

.top-row ::deep a:first-child {
overflow: hidden;
text-overflow: ellipsis;
}
.top-row ::deep a:first-child {
overflow: hidden;
text-overflow: ellipsis;
}

@media (max-width: 640.98px) {
.top-row:not(.auth) {
Expand Down Expand Up @@ -68,14 +68,33 @@ main {
z-index: 1;
}

.top-row.auth ::deep a:first-child {
flex: 1;
text-align: right;
width: 0;
}
.top-row.auth ::deep a:first-child {
flex: 1;
text-align: right;
width: 0;
}

.top-row, article {
padding-left: 2rem !important;
padding-right: 1.5rem !important;
}
}

#blazor-error-ui {
background: lightyellow;
bottom: 0;
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
display: none;
left: 0;
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
position: fixed;
width: 100%;
z-index: 1000;
}

#blazor-error-ui .dismiss {
cursor: pointer;
position: absolute;
right: 0.75rem;
top: 0.5rem;
}
2 changes: 1 addition & 1 deletion Shared/NavMenu.razor → Components/Layout/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</div>

<div class="nav-item px-3">
<NavLink class="nav-link" href="showdata">
<NavLink class="nav-link" href="weather">
<span class="oi oi-list-rich" aria-hidden="true"></span> Weather
</NavLink>
</div>
Expand Down
101 changes: 101 additions & 0 deletions Components/Layout/NavMenu.razor.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
.navbar-toggler {
appearance: none;
cursor: pointer;
width: 3.5rem;
height: 2.5rem;
color: white;
position: absolute;
top: 0.5rem;
right: 1rem;
border: 1px solid rgba(255, 255, 255, 0.1);
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);
}

.navbar-toggler:checked {
background-color: rgba(255, 255, 255, 0.5);
}

.top-row {
height: 3.5rem;
background-color: rgba(0,0,0,0.4);
}

.navbar-brand {
font-size: 1.1rem;
}

.bi {
display: inline-block;
position: relative;
width: 1.25rem;
height: 1.25rem;
margin-right: 0.75rem;
top: -1px;
background-size: cover;
}

.bi-house-door-fill {
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");
}

.bi-plus-square-fill {
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");
}

.bi-list-nested {
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");
}

.nav-item {
font-size: 0.9rem;
padding-bottom: 0.5rem;
}

.nav-item:first-of-type {
padding-top: 1rem;
}

.nav-item:last-of-type {
padding-bottom: 1rem;
}

.nav-item ::deep a {
color: #d7d7d7;
border-radius: 4px;
height: 3rem;
display: flex;
align-items: center;
line-height: 3rem;
}

.nav-item ::deep a.active {
background-color: rgba(255,255,255,0.25);
color: white;
}

.nav-item ::deep a:hover {
background-color: rgba(255,255,255,0.1);
color: white;
}

.nav-scrollable {
display: none;
}

.navbar-toggler:checked ~ .nav-scrollable {
display: block;
}

@media (min-width: 641px) {
.navbar-toggler {
display: none;
}

.nav-scrollable {
/* Never collapse the sidebar for wide screens */
display: block;
/* Allow sidebar to scroll for tall menus */
height: calc(100vh - 3.5rem);
overflow-y: auto;
}
}
File renamed without changes.
70 changes: 70 additions & 0 deletions Components/Pages/Home.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
@page "/"
@using System.ComponentModel.DataAnnotations;
@using Microsoft.AspNetCore.Components.QuickGrid

<PageTitle>Home</PageTitle>

<h1>Home</h1>

<h2>@Message</h2>

Welcome to your new app.

<h3>Add customer</h3>

<EditForm FormName="submit-customer" method="post" Model="NewCustomer" OnValidSubmit="AddCustomer" class="col-lg-6">
<DataAnnotationsValidator />
<ValidationSummary />
<div class="mb-3">
<label for="name" class="form-label">Name</label>
<InputText id="name" class="form-control" @bind-Value="NewCustomer.Name" />
<ValidationMessage For="() => NewCustomer.Name" />
</div>
<div class="mb-3">
<label for="email" class="form-label">Email</label>
<InputText id="email" class="form-control" @bind-Value="NewCustomer.Email" />
</div>
<div class="mb-3 form-check">
<InputCheckbox id="preferred" class="form-check-input" @bind-Value="NewCustomer.IsPreferred" />
<label for="preferred" class="form-check-label">Preferred</label>
</div>
<button type="submit">Submit</button>
</EditForm>

@if (customers.Count > 0)
{
<QuickGrid Items="customers.AsQueryable()" >
<PropertyColumn Property="c => c.Name" />
<PropertyColumn Property="c => c.Email" />
<PropertyColumn Property="c => c.IsPreferred" Title="Preferred" />
</QuickGrid>
}

@code {
static List<Customer> customers = new();

[Parameter]
public string Message { get; set; } = "Hello, world!";

[SupplyParameterFromForm]
public Customer NewCustomer { get; set; } = new();

public void AddCustomer()
{
customers.Add(NewCustomer);
NewCustomer = new();
}

public class Customer
{
public int Id { get; set; }

[Required]
public string? Name { get; set; }

[EmailAddress]
public string? Email { get; set; }

public bool IsPreferred { get; set; }
}
}
10 changes: 9 additions & 1 deletion Pages/Weather.razor → Components/Pages/Weather.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@page "/showdata"
@page "/weather"
@attribute [StreamRendering(true)]

<PageTitle>Weather</PageTitle>
Expand Down Expand Up @@ -57,4 +57,12 @@ else
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
}).ToArray();
}

private class WeatherForecast
{
public DateOnly Date { get; set; }
public int TemperatureC { get; set; }
public string? Summary { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
}
5 changes: 1 addition & 4 deletions Controllers/MvcController.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using BlazorSSR.Pages;
using BlazorSSR.Shared;
using Microsoft.AspNetCore.Components;
using BlazorSSR.Components.Pages;
using Microsoft.AspNetCore.Components.Endpoints;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Routing;

namespace BlazorSSR.Controllers;
public class MvcController : Controller
Expand Down
15 changes: 0 additions & 15 deletions Data/WeatherForecast.cs

This file was deleted.

12 changes: 0 additions & 12 deletions Models/WeatherForecast.cs

This file was deleted.

Loading

0 comments on commit 870a835

Please sign in to comment.