web/_javascript/modules/components/sidebar.js

23 lines
627 B
JavaScript
Raw Permalink Normal View History

/**
* 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');
class SidebarUtil {
2024-10-22 05:42:07 +03:00
static #isExpanded = false;
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);
}
}
export function sidebarExpand() {
2024-10-22 05:42:07 +03:00
$trigger.onclick = $mask.onclick = () => SidebarUtil.toggle();
}