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/Icon/Icon.razor.cs

61 lines
1.8 KiB

2 years ago
using Connected.Annotations;
using Connected.Extensions;
using Connected.Utilities;
using Microsoft.AspNetCore.Components;
namespace Connected.Components;
public partial class Icon : UIComponent
{
protected string Classname =>
new CssBuilder("mud-icon-root")
.AddClass($"mud-icon-default", Color == ThemeColor.Default)
.AddClass($"mud-svg-icon", !string.IsNullOrEmpty(Glyph) && Glyph.Trim().StartsWith(("<")))
.AddClass($"mud-{Color.ToDescriptionString()}-text", Color != ThemeColor.Default && Color != ThemeColor.Inherit)
.AddClass($"mud-icon-size-{Size.ToDescriptionString()}")
.AddClass(Class)
.Build();
/// <summary>
/// Icon to be used can either be svg paths for font icons.
/// </summary>
[Parameter]
[Category(CategoryTypes.Icon.Behavior)]
public string Glyph { get; set; }
/// <summary>
/// Title of the icon used for accessibility.
/// </summary>
[Parameter]
[Category(CategoryTypes.Icon.Behavior)]
public string Title { get; set; }
/// <summary>
/// The Size of the icon.
/// </summary>
[Parameter]
[Category(CategoryTypes.Icon.Appearance)]
public Size Size { get; set; } = Size.Medium;
/// <summary>
/// The color of the component. It supports the theme colors.
/// </summary>
[Parameter]
[Category(CategoryTypes.Icon.Appearance)]
public ThemeColor Color { get; set; } = ThemeColor.Inherit;
/// <summary>
/// The viewbox size of an svg element.
/// </summary>
[Parameter]
[Category(CategoryTypes.Icon.Behavior)]
public string ViewBox { get; set; } = "0 0 24 24";
/// <summary>
/// Child content of component.
/// </summary>
[Parameter]
[Category(CategoryTypes.Icon.Behavior)]
public RenderFragment ChildContent { get; set; }
}