Skip to content

Commit

Permalink
feat(AutoPer): add CollapseBar function (#8)
Browse files Browse the repository at this point in the history
* refactor: 增加 CollapseBar 组件

* refactor: 增加侧边栏收起功能
  • Loading branch information
ArgoZhang authored Nov 23, 2024
1 parent 52407c1 commit 366431d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@inherits BootstrapModuleComponentBase
@attribute [JSModuleAutoLoader("./Components/Layout/CollapseBar.razor.js", AutoInvokeDispose = false)]
@rendermode InteractiveServer

<Tooltip Title="展开/收起菜单" Trigger="hover" Placement="Placement.Right">
<a id="@Id" class="layout-header-bar">
<i class="fa-solid fa-bars"></i>
</a>
</Tooltip>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import EventHandler from "../../_content/BootstrapBlazor/modules/event-handler.js"

export function init(id) {
const el = document.getElementById(id);
if (el === null) {
return;
}

EventHandler.on(el, 'click', e => {
e.preventDefault();

const layout = document.querySelector('.layout');
if (layout) {
layout.classList.toggle('is-collapsed');
}
});
}

export function dispose(id) {
const el = document.getElementById(id);
if (el === null) {
return;
}

EventHandler.off(el, 'click');
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
@inherits LayoutComponentBase

<Layout ShowGotoTop="true" ShowCollapseBar="true" ShowFooter="@ShowFooter" SideWidth="0"
<Layout ShowGotoTop="true" ShowCollapseBar="false" ShowFooter="@ShowFooter" SideWidth="0"
IsPage="true" IsFullSide="@IsFullSide" IsFixedHeader="@IsFixedHeader" IsFixedFooter="@IsFixedFooter"
TabDefaultUrl="/" UseTabSet="@UseTabSet" AdditionalAssemblies="new[] { GetType().Assembly, typeof(BootstrapBlazorApp.Client._Imports).Assembly }"
Menus="@Menus" class="@Theme">
TabDefaultUrl="/" UseTabSet="false" Menus="Menus"
AdditionalAssemblies="new[] { GetType().Assembly, typeof(BootstrapBlazorApp.Client._Imports).Assembly }"
class="@Theme">
<Header>
<CollapseBar></CollapseBar>
<span class="ms-3 flex-sm-fill d-none d-sm-block">Bootstrap of Blazor</span>
<div class="flex-fill d-sm-none">
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ namespace BootstrapBlazorApp.Components.Layout;

public partial class MainLayout
{
private bool UseTabSet { get; set; } = true;

private string Theme { get; set; } = "";

private bool IsFixedHeader { get; set; } = true;
Expand Down

0 comments on commit 366431d

Please sign in to comment.