From 106c70be002cfdfb55e61b3abd1109cb9297e086 Mon Sep 17 00:00:00 2001 From: A-Guldborg Date: Tue, 16 Apr 2024 22:59:25 +0200 Subject: [PATCH] Adds dark mode --- Shifty.App/Components/MenuItems.razor | 5 ++- Shifty.App/Components/ProductManager.razor | 5 ++- Shifty.App/Components/UserTable.razor | 7 ++-- Shifty.App/Shared/MainLayout.razor | 44 ++++++++++++++++++++-- Shifty.App/wwwroot/index.html | 2 +- 5 files changed, 52 insertions(+), 11 deletions(-) diff --git a/Shifty.App/Components/MenuItems.razor b/Shifty.App/Components/MenuItems.razor index f2537e4..5fca9e2 100644 --- a/Shifty.App/Components/MenuItems.razor +++ b/Shifty.App/Components/MenuItems.razor @@ -43,7 +43,8 @@ @@ -54,7 +55,7 @@ @{ if (context.Item.Active) { - } else diff --git a/Shifty.App/Components/ProductManager.razor b/Shifty.App/Components/ProductManager.razor index 01a538e..77648ec 100644 --- a/Shifty.App/Components/ProductManager.razor +++ b/Shifty.App/Components/ProductManager.razor @@ -48,7 +48,8 @@ @@ -57,7 +58,7 @@ @{ if (context.Item.Visible) { - } else diff --git a/Shifty.App/Components/UserTable.razor b/Shifty.App/Components/UserTable.razor index fd6d41a..b85e0f3 100644 --- a/Shifty.App/Components/UserTable.razor +++ b/Shifty.App/Components/UserTable.razor @@ -29,7 +29,8 @@ ValueChanged="@(s => OnSearch(s))" Placeholder="Search" Adornment="Adornment.Start" - AdornmentIcon="Icons.Material.Filled.Search" + AdornmentIcon="@Icons.Material.Filled.Search" + IconSize="Size.Medium" /> @@ -59,7 +60,7 @@ No matching records found - + @@ -120,6 +121,6 @@ { ((SimpleUserResponse)user).UserGroup = UserGroupBeforeEdit; StateHasChanged(); - Snackbar.Add("Canceled editing", Severity.Warning); + Snackbar.Add("Canceled editing", Severity.Info); } } \ No newline at end of file diff --git a/Shifty.App/Shared/MainLayout.razor b/Shifty.App/Shared/MainLayout.razor index c9ab966..95f10eb 100644 --- a/Shifty.App/Shared/MainLayout.razor +++ b/Shifty.App/Shared/MainLayout.razor @@ -2,7 +2,7 @@ @using MudBlazor.Utilities @inherits LayoutComponentBase - + @@ -14,6 +14,8 @@ Analog Shifty + + @@ -28,7 +30,7 @@ - + Please login @@ -41,10 +43,12 @@ @code { bool _drawerOpen = true; + MudThemeProvider _themeProvider; + private bool _darkmode { get; set; } = false; readonly MudTheme _theme = new MudTheme() { - Palette = new Palette() + Palette = new PaletteLight() { Primary = new MudColor("#775440"), Secondary = new MudColor("#38251a"), @@ -56,6 +60,31 @@ Warning = new MudColor("#fed521"), Success = new MudColor("#738d4b"), Dark = Colors.Grey.Darken3, + }, + PaletteDark = new PaletteDark() + { + Primary = new MudColor("#B85C38"), + Secondary = new MudColor("#38251a"), + Tertiary = new MudColor("#8c674c"), + AppbarBackground = new MudColor("#1f1b16"), + Surface = new MudColor("#29221b"), + Background = new MudColor("#1f1b16"), + Info = new MudColor("#20455f"), + Error = new MudColor("#893c24"), + Warning = new MudColor("#fed521"), + Success = new MudColor("#738d4b"), + Dark = new MudColor("E0C097"), + TextPrimary = new MudColor("#f7e8da"), + TextSecondary = new MudColor("#f7e8da"), + AppbarText = new MudColor("#f7e8da"), + DrawerText = new MudColor("#f7e8da"), + DrawerIcon = new MudColor("#f7e8da"), + DrawerBackground = new MudColor("#29221b"), + Divider = new MudColor("#13110f"), + DividerLight = new MudColor("#13110f"), + TableLines = new MudColor("#13110f"), + ActionDefault = new MudColor("#E0C097"), + ActionDisabled = new MudColor("#474747"), } }; @@ -63,6 +92,15 @@ { } + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + _darkmode = await _themeProvider.GetSystemPreference(); + StateHasChanged(); + } + } + void DrawerToggle() { _drawerOpen = !_drawerOpen; diff --git a/Shifty.App/wwwroot/index.html b/Shifty.App/wwwroot/index.html index 75bb695..56a8b8e 100755 --- a/Shifty.App/wwwroot/index.html +++ b/Shifty.App/wwwroot/index.html @@ -22,7 +22,7 @@