wabbajack/Wabbajack.App.Blazor/Components/OptionCheckbox.razor

30 lines
734 B
Plaintext
Raw Normal View History

2022-01-20 08:34:38 +00:00
@namespace Wabbajack.App.Blazor.Components
<label class="option">
@Label
2022-01-28 11:58:28 +00:00
<input type="checkbox" value="@IsChecked" @onchange="CheckBoxChanged">
<span class="checkmark"></span>
</label>
@code {
// TODO: [Low] Implement parameters to customize style.
2022-01-28 11:58:28 +00:00
[Parameter]
2022-01-28 11:58:28 +00:00
public string? Label { get; set; }
[Parameter]
2022-01-28 11:58:28 +00:00
public bool IsChecked { get; set; }
[Parameter]
public EventCallback<bool> IsCheckedChanged { get; set; }
private async Task CheckBoxChanged(ChangeEventArgs e)
{
2022-01-28 11:58:28 +00:00
if (e.Value is not bool newValue) return;
if (IsChecked == newValue) return;
IsChecked = newValue;
await IsCheckedChanged.InvokeAsync(IsChecked);
}
}