using Connected.Utilities;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using static Connected.Colors;
using System;

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.Large
	/// </summary>
	[Parameter]
	public Size Size { get; set; } = Size.Large;

	/// <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>
	/// Glyph (Icon) inside the button.
	/// Options: SVG string --> Icons
	/// Default: string.Empty
	/// </summary>
	[Parameter]
	public string Glyph { get; set; } = string.Empty;

	/// <summary>
	/// Position of the glyph relative to button Text parameter. If Glyph parameter == string.Empty this parameter is ignored
	/// Options: Position.[left,top,right,bottom]
	/// Default: Position.left 
	/// </summary>
	[Parameter]
	public Position GlyphPosition { get; set; } = Position.Left;

	/// <summary>
	/// HEX string of the color for the glyph. If Glyph parameter is empty this parameter is ignored
	/// Options: any HEX color string
	/// Default: Black (#000000)
	/// </summary>
	[Parameter]
	public string GlyphColor { get; set; } = "#000000";

	/// <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 user defined string with valid CSS style
	/// Default: string.Empty
	/// </summary>
	[Parameter]
	public string Style { get; set; } = string.Empty;

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

	#endregion

	#region Events
	protected async Task Click(MouseEventArgs e)
	{
		await OnClick.InvokeAsync(e);

	}
	#endregion

	#region Styling

	/// <summary>
	/// Generated class list for button based on user parameters
	/// </summary>
	private 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>
	private string ContentClassList
	{
		get
		{
			return new CssBuilder("")
				.AddClass(ContentClass)
				.Build();
		}
	}

	#endregion


}
