using Connected.Annotations;
using Connected.Extensions;
using Connected.Utilities;
using Microsoft.AspNetCore.Components;

namespace Connected.Components;

public partial class Icon : UIComponent
{
   protected string Classname =>
       new CssBuilder("icon-root")
           .AddClass($"icon-default", Color == ThemeColor.Default)
           .AddClass($"svg-icon", !string.IsNullOrEmpty(Glyph) && Glyph.Trim().StartsWith(("<")))
           .AddClass($"{Color.ToDescription()}-text", Color != ThemeColor.Default && Color != ThemeColor.Inherit)
           .AddClass($"icon-size-{Size.ToDescription()}")
           .AddClass(AdditionalClassList)
           .Build();

   /// <summary>
   /// Glyph to be used can either be svg paths for font icons.
   /// </summary>
   [Parameter]
   [Category(CategoryTypes.Icon.Behavior)]
   public string Glyph { get; set; }

   /// <summary>
   /// GlyphTitle of the icon used for accessibility.
   /// </summary>
   [Parameter]
   [Category(CategoryTypes.Icon.Behavior)]
   public string Title { get; set; }

   /// <summary>
   /// The Size of the icon.
   /// </summary>
   [Parameter]
   [Category(CategoryTypes.Icon.Appearance)]
   public Size Size { get; set; } = Size.Medium;

   /// <summary>
   /// The color of the component. It supports the theme colors.
   /// </summary>
   [Parameter]
   [Category(CategoryTypes.Icon.Appearance)]
   public ThemeColor Color { get; set; } = ThemeColor.Inherit;

   /// <summary>
   /// The viewbox size of an svg element.
   /// </summary>
   [Parameter]
   [Category(CategoryTypes.Icon.Behavior)]
   public string ViewBox { get; set; } = "0 0 24 24";

   /// <summary>
   /// Child content of component.
   /// </summary>
   [Parameter]
   [Category(CategoryTypes.Icon.Behavior)]
   public RenderFragment ChildContent { get; set; }
}
