mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
38 lines
881 B
Plaintext
38 lines
881 B
Plaintext
<li class="nav-item">
|
|
<a class="nav-link @ActiveClass" data-toggle="tab" @onclick="SetActiveTab" style="cursor: pointer; user-select: none;">
|
|
@ChildContent
|
|
</a>
|
|
</li>
|
|
|
|
@code {
|
|
[CascadingParameter]
|
|
public TabControl Parent { get; set; }
|
|
|
|
[Parameter]
|
|
public RenderFragment ChildContent { get; set; }
|
|
|
|
[Parameter]
|
|
public Action OnActivated { get; set; }
|
|
|
|
[Parameter]
|
|
public string Name { get; set; }
|
|
|
|
private string ActiveClass => Parent.ActiveTab == Name ? "active" : "";
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
if (Parent is null)
|
|
{
|
|
throw new Exception("TabHeader must be contained in a TabControl.");
|
|
}
|
|
base.OnInitialized();
|
|
}
|
|
|
|
private void SetActiveTab()
|
|
{
|
|
Parent.SetActiveTab(this);
|
|
StateHasChanged();
|
|
OnActivated?.Invoke();
|
|
}
|
|
}
|