From b3ac007c8278e4cb8a5f04c8d615dee089100825 Mon Sep 17 00:00:00 2001 From: mcmuzzle Date: Wed, 4 Sep 2024 22:30:49 +0200 Subject: [PATCH] adding solution and main project --- .editorconfig | 21 ++++ .gitignore | 19 ++++ src/LudikZone.sln | 22 ++++ src/LudikZoneBlazor/Components/App.razor | 20 ++++ .../Components/Layout/MainLayout.razor | 104 ++++++++++++++++++ .../Components/Layout/NavMenu.razor | 8 ++ .../Components/Pages/Counter.razor | 18 +++ .../Components/Pages/Error.razor | 36 ++++++ .../Components/Pages/Home.razor | 58 ++++++++++ .../Components/Pages/Weather.razor | 60 ++++++++++ src/LudikZoneBlazor/Components/Routes.razor | 6 + src/LudikZoneBlazor/Components/_Imports.razor | 12 ++ src/LudikZoneBlazor/LudikZoneBlazor.csproj | 13 +++ src/LudikZoneBlazor/Program.cs | 31 ++++++ .../Properties/launchSettings.json | 38 +++++++ .../appsettings.Development.json | 8 ++ src/LudikZoneBlazor/appsettings.json | 9 ++ src/LudikZoneBlazor/wwwroot/favicon.ico | Bin 0 -> 15086 bytes 18 files changed, 483 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 src/LudikZone.sln create mode 100644 src/LudikZoneBlazor/Components/App.razor create mode 100644 src/LudikZoneBlazor/Components/Layout/MainLayout.razor create mode 100644 src/LudikZoneBlazor/Components/Layout/NavMenu.razor create mode 100644 src/LudikZoneBlazor/Components/Pages/Counter.razor create mode 100644 src/LudikZoneBlazor/Components/Pages/Error.razor create mode 100644 src/LudikZoneBlazor/Components/Pages/Home.razor create mode 100644 src/LudikZoneBlazor/Components/Pages/Weather.razor create mode 100644 src/LudikZoneBlazor/Components/Routes.razor create mode 100644 src/LudikZoneBlazor/Components/_Imports.razor create mode 100644 src/LudikZoneBlazor/LudikZoneBlazor.csproj create mode 100644 src/LudikZoneBlazor/Program.cs create mode 100644 src/LudikZoneBlazor/Properties/launchSettings.json create mode 100644 src/LudikZoneBlazor/appsettings.Development.json create mode 100644 src/LudikZoneBlazor/appsettings.json create mode 100644 src/LudikZoneBlazor/wwwroot/favicon.ico diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..43ea4c3 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +root = true + +#### .NET Coding Conventions #### +# C# files +[*.cs] +dotnet_diagnostic.IDE1006.severity = warning +dotnet_diagnostic.IDE0005.severity = error +dotnet_diagnostic.CA5394.severity = none + +# Exclude generated code +[src/**/Migrations/*.cs] +generated_code = true +dotnet_analyzer_diagnostic.severity = none + +#### Core EditorConfig Options #### +[*] +# Indentation and spacing +indent_style = space +indent_size = 4 +charset = utf-8 +trim_trailing_whitespace = true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a395674 --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +# ---> VisualStudioCode +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +bin +obj +report +tools/ +TestResults \ No newline at end of file diff --git a/src/LudikZone.sln b/src/LudikZone.sln new file mode 100644 index 0000000..0a606bb --- /dev/null +++ b/src/LudikZone.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LudikZoneBlazor", "LudikZoneBlazor\LudikZoneBlazor.csproj", "{169488B5-AE88-41C0-8EFE-658E5A259EDB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {169488B5-AE88-41C0-8EFE-658E5A259EDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {169488B5-AE88-41C0-8EFE-658E5A259EDB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {169488B5-AE88-41C0-8EFE-658E5A259EDB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {169488B5-AE88-41C0-8EFE-658E5A259EDB}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/src/LudikZoneBlazor/Components/App.razor b/src/LudikZoneBlazor/Components/App.razor new file mode 100644 index 0000000..fc42740 --- /dev/null +++ b/src/LudikZoneBlazor/Components/App.razor @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/LudikZoneBlazor/Components/Layout/MainLayout.razor b/src/LudikZoneBlazor/Components/Layout/MainLayout.razor new file mode 100644 index 0000000..ae6f235 --- /dev/null +++ b/src/LudikZoneBlazor/Components/Layout/MainLayout.razor @@ -0,0 +1,104 @@ +@inherits LayoutComponentBase + + + + + + + + + Application + + + + + + + + + @Body + + + + +
+ An unhandled error has occurred. + Reload + 🗙 +
+ +@code { + private bool _drawerOpen = true; + private bool _isDarkMode = true; + private MudTheme? _theme = null; + + protected override void OnInitialized() + { + base.OnInitialized(); + + _theme = new() + { + PaletteLight = _lightPalette, + PaletteDark = _darkPalette, + LayoutProperties = new LayoutProperties() + }; + } + + + private void DrawerToggle() + { + _drawerOpen = !_drawerOpen; + } + + private void DarkModeToggle() + { + _isDarkMode = !_isDarkMode; + } + + private readonly PaletteLight _lightPalette = new() + { + Black = "#110e2d", + AppbarText = "#424242", + AppbarBackground = "rgba(255,255,255,0.8)", + DrawerBackground = "#ffffff", + GrayLight = "#e8e8e8", + GrayLighter = "#f9f9f9", + }; + + private readonly PaletteDark _darkPalette = new() + { + Primary = "#7e6fff", + Surface = "#1e1e2d", + Background = "#1a1a27", + BackgroundGray = "#151521", + AppbarText = "#92929f", + AppbarBackground = "rgba(26,26,39,0.8)", + DrawerBackground = "#1a1a27", + ActionDefault = "#74718e", + ActionDisabled = "#9999994d", + ActionDisabledBackground = "#605f6d4d", + TextPrimary = "#b2b0bf", + TextSecondary = "#92929f", + TextDisabled = "#ffffff33", + DrawerIcon = "#92929f", + DrawerText = "#92929f", + GrayLight = "#2a2833", + GrayLighter = "#1e1e2d", + Info = "#4a86ff", + Success = "#3dcb6c", + Warning = "#ffb545", + Error = "#ff3f5f", + LinesDefault = "#33323e", + TableLines = "#33323e", + Divider = "#292838", + OverlayLight = "#1e1e2d80", + }; + + public string DarkLightModeButtonIcon => _isDarkMode switch + { + true => Icons.Material.Rounded.AutoMode, + false => Icons.Material.Outlined.DarkMode, + }; +} + + diff --git a/src/LudikZoneBlazor/Components/Layout/NavMenu.razor b/src/LudikZoneBlazor/Components/Layout/NavMenu.razor new file mode 100644 index 0000000..0225ad0 --- /dev/null +++ b/src/LudikZoneBlazor/Components/Layout/NavMenu.razor @@ -0,0 +1,8 @@ + + + Home + Counter + Weather + + + diff --git a/src/LudikZoneBlazor/Components/Pages/Counter.razor b/src/LudikZoneBlazor/Components/Pages/Counter.razor new file mode 100644 index 0000000..db95bf3 --- /dev/null +++ b/src/LudikZoneBlazor/Components/Pages/Counter.razor @@ -0,0 +1,18 @@ +@page "/counter" + +Counter + +Counter + +Current count: @currentCount + +Click me + +@code { + private int currentCount = 0; + + private void IncrementCount() + { + currentCount++; + } +} diff --git a/src/LudikZoneBlazor/Components/Pages/Error.razor b/src/LudikZoneBlazor/Components/Pages/Error.razor new file mode 100644 index 0000000..576cc2d --- /dev/null +++ b/src/LudikZoneBlazor/Components/Pages/Error.razor @@ -0,0 +1,36 @@ +@page "/Error" +@using System.Diagnostics + +Error + +

