using Connected.Utilities;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;

namespace Connected.Components;

public partial class Glyph
{
	/// <summary>
	/// SVG markup string for glyph
	/// Options: any valid SVG markup string
	/// Default: string.Empty
	/// </summary>
	[Parameter]
	public string SVG { get; set; } = string.Empty;

	/// <summary>
	/// Color of the glyph
	/// Options: Color.[Core,Primary,Secondary,Success,Info,Warning,Danger,White,Light,Dark]
	/// Default: Color.Dark
	/// </summary>
	[Parameter]
	public Color Color { get; set; } = Color.Dark;

	/// <summary>
	/// Width of the glyph in px
	/// Options: Any positive integer number
	/// Default: 24
	/// </summary>
	[Parameter]
	public int Width { get; set; } = 24;

	/// <summary>
	/// Height of the glyph in px
	/// Options: Any positive integer number
	/// Default: 24
	/// </summary>
	[Parameter]
	public int Height { get; set; } = 24;

	/// <summary>
	/// Class name or multiple classes separated by space
	/// Options: Any valid class name or names separated by space
	/// Default: string.Empty
	/// </summary>
	[Parameter]
	public string Class { get; set; } = string.Empty;

	private string GlyphClassList
	{
		get
		{
			return new CssBuilder()
				.AddClass("color-"+Helper.GetEnumDescription<Color>(Color))
				 .AddClass(Class)
				 .Build();
		}
	}

	/// <summary>
	/// User defined style for the glyph
	/// Options: Any valid CSS style
	/// Default: string.Empty
	/// </summary>
	[Parameter]
	public string Style { get; set; } = string.Empty;

	private string GlyphStyleList
	{
		get
		{
			return new StyleBuilder()
				.AddStyle("width: "+Width.ToString()+"px; height:"+Height.ToString()+"px; overflow: hidden")
				 .AddStyle(Style)
				 .Build();
		}
	}

	[Parameter]
	/// <summary>
	/// Glyph click event.
	/// </summary>
	public EventCallback<MouseEventArgs> Click { get; set; }
	protected async Task OnClick(MouseEventArgs e)
	{
		await Click.InvokeAsync(e);
	}
}