-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(AutoPer): add CollapseBar function (#8)
* refactor: 增加 CollapseBar 组件 * refactor: 增加侧边栏收起功能
- Loading branch information
Showing
4 changed files
with
40 additions
and
5 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
src/Auto-Per/BootstrapBlazorApp/Components/Layout/CollapseBar.razor
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,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> |
26 changes: 26 additions & 0 deletions
26
src/Auto-Per/BootstrapBlazorApp/Components/Layout/CollapseBar.razor.js
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,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'); | ||
} |
8 changes: 5 additions & 3 deletions
8
src/Auto-Per/BootstrapBlazorApp/Components/Layout/MainLayout.razor
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