Error.

+

An error occurred while processing your request.

+ +@if (ShowRequestId) +{ +

+ Request ID: @RequestId +

+} + +

Development Mode

+

+ Swapping to Development environment will display more detailed information about the error that occurred. +

+

+ The Development environment shouldn't be enabled for deployed applications. + It can result in displaying sensitive information from exceptions to end users. + For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development + and restarting the app. +

+ +@code{ + [CascadingParameter] + private HttpContext? HttpContext { get; set; } + + private string? RequestId { get; set; } + private bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + + protected override void OnInitialized() => + RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier; +} diff --git a/src/LudikZoneBlazor/Components/Pages/Home.razor b/src/LudikZoneBlazor/Components/Pages/Home.razor new file mode 100644 index 0000000..2ba687d --- /dev/null +++ b/src/LudikZoneBlazor/Components/Pages/Home.razor @@ -0,0 +1,58 @@ +@page "/" + +Home + +Hello, world! +Welcome to your new app, powered by MudBlazor and the .NET 8 Template! + + + You can find documentation and examples on our website here: + + www.mudblazor.com + + + +
+Interactivity in this Template +
+ + When you opt for the "Global" Interactivity Location,
+ the render modes are defined in App.razor and consequently apply to all child components.
+ In this case, providers are globally set in the MainLayout.
+
+ On the other hand, if you choose the "Per page/component" Interactivity Location,
+ it is necessary to include the
+
+ <MudPopoverProvider />
+ <MudDialogProvider />
+ <MudSnackbarProvider />
+
+ components on every interactive page.
+
+ If a render mode is not specified for a page, it defaults to Server-Side Rendering (SSR),
+ similar to this page. While MudBlazor allows pages to be rendered in SSR,
+ please note that interactive features, such as buttons and dropdown menus, will not be functional. +
+ +
+What's New in Blazor with the Release of .NET 8 +
+Prerendering + + If you're exploring the features of .NET 8 Blazor,
you might be pleasantly surprised to learn that each page is prerendered on the server,
regardless of the selected render mode.

