@namespace Lumeo

<li @attributes="AdditionalAttributes">
    <a href="@Href" class="@CssClass" aria-disabled="@(Disabled ? "true" : null)">
        @if (Icon is not null)
        {
            <Blazicon Svg="@Icon" class="h-5 w-5 mt-0.5 text-muted-foreground shrink-0" />
        }
        <div>
            <div class="text-sm font-medium text-foreground">@Title</div>
            @if (Description is not null)
            {
                <p class="text-xs text-muted-foreground mt-0.5">@Description</p>
            }
        </div>
    </a>
</li>

@code {
    [Parameter] public string Href { get; set; } = "#";
    [Parameter] public string Title { get; set; } = string.Empty;
    [Parameter] public string? Description { get; set; }
    [Parameter] public SvgIcon? Icon { get; set; }
    [Parameter] public bool Disabled { get; set; }
    [Parameter] public string? Class { get; set; }
    [Parameter(CaptureUnmatchedValues = true)] public Dictionary<string, object>? AdditionalAttributes { get; set; }

    private string CssClass => string.Join(" ", new[] { "flex items-start gap-3 rounded-md p-2 hover:bg-accent transition-colors focus-visible:outline-none focus-visible:ring-[1.5px] focus-visible:ring-ring focus-visible:ring-offset-1", Disabled ? "pointer-events-none opacity-50" : null, Class }.Where(s => !string.IsNullOrWhiteSpace(s)));
}
