using Connected.Annotations; using Microsoft.AspNetCore.Components; namespace Connected.Components; public partial class ToggleIconButton : UIComponent { /// /// The toggled value. /// [Parameter] [Category(CategoryTypes.Button.Behavior)] public bool Toggled { get; set; } /// /// Fires whenever toggled is changed. /// [Parameter] public EventCallback ToggledChanged { get; set; } /// /// The Icon that will be used in the untoggled state. /// [Parameter] [Category(CategoryTypes.Button.Behavior)] public string Icon { get; set; } /// /// The Icon that will be used in the toggled state. /// [Parameter] [Category(CategoryTypes.Button.Behavior)] public string ToggledIcon { get; set; } /// /// Title of the icon used for accessibility. /// [Parameter] [Category(CategoryTypes.Button.Behavior)] public string Title { get; set; } /// /// Title used in toggled state, if different. /// [Parameter] [Category(CategoryTypes.Button.Behavior)] public string ToggledTitle { get; set; } /// /// The color of the icon in the untoggled state. It supports the theme colors. /// [Parameter] [Category(CategoryTypes.Button.Appearance)] public ThemeColor Color { get; set; } = ThemeColor.Default; /// /// The color of the icon in the toggled state. It supports the theme colors. /// [Parameter] [Category(CategoryTypes.Button.Appearance)] public ThemeColor ToggledColor { get; set; } = ThemeColor.Default; /// /// The Size of the component in the untoggled state. /// [Parameter] [Category(CategoryTypes.Button.Appearance)] public Size Size { get; set; } = Size.Medium; /// /// The Size of the component in the toggled state. /// [Parameter] [Category(CategoryTypes.Button.Appearance)] public Size ToggledSize { get; set; } = Size.Medium; /// /// If set uses a negative margin. /// [Parameter] [Category(CategoryTypes.Button.Appearance)] public Edge Edge { get; set; } /// /// If true, disables ripple effect. /// [Parameter] [Category(CategoryTypes.Button.Appearance)] public bool DisableRipple { get; set; } /// /// If true, the button will be disabled. /// [Parameter] [Category(CategoryTypes.Button.Behavior)] public bool Disabled { get; set; } /// /// The variant to use. /// [Parameter] [Category(CategoryTypes.Button.Appearance)] public Variant Variant { get; set; } = Variant.Text; public Task Toggle() { return SetToggledAsync(!Toggled); } protected internal async Task SetToggledAsync(bool toggled) { if (Disabled) return; if (Toggled != toggled) { Toggled = toggled; await ToggledChanged.InvokeAsync(Toggled); } } }