+ This means that you'll need to inject all necessary services on the server,
even when opting for the wasm (WebAssembly) render mode.

+ This prerendering functionality is crucial to ensuring that WebAssembly mode feels fast and responsive,
especially when it comes to initial page load times.

+ For more information on how to detect prerendering and leverage the RenderContext, you can refer to the following link: + + More details + +
+ +
+InteractiveAuto + + A discussion on how to achieve this can be found here: + + More details + + \ No newline at end of file diff --git a/src/LudikZoneBlazor/Components/Pages/Weather.razor b/src/LudikZoneBlazor/Components/Pages/Weather.razor new file mode 100644 index 0000000..3ffd7d8 --- /dev/null +++ b/src/LudikZoneBlazor/Components/Pages/Weather.razor @@ -0,0 +1,60 @@ +@page "/weather" + + + +Weather + +Weather forecast +This component demonstrates fetching data from the server. + +@if (forecasts == null) +{ + +} +else +{ + + + Date + Temp. (C) + Temp. (F) + Summary + + + @context.Date + @context.TemperatureC + @context.TemperatureF + @context.Summary + + + + + +} + +@code { + private WeatherForecast[]? forecasts; + + protected override async Task OnInitializedAsync() + { + // Simulate asynchronous loading to demonstrate a loading indicator + await Task.Delay(500); + + var startDate = DateOnly.FromDateTime(DateTime.Now); + var summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" }; + forecasts = Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = startDate.AddDays(index), + TemperatureC = Random.Shared.Next(-20, 55), + 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); + } +} diff --git a/src/LudikZoneBlazor/Components/Routes.razor b/src/LudikZoneBlazor/Components/Routes.razor new file mode 100644 index 0000000..f756e19 --- /dev/null +++ b/src/LudikZoneBlazor/Components/Routes.razor @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/LudikZoneBlazor/Components/_Imports.razor b/src/LudikZoneBlazor/Components/_Imports.razor new file mode 100644 index 0000000..252c514 --- /dev/null +++ b/src/LudikZoneBlazor/Components/_Imports.razor @@ -0,0 +1,12 @@ +@using System.Net.Http +@using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using static Microsoft.AspNetCore.Components.Web.RenderMode +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.JSInterop +@using MudBlazor +@using MudBlazor.Services +@using LudikZoneBlazor +@using LudikZoneBlazor.Components diff --git a/src/LudikZoneBlazor/LudikZoneBlazor.csproj b/src/LudikZoneBlazor/LudikZoneBlazor.csproj new file mode 100644 index 0000000..e4aa989 --- /dev/null +++ b/src/LudikZoneBlazor/LudikZoneBlazor.csproj @@ -0,0 +1,13 @@ + + + + net8.0 + enable + enable + + + + + + + diff --git a/src/LudikZoneBlazor/Program.cs b/src/LudikZoneBlazor/Program.cs new file mode 100644 index 0000000..08009fe --- /dev/null +++ b/src/LudikZoneBlazor/Program.cs @@ -0,0 +1,31 @@ +using MudBlazor.Services; +using LudikZoneBlazor.Components; + +var builder = WebApplication.CreateBuilder(args); + +// Add MudBlazor services +builder.Services.AddMudServices(); + +// Add services to the container. +builder.Services.AddRazorComponents() + .AddInteractiveServerComponents(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (!app.Environment.IsDevelopment()) +{ + app.UseExceptionHandler("/Error", createScopeForErrors: true); + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + app.UseHsts(); +} + +app.UseHttpsRedirection(); + +app.UseStaticFiles(); +app.UseAntiforgery(); + +app.MapRazorComponents() + .AddInteractiveServerRenderMode(); + +app.Run(); diff --git a/src/LudikZoneBlazor/Properties/launchSettings.json b/src/LudikZoneBlazor/Properties/launchSettings.json new file mode 100644 index 0000000..de483f5 --- /dev/null +++ b/src/LudikZoneBlazor/Properties/launchSettings.json @@ -0,0 +1,38 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:15132", + "sslPort": 44355 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:5031", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:7201;http://localhost:5031", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } + } diff --git a/src/LudikZoneBlazor/appsettings.Development.json b/src/LudikZoneBlazor/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/src/LudikZoneBlazor/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/src/LudikZoneBlazor/appsettings.json b/src/LudikZoneBlazor/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/src/LudikZoneBlazor/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/src/LudikZoneBlazor/wwwroot/favicon.ico b/src/LudikZoneBlazor/wwwroot/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..12392236657563eb8cc764f235e66d568b3a0fbb GIT binary patch literal 15086 zcmd5@3vgXU89or@;sb&xh>sx^P*g@JAPS{Yd_tiueWi_Q(uStVO_SUgeWuMhXESw* zFTgS?1+faFJmjS?j^l{KW$MUNQRF4GG;Mi{HEn^W?Ir8??>T$U?zwwz&J9WFoo@fL zyZ>{a|NgtNtV66CYy5Z%aGZ6^r!DJCmSv3_=jV^Itmjd76d=`iyvMTE0^zg30g2Uu zMCIalk_Qgt|D3VIc-Fau=bfv0&e@3c9MWc_Cwb1k2g%_DMkXCpKVB%j4?3hAp%_Srwg;P_+2y@BU?Pv%*BDe&H|fIGkot3MH^3zhSx?rD75 zr91frjXX%R7CjY56EpVr@J#QCl7_}E{D^Lm!enjQR-q7jt3+IJx zuIf(TGg~)l1bznc;fu-f>BFpjW)zp#*Vh2=*>YUHJz?kkGMp&?oO_kZpEqSE#J0P% zgZhOrc)0oxvfhZudq&3yb4K0r?zJI?=+6ZDJ1+>Re%|QK9>(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