@@ -57,8 +57,7 @@
ShowOnHover="true"
Placement="Placement.Top"
Text="@description"
- RootClass="tag"
- RootStyle="background-color:#f5f5f5">
+ RootClass="tag">
…
}
diff --git a/Modix.Web/Pages/Index.razor b/Modix.Web/Pages/Index.razor
index 6cf3cd4e6..7385a9715 100644
--- a/Modix.Web/Pages/Index.razor
+++ b/Modix.Web/Pages/Index.razor
@@ -17,7 +17,13 @@
and check out our
GitHub repo!
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/Modix.Web/Pages/_Host.cshtml b/Modix.Web/Pages/_Host.cshtml
index 0d78d30c7..14ebc7c03 100644
--- a/Modix.Web/Pages/_Host.cshtml
+++ b/Modix.Web/Pages/_Host.cshtml
@@ -26,6 +26,7 @@
param-ShowInfractionState="@Request.Cookies[CookieConstants.ShowInfractionState]"
param-ShowDeletedInfractions="@Request.Cookies[CookieConstants.ShowDeletedInfractions]"
param-ShowInactivePromotions="@Request.Cookies[CookieConstants.ShowInactivePromotions]"
+ param-UseDarkMode="@Request.Cookies[CookieConstants.UseDarkMode]"
/>
diff --git a/Modix.Web/Services/CookieService.cs b/Modix.Web/Services/CookieService.cs
index fe60141be..b9afd472c 100644
--- a/Modix.Web/Services/CookieService.cs
+++ b/Modix.Web/Services/CookieService.cs
@@ -29,6 +29,12 @@ public async Task SetShowInactivePromotionsAsync(bool showInactivePromotions)
sessionState.ShowInactivePromotions = showInactivePromotions;
}
+ public async Task SetUseDarkModeAsync(bool useDarkMode)
+ {
+ await SetCookieAsync(CookieConstants.UseDarkMode, useDarkMode);
+ sessionState.UseDarkMode = useDarkMode;
+ }
+
private async Task SetCookieAsync
(string key, T value)
=> await jsRuntime.InvokeVoidAsync("eval", $"document.cookie = \"{key}={value}; path=/\";");
}
diff --git a/Modix.Web/Shared/MainLayout.razor b/Modix.Web/Shared/MainLayout.razor
index 448f695bb..a7d8ba2c3 100644
--- a/Modix.Web/Shared/MainLayout.razor
+++ b/Modix.Web/Shared/MainLayout.razor
@@ -1,15 +1,16 @@
@using Modix.Data.Models.Core;
+@using Modix.Web.Models
@using MudBlazor
@inherits LayoutComponentBase
-
+
-
+
@Body
@@ -19,12 +20,19 @@
@code {
+ [Inject]
+ public required SessionState SessionState { get; set; }
private MudTheme _theme = new()
{
- Palette = new()
+ Palette = new PaletteLight()
{
Primary = new("#803788"),
+ Surface = new("#fafafa")
+ },
+ PaletteDark = new PaletteDark()
+ {
+ Primary = new("#803788"),
},
Typography = new()
{
diff --git a/Modix.Web/Shared/NavMenu.razor b/Modix.Web/Shared/NavMenu.razor
index 07fefc615..bf7308789 100644
--- a/Modix.Web/Shared/NavMenu.razor
+++ b/Modix.Web/Shared/NavMenu.razor
@@ -29,6 +29,18 @@
+
+ @* The color: inherit here is needed to keep the colors consistent between link icons and light/dark theme icons
+ I would suggest not thinking about it too much :) *@
+
+
@@ -36,8 +48,23 @@
@code {
+ [Inject]
+ public required CookieService CookieService { get; set; }
+
+ [Parameter]
+ public bool DarkMode { get; set; }
+
+ [Parameter]
+ public EventCallback DarkModeChanged { get; set; }
private bool _drawerVisible;
private void ToggleDrawer() => _drawerVisible = !_drawerVisible;
+
+ private async Task ToggleDarkMode(bool toggled)
+ {
+ DarkMode = toggled;
+ await DarkModeChanged.InvokeAsync(DarkMode);
+ await CookieService.SetUseDarkModeAsync(DarkMode);
+ }
}