ant-design-blazor/components/switch/Switch.razor

54 lines
1.3 KiB
C#

@namespace AntDesign
@inherits AntInputComponentBase<bool>
<button type="button" role="switch"
aria-checked="@(CurrentValue?"true":"false")"
disabled="@(Disabled||Loading)"
class="@ClassMapper.Class"
style="@Style"
ant-click-animating="@(_clickAnimating?"true":"false")"
@onmouseover="HandleMouseOver"
@onmouseout="HandleMouseOut"
@onclick="HandleClick">
<div class="@($"{_prefixCls}-handle")">
@if (Loading)
{
<Icon Type="loading" Class="@($"{_prefixCls}-loading-icon")" />
}
</div>
<span class="@($"{_prefixCls}-inner")">
@if (CurrentValue)
{
if (CheckedChildren.IsT0)
{
@(CheckedChildren.AsT0)
}
else
{
@(CheckedChildren.AsT1)
}
}
else
{
if (UnCheckedChildren.IsT0)
{
@(UnCheckedChildren.AsT0)
}
else
{
@(UnCheckedChildren.AsT1)
}
}
</span>
<!--animation-->
@if (CurrentValue)
{
<div class="ant-click-animating-node"></div>
}
else
{
<div class="ant-click-animating-node"></div>
}
</button>