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 0000000..1239223 Binary files /dev/null and b/src/LudikZoneBlazor/wwwroot/favicon.ico differ