39 lines
1.0 KiB
Plaintext
39 lines
1.0 KiB
Plaintext
@using System.Diagnostics.CodeAnalysis
|
|
@using Microsoft.AspNetCore.Components
|
|
|
|
@* TODO: Extract to mooncore? *@
|
|
|
|
@inherits InputBase<bool>
|
|
|
|
<div class="flex items-center">
|
|
<div class="form-switch">
|
|
<input @bind="CurrentValue" type="checkbox" id="@("switch-" + GetHashCode())" class="sr-only">
|
|
<label class="bg-gray-700" for="switch-@(GetHashCode())">
|
|
<span class="bg-white shadow-sm" aria-hidden="true"></span>
|
|
<span class="sr-only">Switch label</span>
|
|
</label>
|
|
</div>
|
|
<div class="text-sm text-gray-500 italic ml-2">
|
|
@if (CurrentValue)
|
|
{
|
|
<span>On</span>
|
|
}
|
|
else
|
|
{
|
|
<span>
|
|
Off
|
|
</span>
|
|
}
|
|
</div>
|
|
</div>
|
|
|
|
@code
|
|
{
|
|
protected override bool TryParseValueFromString(string? value, out bool result, [NotNullWhen(false)] out string? validationErrorMessage)
|
|
{
|
|
validationErrorMessage = null;
|
|
result = string.Equals(value, "true", StringComparison.OrdinalIgnoreCase);
|
|
return true;
|
|
}
|
|
}
|