Skip to content

Commit

Permalink
Added logic to tab component to only show tabs if there's more than 1…
Browse files Browse the repository at this point in the history
… item in the tab list
  • Loading branch information
ProgrammerAL committed May 4, 2024
1 parent 69a2206 commit 0b548c8
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/SvgHelpers/SvgHelpers/Components/TabComponent.razor
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<CascadingValue Value="this">
<div class="btn-group" role="group">
@foreach (var tabPage in Pages)
{
<button type="button"
class="border p-2 @(tabPage == ActivePage ? ActivePageTabCss : InactivePageTabCss)"
@onclick=@(() => ActivatePage(tabPage))>
@tabPage.Title
</button>
}
</div>
@if (Pages.Count > 1)
{
<div class="btn-group" role="group">
@foreach (var tabPage in Pages)
{
<button type="button"
class="border p-2 @(tabPage == ActivePage ? ActivePageTabCss : InactivePageTabCss)"
@onclick=@(() => ActivatePage(tabPage))>
@tabPage.Title
</button>
}
</div>
}
<div class="border m-2 p-4">
@ChildContent
</div>
Expand All @@ -30,7 +33,7 @@
Pages.Add(tabPage);
if (Pages.Count == 1)
{
ActivePage = tabPage;
ActivatePage(tabPage);
}

StateHasChanged();
Expand Down

0 comments on commit 0b548c8

Please sign in to comment.