@namespace Lumeo

<a href="@Href" class="@CssClass" @onclick="HandleClick" @attributes="AdditionalAttributes">
    @ChildContent
</a>

@code {
    [CascadingParameter] public NavigationMenu.NavigationMenuContext Context { get; set; } = default!;
    [Parameter] public string? Href { get; set; }
    [Parameter] public RenderFragment? ChildContent { get; set; }
    [Parameter] public string? Class { get; set; }
    [Parameter(CaptureUnmatchedValues = true)] public Dictionary<string, object>? AdditionalAttributes { get; set; }

    private string CssClass => $"block select-none space-y-1 rounded-md p-3 leading-none no-underline outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground {Class}".Trim();

    private async Task HandleClick()
    {
        await Context.SetActiveItemId.InvokeAsync(null);
    }
}
