diff --git a/Server/src/SOR.Admin/Components/Layout/MainLayout.razor b/Server/src/SOR.Admin/Components/Layout/MainLayout.razor index 453df6c..c39f163 100644 --- a/Server/src/SOR.Admin/Components/Layout/MainLayout.razor +++ b/Server/src/SOR.Admin/Components/Layout/MainLayout.razor @@ -1,17 +1,65 @@ @inherits LayoutComponentBase +@implements IDisposable +@inject NavigationManager Nav -
- -
-
- @Body -
-
+
+ + @* Mobile topbar: hamburger + brand. Hidden on desktop via CSS. *@ +
+ + + SOR Admin + +
+ + @* Backdrop: click outside the drawer to close it (mobile only). *@ + @if (_drawerOpen) + { +
+ } + +
+ +
+
+ @Body +
+
+
+
@Body + +@code { + private bool _drawerOpen; + + protected override void OnInitialized() + { + Nav.LocationChanged += OnLocationChanged; + } + + // Close the drawer automatically whenever the user navigates to any page. + private void OnLocationChanged(object? sender, LocationChangedEventArgs e) + { + _drawerOpen = false; + InvokeAsync(StateHasChanged); + } + + private void ToggleDrawer() => _drawerOpen = !_drawerOpen; + private void CloseDrawer() => _drawerOpen = false; + + public void Dispose() + { + Nav.LocationChanged -= OnLocationChanged; + } +} diff --git a/Server/src/SOR.Admin/Components/Layout/NavMenu.razor b/Server/src/SOR.Admin/Components/Layout/NavMenu.razor index cfc0133..fda8bb2 100644 --- a/Server/src/SOR.Admin/Components/Layout/NavMenu.razor +++ b/Server/src/SOR.Admin/Components/Layout/NavMenu.razor @@ -1,6 +1,6 @@ @inject IJSRuntime Js -