2023-03-13 15:20:59 +03:00
|
|
|
/**
|
|
|
|
* Expand or close the sidebar in mobile screens.
|
|
|
|
*/
|
|
|
|
|
2024-10-22 05:42:07 +03:00
|
|
|
const $sidebar = document.getElementById('sidebar');
|
|
|
|
const $trigger = document.getElementById('sidebar-trigger');
|
|
|
|
const $mask = document.getElementById('mask');
|
2023-03-13 15:20:59 +03:00
|
|
|
|
|
|
|
class SidebarUtil {
|
2024-10-22 05:42:07 +03:00
|
|
|
static #isExpanded = false;
|
2023-03-13 15:20:59 +03:00
|
|
|
|
|
|
|
static toggle() {
|
2024-10-22 05:42:07 +03:00
|
|
|
this.#isExpanded = !this.#isExpanded;
|
|
|
|
document.body.toggleAttribute('sidebar-display', this.#isExpanded);
|
|
|
|
$sidebar.classList.toggle('z-2', this.#isExpanded);
|
|
|
|
$mask.classList.toggle('d-none', !this.#isExpanded);
|
2023-03-13 15:20:59 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function sidebarExpand() {
|
2024-10-22 05:42:07 +03:00
|
|
|
$trigger.onclick = $mask.onclick = () => SidebarUtil.toggle();
|
2023-03-13 15:20:59 +03:00
|
|
|
}
|