42 lines
1.4 KiB
Plaintext
42 lines
1.4 KiB
Plaintext
@namespace Enciphered.Blazor.UIComponents
|
|
|
|
<button type="@Type"
|
|
disabled="@Disabled"
|
|
class="@ComputedClass"
|
|
@attributes="AdditionalAttributes">
|
|
@if (Icon is not null)
|
|
{
|
|
<span class="shrink-0">@Icon</span>
|
|
}
|
|
@ChildContent
|
|
</button>
|
|
|
|
@code {
|
|
[Parameter] public RenderFragment? ChildContent { get; set; }
|
|
[Parameter] public RenderFragment? Icon { get; set; }
|
|
[Parameter] public string Type { get; set; } = "button";
|
|
[Parameter] public bool Disabled { get; set; }
|
|
|
|
[Parameter] public string Variant { get; set; } = ButtonVariant.Default;
|
|
[Parameter] public string Size { get; set; } = ButtonSize.Default;
|
|
|
|
[Parameter] public string? Class { get; set; }
|
|
|
|
[Parameter(CaptureUnmatchedValues = true)]
|
|
public Dictionary<string, object>? AdditionalAttributes { get; set; }
|
|
|
|
private const string BaseClass =
|
|
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium " +
|
|
"transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring " +
|
|
"disabled:pointer-events-none disabled:opacity-50 cursor-pointer";
|
|
|
|
private string ComputedClass
|
|
{
|
|
get
|
|
{
|
|
var combined = $"{BaseClass} {Variant} {Size}";
|
|
return string.IsNullOrEmpty(Class) ? combined : $"{combined} {Class}";
|
|
}
|
|
}
|
|
}
|