@using JSMR.UI.Blazor.Enums

<div class="@GetIconClasses()" style="@GetStyle()"></div>

@code {
    [Parameter]
    public Graphic Graphic { get; set; }

    [Parameter]
    public SizeVarient Size { get; set; } = SizeVarient.Small;

    [Parameter]
    public IconVarient Varient { get; set; } = IconVarient.None;

    [Parameter]
    public ColorVarient Color { get; set; }

    [Parameter]
    public bool UseCurrentColor { get; set; }

    private string GetIconClasses()
    {
        string graphic = Varient == IconVarient.None
            ? Graphic.ToString().ToLower()
            : $"{Graphic.ToString().ToLower()}-{Varient.ToString().ToLower()}";

        List<string> classNames =
        [
            $"j-icon",
            $"j-icon-{graphic}",
            $"size-{Size.ToString().ToLower()}",
            //$"background-color-{Color.ToString().ToLower()}"
        ];

        if (!UseCurrentColor)
        {
            classNames.Add($"background-color-{Color.ToString().ToLower()}");
        }

        return string.Join(" ", classNames);
    }

    private string? GetStyle()
    {
        return UseCurrentColor ? "background-color: currentColor;" : null;
    }
}