using Biskilog_Accounting.Client.Models; using Microsoft.AspNetCore.Components; using System.Linq; namespace Biskilog_Accounting.Client.Elements { public partial class MenuItem { [Parameter] public NavItem Item { get; set; } [Parameter] public double ActiveId { get; set; } [Parameter] public EventCallback ActiveChanged { get; set; } private string m_expand { get; set; } = string.Empty; protected override void OnParametersSet() { //Collapse expanded parents if none of its child is active if (!Item.Children.Any(i => i.Id == ActiveId)) { m_expand = string.Empty; } base.OnParametersSet(); } private void Toggle() { if (String.IsNullOrEmpty(m_expand)) { m_expand = "menu-item-animating open"; } else { m_expand = ""; } } private void ItemClick(double a_id) { ActiveId = a_id; ActiveChanged.InvokeAsync(a_id); } } }