You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Connected.Components/Components/Button/Button.razor.cs

97 lines
2.6 KiB

2 years ago
using Connected.Annotations;
using Connected.Extensions;
using Connected.Utilities;
using Microsoft.AspNetCore.Components;
namespace Connected.Components;
public partial class Button : ButtonBase
{
protected string Classname =>
new CssBuilder("mud-button-root mud-button")
.AddClass($"mud-button-{Variant.ToDescriptionString()}")
.AddClass($"mud-button-{Variant.ToDescriptionString()}-{Color.ToDescriptionString()}")
.AddClass($"mud-button-{Variant.ToDescriptionString()}-size-{Size.ToDescriptionString()}")
.AddClass($"mud-width-full", FullWidth)
.AddClass($"mud-ripple", !DisableRipple)
.AddClass($"mud-button-disable-elevation", DisableElevation)
.AddClass(Class)
.Build();
protected string StartIconClass =>
new CssBuilder("mud-button-icon-start")
.AddClass($"mud-button-icon-size-{Size.ToDescriptionString()}")
.AddClass(IconClass)
.Build();
protected string EndIconClass =>
new CssBuilder("mud-button-icon-end")
.AddClass($"mud-button-icon-size-{Size.ToDescriptionString()}")
.AddClass(IconClass)
.Build();
/// <summary>
/// Icon placed before the text if set.
/// </summary>
[Parameter]
[Category(CategoryTypes.Button.Behavior)]
public string StartIcon { get; set; }
/// <summary>
/// Icon placed after the text if set.
/// </summary>
[Parameter]
[Category(CategoryTypes.Button.Behavior)]
public string EndIcon { get; set; }
/// <summary>
/// The color of the icon. It supports the theme colors.
/// </summary>
[Parameter]
[Category(CategoryTypes.Button.Appearance)]
public ThemeColor IconColor { get; set; } = ThemeColor.Inherit;
/// <summary>
/// Icon class names, separated by space
/// </summary>
[Parameter]
[Category(CategoryTypes.Button.Appearance)]
public string IconClass { get; set; }
/// <summary>
/// The color of the component. It supports the theme colors.
/// </summary>
[Parameter]
[Category(CategoryTypes.Button.Appearance)]
public ThemeColor Color { get; set; } = ThemeColor.Default;
/// <summary>
/// The Size of the component.
/// </summary>
[Parameter]
[Category(CategoryTypes.Button.Appearance)]
public Size Size { get; set; } = Size.Medium;
/// <summary>
/// The variant to use.
/// </summary>
[Parameter]
[Category(CategoryTypes.Button.Appearance)]
public Variant Variant { get; set; } = Variant.Text;
/// <summary>
/// If true, the button will take up 100% of available width.
/// </summary>
[Parameter]
[Category(CategoryTypes.Button.Appearance)]
public bool FullWidth { get; set; }
/// <summary>
/// Child content of component.
/// </summary>
[Parameter]
[Category(CategoryTypes.Button.Behavior)]
public RenderFragment ChildContent { get; set; }
}