diff --git a/src/Connected.Components/Components/Button/ButtonBase.cs b/src/Connected.Components/Components/Button/ButtonBase.cs index 368a942..92b75e9 100644 --- a/src/Connected.Components/Components/Button/ButtonBase.cs +++ b/src/Connected.Components/Components/Button/ButtonBase.cs @@ -1,57 +1,38 @@ using System.Windows.Input; -using Connected.Annotations; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; -using static System.String; namespace Connected.Components; public abstract class ButtonBase : UIComponent { + #region EventCallbacks /// /// Button click event. /// [Parameter] - public EventCallback OnClick { get; set; } + public EventCallback Clicked { get; set; } + #endregion + #region Content placeholders /// /// Potential activation target for this button. This enables RenderFragments with user-defined /// buttons which will automatically activate the intended functionality. /// [CascadingParameter] - protected IActivatable Activateable { get; set; } + protected IActivatable? Activateable { get; set; } + #endregion - /// - /// The HTML element that will be rendered in the root by the component - /// By default, is a button - /// - [Parameter] - public string HtmlTag { get; set; } = "button"; + #region Styling properties + #endregion + #region Behavior properties /// /// The button Type (Button, Submit, Refresh) /// [Parameter] public ButtonType ButtonType { get; set; } - /// - /// If true, the button will be disabled. - /// - [Parameter] - public bool Disabled { get; set; } - - /// - /// The higher the number, the heavier the drop-shadow. 0 for no shadow. - /// - [Parameter] - public int Elevation { set; get; } = 0; - - /// - /// If true, disables ripple effect. - /// - [Parameter] - public bool CanRipple { get; set; } - /// /// Command executed when the user clicks on an element. /// @@ -64,20 +45,30 @@ public abstract class ButtonBase : UIComponent [Parameter] public object? CommandParameters { get; set; } - protected async Task OnClickHandler(MouseEventArgs e) + /// + /// If true, the button will be disabled. + /// + [Parameter] + public bool Disabled { get; set; } + #endregion + + /// + /// The HTML element that will be rendered in the root by the component + /// By default, is a button + /// + protected string HtmlTag => ButtonType.ToString().ToLower(); + + protected async Task OnClick(MouseEventArgs e) { if (Disabled) return; - await OnClick.InvokeAsync(e); + if (Clicked.HasDelegate) + await Clicked.InvokeAsync(e); if (Command?.CanExecute(CommandParameters) ?? false) Command.Execute(CommandParameters); Activateable?.Activate(this, e); } - - protected ElementReference _elementReference; - - public ValueTask FocusAsync() => _elementReference.FocusAsync(); }