diff --git a/Microsoft.Azure.AppService.Authentication.WebAssembly.sln b/Microsoft.Azure.AppService.Authentication.WebAssembly.sln index a13ad4b..83ad103 100644 --- a/Microsoft.Azure.AppService.Authentication.WebAssembly.sln +++ b/Microsoft.Azure.AppService.Authentication.WebAssembly.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.1500 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32519.379 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.AppService.Authentication.WebAssembly", "src\Microsoft.Azure.AppService.Authentication.WebAssembly\Microsoft.Azure.AppService.Authentication.WebAssembly.csproj", "{7F186EA5-90A4-4FE9-970B-423074B4FB5A}" EndProject diff --git a/example/Api/Api.csproj b/example/Api/Api.csproj index 19d2e60..6644e13 100644 --- a/example/Api/Api.csproj +++ b/example/Api/Api.csproj @@ -1,10 +1,10 @@ - + - netcoreapp3.1 - v3 + net6.0 + v4 - + diff --git a/example/Api/local.settings.sample.json b/example/Api/local.settings.sample.json new file mode 100644 index 0000000..a105212 --- /dev/null +++ b/example/Api/local.settings.sample.json @@ -0,0 +1,12 @@ +{ + "IsEncrypted": false, + "Values": { + "AzureWebJobsStorage": "UseDevelopmentStorage=true", + "FUNCTIONS_WORKER_RUNTIME": "dotnet" + }, + "Host": { + "LocalHttpPort": 7071, + "CORS": "*", + "CORSCredentials": false + } +} diff --git a/example/Client/App.razor b/example/Client/App.razor index c3780a0..a535a01 100644 --- a/example/Client/App.razor +++ b/example/Client/App.razor @@ -1,5 +1,5 @@ - - + + @@ -13,10 +13,12 @@ } + + Not found -

Sorry, there's nothing at this address.

+

Sorry, there's nothing at this address.

diff --git a/example/Client/Client.csproj b/example/Client/Client.csproj index 4eddcce..6851395 100644 --- a/example/Client/Client.csproj +++ b/example/Client/Client.csproj @@ -1,20 +1,19 @@ - + - - netstandard2.1 - 3.0 - + + net6.0 + enable + enable + - - - - - - + + + + - - - - + + + + diff --git a/example/Client/Pages/Counter.razor b/example/Client/Pages/Counter.razor index 8641f78..ef23cb3 100644 --- a/example/Client/Pages/Counter.razor +++ b/example/Client/Pages/Counter.razor @@ -1,8 +1,10 @@ @page "/counter" +Counter +

Counter

-

Current count: @currentCount

+

Current count: @currentCount

diff --git a/example/Client/Pages/FetchData.razor b/example/Client/Pages/FetchData.razor index 7392391..5d44e3c 100644 --- a/example/Client/Pages/FetchData.razor +++ b/example/Client/Pages/FetchData.razor @@ -1,7 +1,9 @@ -@page "/fetchdata" +@page "/fetchdata" @inject HttpClient Http @attribute [Authorize] +Weather forecast +

Weather forecast

This component demonstrates fetching data from the server.

