mirror of
https://github.com/aliasvault/aliasvault.git
synced 2026-03-20 07:39:07 -04:00
61 lines
1.6 KiB
Plaintext
61 lines
1.6 KiB
Plaintext
<button @onclick="HandleClick"
|
|
disabled="@IsDisabled"
|
|
class="@GetButtonClasses()">
|
|
@ChildContent
|
|
</button>
|
|
|
|
@code {
|
|
/// <summary>
|
|
/// The content to be displayed inside the button.
|
|
/// </summary>
|
|
[Parameter]
|
|
public RenderFragment? ChildContent { get; set; }
|
|
|
|
/// <summary>
|
|
/// The event to call when the button is clicked.
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback OnClick { get; set; }
|
|
|
|
/// <summary>
|
|
/// Specifies whether the button is disabled.
|
|
/// </summary>
|
|
[Parameter]
|
|
public bool IsDisabled { get; set; }
|
|
|
|
/// <summary>
|
|
/// The color theme of the button.
|
|
/// </summary>
|
|
[Parameter]
|
|
public string Color { get; set; } = "primary";
|
|
|
|
/// <summary>
|
|
/// Additional CSS classes to apply to the button.
|
|
/// </summary>
|
|
[Parameter]
|
|
public string AdditionalClasses { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Handles the button click event.
|
|
/// </summary>
|
|
private async Task HandleClick()
|
|
{
|
|
if (!IsDisabled)
|
|
{
|
|
await OnClick.InvokeAsync();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets the CSS classes for the button based on its state and color.
|
|
/// </summary>
|
|
/// <returns>A string containing the CSS classes for the button.</returns>
|
|
private string GetButtonClasses()
|
|
{
|
|
var colorClasses = ButtonStyles.GetColorClasses(Color);
|
|
var disabledClasses = IsDisabled ? ButtonStyles.DisabledClasses : "";
|
|
|
|
return $"{ButtonStyles.BaseClasses} {colorClasses} {disabledClasses} {AdditionalClasses}".Trim();
|
|
}
|
|
}
|