Razor UI component for rendering an icon. It defines a Panel-derived component that outputs a root element with CSS classes based on the icon size and an optional extra class, and it shows the Name string as content.
@namespace Sunless.Libraries.UI
@using Sandbox
@using Sandbox.UI
@attribute [StyleSheet]
@inherits Panel
<root class="icon @SizeClass @ExtraClass">@Name</root>
@code
{
public string Name { get; set; } = "";
public IconSize Size { get; set; } = IconSize.Medium;
public string ExtraClass { get; set; }
string SizeClass => Size switch
{
IconSize.Small => "icon-sm",
IconSize.Large => "icon-lg",
IconSize.XLarge => "icon-xl",
_ => "icon-md",
};
protected override int BuildHash() => HashCode.Combine( Name, Size, ExtraClass );
}