@@ -36,7 +38,7 @@ else } @code { - private WeatherForecast[] forecasts; + private WeatherForecast[]? forecasts; protected override async Task OnInitializedAsync() { diff --git a/example/Client/Pages/Index.razor b/example/Client/Pages/Index.razor index e54d914..6085c4a 100644 --- a/example/Client/Pages/Index.razor +++ b/example/Client/Pages/Index.razor @@ -1,5 +1,7 @@ @page "/" +Index +

Hello, world!

Welcome to your new app. diff --git a/example/Client/Program.cs b/example/Client/Program.cs index f92a201..34b638b 100644 --- a/example/Client/Program.cs +++ b/example/Client/Program.cs @@ -1,25 +1,13 @@ -using System; -using System.Net.Http; -using System.Threading.Tasks; +using Client; +using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using Microsoft.Azure.AppService.Authentication.WebAssembly; -using Microsoft.Extensions.DependencyInjection; -namespace Client -{ - public class Program - { - public static async Task Main(string[] args) - { - var builder = WebAssemblyHostBuilder.CreateDefault(args); - builder.RootComponents.Add("app"); +var builder = WebAssemblyHostBuilder.CreateDefault(args); +builder.RootComponents.Add("#app"); +builder.RootComponents.Add("head::after"); - var baseAddress = builder.Configuration["ApiHost"] ?? builder.HostEnvironment.BaseAddress; - builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(baseAddress) }); +builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.Configuration["ApiHost"] ?? builder.HostEnvironment.BaseAddress) }); +builder.Services.AddStaticWebAppsAuthentication(); - builder.Services.AddStaticWebAppsAuthentication(); - - await builder.Build().RunAsync(); - } - } -} +await builder.Build().RunAsync(); diff --git a/example/Client/Properties/launchSettings.json b/example/Client/Properties/launchSettings.json index ff0334f..d812af5 100644 --- a/example/Client/Properties/launchSettings.json +++ b/example/Client/Properties/launchSettings.json @@ -18,6 +18,7 @@ }, "Client": { "commandName": "Project", + "dotnetRunMessages": true, "launchBrowser": true, "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", "applicationUrl": "https://localhost:5001;http://localhost:5000", diff --git a/example/Client/Shared/LoginDisplay.razor b/example/Client/Shared/LoginDisplay.razor index 662c28b..0489ed0 100644 --- a/example/Client/Shared/LoginDisplay.razor +++ b/example/Client/Shared/LoginDisplay.razor @@ -1,5 +1,4 @@ -@using Microsoft.AspNetCore.Components.Authorization -@using Microsoft.AspNetCore.Components.WebAssembly.Authentication +@using Microsoft.AspNetCore.Components.WebAssembly.Authentication @inject NavigationManager Navigation @inject SignOutSessionStateManager SignOutManager diff --git a/example/Client/Shared/MainLayout.razor b/example/Client/Shared/MainLayout.razor index 8eca683..5bb2a17 100644 --- a/example/Client/Shared/MainLayout.razor +++ b/example/Client/Shared/MainLayout.razor @@ -1,15 +1,17 @@ @inherits LayoutComponentBase - - -
-
- +
+ -
- @Body -
-
\ No newline at end of file +
+
+ +
+ +
+ @Body +
+
+
diff --git a/example/Client/Shared/MainLayout.razor.css b/example/Client/Shared/MainLayout.razor.css new file mode 100644 index 0000000..c865427 --- /dev/null +++ b/example/Client/Shared/MainLayout.razor.css @@ -0,0 +1,81 @@ +.page { + position: relative; + display: flex; + flex-direction: column; +} + +main { + flex: 1; +} + +.sidebar { + background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); +} + +.top-row { + background-color: #f7f7f7; + border-bottom: 1px solid #d6d5d5; + justify-content: flex-end; + height: 3.5rem; + display: flex; + align-items: center; +} + + .top-row ::deep a, .top-row ::deep .btn-link { + white-space: nowrap; + margin-left: 1.5rem; + text-decoration: none; + } + + .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; + } + +@media (max-width: 640.98px) { + .top-row:not(.auth) { + display: none; + } + + .top-row.auth { + justify-content: space-between; + } + + .top-row ::deep a, .top-row ::deep .btn-link { + margin-left: 0; + } +} + +@media (min-width: 641px) { + .page { + flex-direction: row; + } + + .sidebar { + width: 250px; + height: 100vh; + position: sticky; + top: 0; + } + + .top-row { + position: sticky; + top: 0; + z-index: 1; + } + + .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; + } +} diff --git a/example/Client/Shared/NavMenu.razor b/example/Client/Shared/NavMenu.razor index 39aa4ee..8518c5b 100644 --- a/example/Client/Shared/NavMenu.razor +++ b/example/Client/Shared/NavMenu.razor @@ -1,34 +1,36 @@ - @code { private bool collapseNavMenu = true; - private string NavMenuCssClass => collapseNavMenu ? "collapse" : null; + private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; private void ToggleNavMenu() { diff --git a/example/Client/Shared/NavMenu.razor.css b/example/Client/Shared/NavMenu.razor.css new file mode 100644 index 0000000..acc5f9f --- /dev/null +++ b/example/Client/Shared/NavMenu.razor.css @@ -0,0 +1,62 @@ +.navbar-toggler { + background-color: rgba(255, 255, 255, 0.1); +} + +.top-row { + height: 3.5rem; + background-color: rgba(0,0,0,0.4); +} + +.navbar-brand { + font-size: 1.1rem; +} + +.oi { + width: 2rem; + font-size: 1.1rem; + vertical-align: text-top; + top: -2px; +} + +.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; +} + +@media (min-width: 641px) { + .navbar-toggler { + display: none; + } + + .collapse { + /* Never collapse the sidebar for wide screens */ + display: block; + } +} diff --git a/example/Client/Shared/SurveyPrompt.razor b/example/Client/Shared/SurveyPrompt.razor index 0271409..962027f 100644 --- a/example/Client/Shared/SurveyPrompt.razor +++ b/example/Client/Shared/SurveyPrompt.razor @@ -1,10 +1,10 @@ -