Skip to content

Commit c2dca4e

Browse files
New sample added
1 parent 0216ca3 commit c2dca4e

File tree

79 files changed

+4432
-0
lines changed

Some content is hidden

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

79 files changed

+4432
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@inherits LayoutComponentBase
2+
3+
<div class="page">
4+
<div class="sidebar">
5+
<NavMenu />
6+
</div>
7+
8+
<main>
9+
<div class="top-row px-4">
10+
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
11+
</div>
12+
13+
<article class="content px-4">
14+
@Body
15+
</article>
16+
</main>
17+
</div>
18+
19+
<div id="blazor-error-ui">
20+
An unhandled error has occurred.
21+
<a href="" class="reload">Reload</a>
22+
<a class="dismiss">🗙</a>
23+
</div>
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
.page {
2+
position: relative;
3+
display: flex;
4+
flex-direction: column;
5+
}
6+
7+
main {
8+
flex: 1;
9+
}
10+
11+
.sidebar {
12+
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
13+
}
14+
15+
.top-row {
16+
background-color: #f7f7f7;
17+
border-bottom: 1px solid #d6d5d5;
18+
justify-content: flex-end;
19+
height: 3.5rem;
20+
display: flex;
21+
align-items: center;
22+
}
23+
24+
.top-row ::deep a, .top-row ::deep .btn-link {
25+
white-space: nowrap;
26+
margin-left: 1.5rem;
27+
text-decoration: none;
28+
}
29+
30+
.top-row ::deep a:hover, .top-row ::deep .btn-link:hover {
31+
text-decoration: underline;
32+
}
33+
34+
.top-row ::deep a:first-child {
35+
overflow: hidden;
36+
text-overflow: ellipsis;
37+
}
38+
39+
@media (max-width: 640.98px) {
40+
.top-row {
41+
justify-content: space-between;
42+
}
43+
44+
.top-row ::deep a, .top-row ::deep .btn-link {
45+
margin-left: 0;
46+
}
47+
}
48+
49+
@media (min-width: 641px) {
50+
.page {
51+
flex-direction: row;
52+
}
53+
54+
.sidebar {
55+
width: 250px;
56+
height: 100vh;
57+
position: sticky;
58+
top: 0;
59+
}
60+
61+
.top-row {
62+
position: sticky;
63+
top: 0;
64+
z-index: 1;
65+
}
66+
67+
.top-row.auth ::deep a:first-child {
68+
flex: 1;
69+
text-align: right;
70+
width: 0;
71+
}
72+
73+
.top-row, article {
74+
padding-left: 2rem !important;
75+
padding-right: 1.5rem !important;
76+
}
77+
}
78+
79+
#blazor-error-ui {
80+
background: lightyellow;
81+
bottom: 0;
82+
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
83+
display: none;
84+
left: 0;
85+
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
86+
position: fixed;
87+
width: 100%;
88+
z-index: 1000;
89+
}
90+
91+
#blazor-error-ui .dismiss {
92+
cursor: pointer;
93+
position: absolute;
94+
right: 0.75rem;
95+
top: 0.5rem;
96+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
@implements IDisposable
2+
3+
@inject NavigationManager NavigationManager
4+
5+
<div class="top-row ps-3 navbar navbar-dark">
6+
<div class="container-fluid">
7+
<a class="navbar-brand" href="">ServerWasm-Global-Individual</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+
33+
<div class="nav-item px-3">
34+
<NavLink class="nav-link" href="auth">
35+
<span class="bi bi-lock-nav-menu" aria-hidden="true"></span> Auth Required
36+
</NavLink>
37+
</div>
38+
39+
<AuthorizeView>
40+
<Authorized>
41+
<div class="nav-item px-3">
42+
<NavLink class="nav-link" href="Account/Manage">
43+
<span class="bi bi-person-fill-nav-menu" aria-hidden="true"></span> @context.User.Identity?.Name
44+
</NavLink>
45+
</div>
46+
<div class="nav-item px-3">
47+
<form action="Account/Logout" method="post">
48+
<AntiforgeryToken />
49+
<input type="hidden" name="ReturnUrl" value="@currentUrl" />
50+
<button type="submit" class="nav-link">
51+
<span class="bi bi-arrow-bar-left-nav-menu" aria-hidden="true"></span> Logout
52+
</button>
53+
</form>
54+
</div>
55+
</Authorized>
56+
<NotAuthorized>
57+
<div class="nav-item px-3">
58+
<NavLink class="nav-link" href="Account/Register">
59+
<span class="bi bi-person-nav-menu" aria-hidden="true"></span> Register
60+
</NavLink>
61+
</div>
62+
<div class="nav-item px-3">
63+
<NavLink class="nav-link" href="Account/Login">
64+
<span class="bi bi-person-badge-nav-menu" aria-hidden="true"></span> Login
65+
</NavLink>
66+
</div>
67+
</NotAuthorized>
68+
</AuthorizeView>
69+
</nav>
70+
</div>
71+
72+
@code {
73+
private string? currentUrl;
74+
75+
protected override void OnInitialized()
76+
{
77+
currentUrl = NavigationManager.ToBaseRelativePath(NavigationManager.Uri);
78+
NavigationManager.LocationChanged += OnLocationChanged;
79+
}
80+
81+
private void OnLocationChanged(object? sender, LocationChangedEventArgs e)
82+
{
83+
currentUrl = NavigationManager.ToBaseRelativePath(e.Location);
84+
StateHasChanged();
85+
}
86+
87+
public void Dispose()
88+
{
89+
NavigationManager.LocationChanged -= OnLocationChanged;
90+
}
91+
}
92+
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
.navbar-toggler {
2+
appearance: none;
3+
cursor: pointer;
4+
width: 3.5rem;
5+
height: 2.5rem;
6+
color: white;
7+
position: absolute;
8+
top: 0.5rem;
9+
right: 1rem;
10+
border: 1px solid rgba(255, 255, 255, 0.1);
11+
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);
12+
}
13+
14+
.navbar-toggler:checked {
15+
background-color: rgba(255, 255, 255, 0.5);
16+
}
17+
18+
.top-row {
19+
height: 3.5rem;
20+
background-color: rgba(0,0,0,0.4);
21+
}
22+
23+
.navbar-brand {
24+
font-size: 1.1rem;
25+
}
26+
27+
.bi {
28+
display: inline-block;
29+
position: relative;
30+
width: 1.25rem;
31+
height: 1.25rem;
32+
margin-right: 0.75rem;
33+
top: -1px;
34+
background-size: cover;
35+
}
36+
37+
.bi-house-door-fill-nav-menu {
38+
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");
39+
}
40+
41+
.bi-plus-square-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-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");
43+
}
44+
45+
.bi-list-nested-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-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");
47+
}
48+
49+
.bi-lock-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 d='M8 1a2 2 0 0 1 2 2v4H6V3a2 2 0 0 1 2-2zm3 6V3a3 3 0 0 0-6 0v4a2 2 0 0 0-2 2v5a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2zM5 8h6a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1z'/%3E%3C/svg%3E");
51+
}
52+
53+
.bi-person-nav-menu {
54+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-person' viewBox='0 0 16 16'%3E%3Cpath d='M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6Zm2-3a2 2 0 1 1-4 0 2 2 0 0 1 4 0Zm4 8c0 1-1 1-1 1H3s-1 0-1-1 1-4 6-4 6 3 6 4Zm-1-.004c-.001-.246-.154-.986-.832-1.664C11.516 10.68 10.289 10 8 10c-2.29 0-3.516.68-4.168 1.332-.678.678-.83 1.418-.832 1.664h10Z'/%3E%3C/svg%3E");
55+
}
56+
57+
.bi-person-badge-nav-menu {
58+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-person-badge' viewBox='0 0 16 16'%3E%3Cpath d='M6.5 2a.5.5 0 0 0 0 1h3a.5.5 0 0 0 0-1h-3zM11 8a3 3 0 1 1-6 0 3 3 0 0 1 6 0z'/%3E%3Cpath d='M4.5 0A2.5 2.5 0 0 0 2 2.5V14a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V2.5A2.5 2.5 0 0 0 11.5 0h-7zM3 2.5A1.5 1.5 0 0 1 4.5 1h7A1.5 1.5 0 0 1 13 2.5v10.795a4.2 4.2 0 0 0-.776-.492C11.392 12.387 10.063 12 8 12s-3.392.387-4.224.803a4.2 4.2 0 0 0-.776.492V2.5z'/%3E%3C/svg%3E");
59+
}
60+
61+
.bi-person-fill-nav-menu {
62+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-person-fill' viewBox='0 0 16 16'%3E%3Cpath d='M3 14s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1H3Zm5-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z'/%3E%3C/svg%3E");
63+
}
64+
65+
.bi-arrow-bar-left-nav-menu {
66+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-arrow-bar-left' viewBox='0 0 16 16'%3E%3Cpath d='M12.5 15a.5.5 0 0 1-.5-.5v-13a.5.5 0 0 1 1 0v13a.5.5 0 0 1-.5.5ZM10 8a.5.5 0 0 1-.5.5H3.707l2.147 2.146a.5.5 0 0 1-.708.708l-3-3a.5.5 0 0 1 0-.708l3-3a.5.5 0 1 1 .708.708L3.707 7.5H9.5a.5.5 0 0 1 .5.5Z'/%3E%3C/svg%3E");
67+
}
68+
69+
.nav-item {
70+
font-size: 0.9rem;
71+
padding-bottom: 0.5rem;
72+
}
73+
74+
.nav-item:first-of-type {
75+
padding-top: 1rem;
76+
}
77+
78+
.nav-item:last-of-type {
79+
padding-bottom: 1rem;
80+
}
81+
82+
.nav-item ::deep .nav-link {
83+
color: #d7d7d7;
84+
background: none;
85+
border: none;
86+
border-radius: 4px;
87+
height: 3rem;
88+
display: flex;
89+
align-items: center;
90+
line-height: 3rem;
91+
width: 100%;
92+
}
93+
94+
.nav-item ::deep a.active {
95+
background-color: rgba(255,255,255,0.37);
96+
color: white;
97+
}
98+
99+
.nav-item ::deep .nav-link:hover {
100+
background-color: rgba(255,255,255,0.1);
101+
color: white;
102+
}
103+
104+
.nav-scrollable {
105+
display: none;
106+
}
107+
108+
.navbar-toggler:checked ~ .nav-scrollable {
109+
display: block;
110+
}
111+
112+
@media (min-width: 641px) {
113+
.navbar-toggler {
114+
display: none;
115+
}
116+
117+
.nav-scrollable {
118+
/* Never collapse the sidebar for wide screens */
119+
display: block;
120+
121+
/* Allow sidebar to scroll for tall menus */
122+
height: calc(100vh - 3.5rem);
123+
overflow-y: auto;
124+
}
125+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@page "/auth"
2+
3+
@using Microsoft.AspNetCore.Authorization
4+
5+
@attribute [Authorize]
6+
7+
<PageTitle>Auth</PageTitle>
8+
9+
<h1>You are authenticated</h1>
10+
11+
<AuthorizeView>
12+
Hello @context.User.Identity?.Name!
13+
</AuthorizeView>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@page "/counter"
2+
3+
<PageTitle>Counter</PageTitle>
4+
5+
<h1>Counter</h1>
6+
7+
<p role="status">Current count: @currentCount</p>
8+
9+
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
10+
11+
@code {
12+
private int currentCount = 0;
13+
14+
private void IncrementCount()
15+
{
16+
currentCount++;
17+
}
18+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@page "/"
2+
3+
<PageTitle>Home</PageTitle>
4+
5+
<h1>Hello, world!</h1>
6+
7+
Welcome to your new app.

0 commit comments

Comments
 (0)