summaryrefslogtreecommitdiff
path: root/Pages/Component/TabContainer.razor
diff options
context:
space:
mode:
authorJake Mannens <jake@asger.xyz>2023-08-15 15:49:14 +1000
committerJake Mannens <jake@asger.xyz>2025-08-18 10:59:32 +1000
commit38c60cee378b9c2ad42fc9dc79bc492b919a68f5 (patch)
tree6b62f84aab4b7866432e5da8ae8fcb889795d58b /Pages/Component/TabContainer.razor
parent07a4c7ead01514bd3f304f00abc38140a1d73634 (diff)
Convert Razor pages to Blazor
Diffstat (limited to 'Pages/Component/TabContainer.razor')
-rw-r--r--Pages/Component/TabContainer.razor35
1 files changed, 35 insertions, 0 deletions
diff --git a/Pages/Component/TabContainer.razor b/Pages/Component/TabContainer.razor
new file mode 100644
index 0000000..3caab0b
--- /dev/null
+++ b/Pages/Component/TabContainer.razor
@@ -0,0 +1,35 @@
+<link rel="stylesheet" href="@(nameof(HyperBooru)).styles.css"/>
+
+<div class="tabs">
+ @foreach(var pane in Panes) {
+ <a href="javascript:;" @onclick=@(() => ActivePane = pane) class="@(pane == ActivePane ? "selected" : "")">
+ @pane.Title
+ </a>
+ }
+</div>
+
+<CascadingValue Value="this">
+ @ChildContent
+</CascadingValue>
+
+@code {
+ [Parameter]
+ public RenderFragment ChildContent { get; set; }
+
+ public TabPane? ActivePane { get; set; }
+ List<TabPane> Panes = new();
+
+ public void AddPane(TabPane tabPane) {
+ Panes.Add(tabPane);
+ if(Panes.Count == 1)
+ ActivePane = tabPane;
+ StateHasChanged();
+ }
+
+ public void RemovePane(TabPane tabPane) {
+ if(ActivePane == tabPane)
+ ActivePane = Panes.ElementAtOrDefault(0);
+ Panes.Remove(tabPane);
+ StateHasChanged();
+ }
+} \ No newline at end of file