allow menu component to be extensible

This commit is contained in:
sbwalker
2025-12-19 15:35:35 -05:00
parent 8120db84f4
commit 96bea78424
2 changed files with 26 additions and 12 deletions

View File

@@ -1,20 +1,33 @@
@namespace Oqtane.Themes.Controls @namespace Oqtane.Themes.Controls
@switch (Orientation) @if (ComponentType != null)
{ {
case "Horizontal": <DynamicComponent Type="@ComponentType"></DynamicComponent>
<MenuHorizontal/>
break;
default: // Vertical
{
<MenuVertical/>
break;
}
} }
@code{ @code{
[Parameter] [Parameter]
public string Orientation { get; set; } public string Orientation { get; set; }
[Parameter]
public string MenuType { get; set; }
public Type ComponentType { get; set; }
protected override void OnInitialized()
{
if (string.IsNullOrEmpty(MenuType) && !string.IsNullOrEmpty(Orientation))
{
if (Orientation == "Horizontal")
{
MenuType = "Oqtane.Themes.Controls.MenuHorizontal, Oqtane.Client";
}
else
{
MenuType = "Oqtane.Themes.Controls.MenuVertical, Oqtane.Client";
}
}
ComponentType = Type.GetType(MenuType);
}
} }

View File

@@ -4,7 +4,8 @@
<main role="main"> <main role="main">
<nav class="navbar navbar-dark bg-primary fixed-top"> <nav class="navbar navbar-dark bg-primary fixed-top">
<Logo UseSiteNameAsFallback="true" /><Menu Orientation="Horizontal" /> <Logo UseSiteNameAsFallback="true" />
<Menu MenuType="Oqtane.Themes.Controls.MenuHorizontal, Oqtane.Client" />
<div class="controls ms-auto"> <div class="controls ms-auto">
<div class="controls-group"> <div class="controls-group">
<Search CssClass="me-3 text-center bg-primary" /> <Search CssClass="me-3 text-center bg-primary" />