using Connected.Annotations;
using Connected.Extensions;
using Connected.Utilities;
using Microsoft.AspNetCore.Components;
namespace Connected.Components;
partial class Avatar : UIComponent, IDisposable
{
[CascadingParameter] protected AvatarGroup AvatarGroup { get; set; }
protected string Classname =>
new CssBuilder("mud-avatar")
.AddClass($"mud-avatar-{Size.ToDescriptionString()}")
.AddClass($"mud-avatar-rounded", Rounded)
.AddClass($"mud-avatar-square", Square)
.AddClass($"mud-avatar-{Variant.ToDescriptionString()}")
.AddClass($"mud-avatar-{Variant.ToDescriptionString()}-{Color.ToDescriptionString()}")
.AddClass($"mud-elevation-{Elevation.ToString()}")
.AddClass(AvatarGroup?.GetAvatarSpacing() ?? new CssBuilder(), AvatarGroup != null)
.AddClass(Class)
.Build();
protected string Stylesname =>
new StyleBuilder()
.AddStyle(AvatarGroup?.GetAvatarZindex(this) ?? new StyleBuilder(), AvatarGroup != null)
.AddStyle(Style)
.Build();
///
/// The higher the number, the heavier the drop-shadow.
///
[Parameter]
[Category(CategoryTypes.Avatar.Appearance)]
public int Elevation { set; get; } = 0;
///
/// If true, border-radius is set to 0.
///
[Parameter]
[Category(CategoryTypes.Avatar.Appearance)]
public bool Square { get; set; }
///
/// If true, border-radius is set to the themes default value.
///
[Parameter]
[Category(CategoryTypes.Avatar.Appearance)]
public bool Rounded { get; set; }
///
/// Link to image, if set a image will be displayed instead of text.
///
[Parameter]
[Category(CategoryTypes.Avatar.Behavior)]
public string Image { get; set; }
///
/// If set (and Image is also set), will add an alt property to the img element
///
[Parameter]
[Category(CategoryTypes.Avatar.Behavior)]
public string Alt { get; set; }
///
/// The color of the component. It supports the theme colors.
///
[Parameter]
[Category(CategoryTypes.Avatar.Appearance)]
public ThemeColor Color { get; set; } = ThemeColor.Default;
///
/// The Size of the MudAvatar.
///
[Parameter]
[Category(CategoryTypes.Avatar.Appearance)]
public Size Size { get; set; } = Size.Medium;
///
/// The variant to use.
///
[Parameter]
[Category(CategoryTypes.Avatar.Appearance)]
public Variant Variant { get; set; } = Variant.Filled;
///
/// Child content of the component.
///
[Parameter]
[Category(CategoryTypes.Avatar.Behavior)]
public RenderFragment ChildContent { get; set; }
protected override void OnInitialized()
{
base.OnInitialized();
AvatarGroup?.AddAvatar(this);
}
public void Dispose()
{
AvatarGroup?.RemoveAvatar(this);
}
internal void ForceRedraw()
{
StateHasChanged();
}
}