initial commit
This commit is contained in:
27
_javascript/modules/components/sidebar.js
Normal file
27
_javascript/modules/components/sidebar.js
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Expand or close the sidebar in mobile screens.
|
||||
*/
|
||||
|
||||
const ATTR_DISPLAY = 'sidebar-display';
|
||||
|
||||
class SidebarUtil {
|
||||
static isExpanded = false;
|
||||
|
||||
static toggle() {
|
||||
if (SidebarUtil.isExpanded === false) {
|
||||
document.body.setAttribute(ATTR_DISPLAY, '');
|
||||
} else {
|
||||
document.body.removeAttribute(ATTR_DISPLAY);
|
||||
}
|
||||
|
||||
SidebarUtil.isExpanded = !SidebarUtil.isExpanded;
|
||||
}
|
||||
}
|
||||
|
||||
export function sidebarExpand() {
|
||||
document
|
||||
.getElementById('sidebar-trigger')
|
||||
.addEventListener('click', SidebarUtil.toggle);
|
||||
|
||||
document.getElementById('mask').addEventListener('click', SidebarUtil.toggle);
|
||||
}
|
||||
Reference in New Issue
Block a user