-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2126ddc
commit 8dfcdd0
Showing
7 changed files
with
90 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Microsoft.AspNetCore.Components; | ||
|
||
namespace WaxComponents; | ||
|
||
public partial class WaxTab | ||
{ | ||
[Parameter] | ||
public RenderFragment? ChildContent { get; set; } | ||
|
||
[Parameter] | ||
public string Style { get; set; } = String.Empty; | ||
|
||
private List<WaxTabItem> _tabs = new(); | ||
|
||
private WaxTabItem? _activeTab; | ||
|
||
public void RegisterTab(WaxTabItem tab) | ||
{ | ||
_tabs.Add(tab); | ||
|
||
tab.SetAsLast(); | ||
if (_tabs.Count == 1) | ||
{ | ||
tab.SetAsFirst(); | ||
SetTab(tab); | ||
} | ||
else | ||
_tabs[^2].SetAsLast(true); | ||
} | ||
|
||
public void SetTab(WaxTabItem tab) | ||
{ | ||
_activeTab?.ChangeActive(false); | ||
tab.ChangeActive(true); | ||
|
||
_activeTab = tab; | ||
StateHasChanged(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.waxTab { | ||
overflow: hidden; | ||
margin-top: 10px; | ||
margin-left: 4px; | ||
} | ||
|
||
.waxTabContent { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,4 @@ | ||
<button class="waxTabItem" style="background-color: @_bgColor;@Style" onclick="@OnTabClicked"> | ||
<button class="waxTabItem" style="border-top-right-radius:@_borderTopRight;border-top-left-radius:@_borderTopLeft;background-color: @_bgColor;@Style" onclick="@OnTabClicked"> | ||
<WaxIcon>@Icon</WaxIcon> | ||
<p class="waxTabItemText" style="font-size:@FontSize;@Style">@Text</p> | ||
</button> | ||
|
||
@code { | ||
|
||
[Parameter] | ||
public RenderFragment? Text { get; set; } | ||
|
||
[Parameter] | ||
public RenderFragment? Icon { get; set; } | ||
|
||
[Parameter] | ||
public RenderFragment? Content { get; set; } | ||
|
||
[CascadingParameter] | ||
public WaxTab? Parent { get; set; } | ||
|
||
[Parameter] | ||
public string FontSize { get; set; } = "12px"; | ||
|
||
[Parameter] | ||
public string Style { get; set; } = String.Empty; | ||
|
||
private string _bgColor = "white"; | ||
|
||
private void OnTabClicked() | ||
{ | ||
if (Parent is not null) Parent.SetTab(this); | ||
} | ||
|
||
protected override void OnInitialized() | ||
{ | ||
if (Parent is not null) Parent.SetTab(this, true); | ||
|
||
base.OnInitialized(); | ||
} | ||
|
||
public void ChangeActive(bool active) | ||
{ | ||
_bgColor = active ? "rgba(255, 20, 147, 0.2) !important" : "white"; | ||
} | ||
|
||
} | ||
</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using Microsoft.AspNetCore.Components; | ||
|
||
namespace WaxComponents; | ||
|
||
public partial class WaxTabItem | ||
{ | ||
[Parameter] | ||
public RenderFragment? Text { get; set; } | ||
|
||
[Parameter] | ||
public RenderFragment? Icon { get; set; } | ||
|
||
[Parameter] | ||
public RenderFragment? Content { get; set; } | ||
|
||
[CascadingParameter] | ||
public WaxTab? Parent { get; set; } | ||
|
||
[Parameter] | ||
public string FontSize { get; set; } = "12px"; | ||
|
||
[Parameter] | ||
public string Style { get; set; } = String.Empty; | ||
|
||
private string _bgColor = "white"; | ||
private string _borderTopRight = "0"; | ||
private string _borderTopLeft = "0"; | ||
|
||
protected override void OnInitialized() | ||
{ | ||
if (Parent is not null) Parent.RegisterTab(this); | ||
|
||
base.OnInitialized(); | ||
} | ||
|
||
public void ChangeActive(bool active) => _bgColor = active ? "rgba(255, 20, 147, 0.2) !important" : "white"; | ||
|
||
public void SetAsFirst(bool remove = false) => _borderTopLeft = remove ? "0" : "5px"; | ||
public void SetAsLast(bool remove = false) => _borderTopRight = remove ? "0" : "5px"; | ||
|
||
private void OnTabClicked() | ||
{ | ||
if (Parent is not null) Parent.SetTab(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters