Files
webwindowconfigurator/Test.UI/Components/Layout/NavMenu.razor.cs
T
Annamaria Sassi 618c1acc4f - aggiunti fonts
- modificata navbar
- aggiunto un template
2025-09-09 13:22:55 +02:00

52 lines
1.4 KiB
C#

using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Routing;
namespace Test.UI.Components.Layout
{
public partial class NavMenu
{
[Parameter]
public EventCallback<bool> EC_compressUpdated { get; set; }
public void Dispose()
{
NavigationManager.LocationChanged -= OnLocationChanged;
}
protected string hideText { get => showText ? "" : "invisible"; }
protected string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;
protected string? TextCss => onlyIcon ? "d-none" : "";
protected override void OnInitialized()
{
currentUrl = NavigationManager.ToBaseRelativePath(NavigationManager.Uri);
NavigationManager.LocationChanged += OnLocationChanged;
}
protected void ToggleCompress()
{
showText = !showText;
EC_compressUpdated.InvokeAsync(showText);
}
protected void ToggleNavMenu()
{
collapseNavMenu = !collapseNavMenu;
}
private bool collapseNavMenu = false;
private string? currentUrl;
private bool onlyIcon = false;
private bool showText { get; set; } = true;
private void OnLocationChanged(object? sender, LocationChangedEventArgs e)
{
currentUrl = NavigationManager.ToBaseRelativePath(e.Location);
StateHasChanged();
}
}
}