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

namespace Connected.Components;
public partial class Button
{
	#region Parameters

	/// <summary>
	/// Outline type of the button.
	/// Options: true, false
	/// Default: false
	/// </summary>
	[Parameter]
	public bool Outlined { get; set; } = false;

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

	/// <summary>
	/// Size of the button.
	/// Options: Size.[Small,Medium,Large,FullWidth]
	/// Default: Size.Medium
	/// </summary>
	[Parameter]
	public Size Size { get; set; } = Size.Medium;

	/// <summary>
	/// Text shown inside the button
	/// Options: any string variable
	/// Default: string.Empty
	/// </summary>
	[Parameter]
	public RenderFragment? ChildContent { get; set; }

	/// <summary>
	/// Disabled or enabled.
	/// Default: false
	/// </summary>
	[Parameter]
	public bool Disabled { get; set; } = false;


	/// <summary>
	/// User defined custom class added on top of default generated classes
	/// Options: any user defined string with class names divided by space
	/// Default: string.Empty
	/// </summary>
	[Parameter]
	public string Class { get; set; } = string.Empty;

	/// <summary>
	/// User defined custom class added on top of default generated classes
	/// Options: any user defined string with class names divided by space
	/// Default: string.Empty
	/// </summary>
	[Parameter]
	public string ContentClass { get; set; } = string.Empty;

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

	#endregion

	#region Events

	/// <summary>
	/// Button click event.
	/// Options: any MouseEventCallback event
	/// Default: empty
	[Parameter]
	public EventCallback<MouseEventArgs> OnClick { get; set; }

	protected async Task Click(MouseEventArgs e)
	{
		await OnClick.InvokeAsync(e);
	}
	#endregion

	#region Styling

	public string StyleList
	{
		get
		{
			return new StyleBuilder()
				.AddStyle(Style)
				.Build();
		}
	}


	/// <summary>
	/// Generated class list for button based on user parameters
	/// </summary>
	public string ClassList
	{
		get
		{
			return new CssBuilder("btn")
				.AddClass("btn-" + Helper.GetEnumDescription<Size>(Size))
				.AddClass("btn-" + Helper.GetEnumDescription<Color>(Color),!Outlined)
				.AddClass("btn-outline-" + Helper.GetEnumDescription<Color>(Color), Outlined)
				.AddClass(Class)
				.Build();
		}
	}

	/// <summary>
	/// Generated class list for button based on user parameters
	/// </summary>
	public string ContentClassList
	{
		get
		{
			return new CssBuilder("")
				.AddClass(ContentClass)
				.Build();
		}
	}

	#endregion

}
