File tree Expand file tree Collapse file tree 3 files changed +10
-25
lines changed
_javascript/modules/components Expand file tree Collapse file tree 3 files changed +10
-25
lines changed Original file line number Diff line number Diff line change 22 * Expand or close the sidebar in mobile screens.
33 */
44
5- const ATTR_DISPLAY = 'sidebar-display' ;
5+ const $sidebar = document . getElementById ( 'sidebar' ) ;
6+ const $trigger = document . getElementById ( 'sidebar-trigger' ) ;
7+ const $mask = document . getElementById ( 'mask' ) ;
68
79class SidebarUtil {
8- static isExpanded = false ;
10+ static # isExpanded = false ;
911
1012 static toggle ( ) {
11- if ( SidebarUtil . isExpanded === false ) {
12- document . body . setAttribute ( ATTR_DISPLAY , '' ) ;
13- } else {
14- document . body . removeAttribute ( ATTR_DISPLAY ) ;
15- }
16-
17- SidebarUtil . isExpanded = ! SidebarUtil . isExpanded ;
13+ this . #isExpanded = ! this . #isExpanded;
14+ document . body . toggleAttribute ( 'sidebar-display' , this . #isExpanded) ;
15+ $sidebar . classList . toggle ( 'z-2' , this . #isExpanded) ;
16+ $mask . classList . toggle ( 'd-none' , ! this . #isExpanded) ;
1817 }
1918}
2019
2120export function sidebarExpand ( ) {
22- document
23- . getElementById ( 'sidebar-trigger' )
24- . addEventListener ( 'click' , SidebarUtil . toggle ) ;
25-
26- document . getElementById ( 'mask' ) . addEventListener ( 'click' , SidebarUtil . toggle ) ;
21+ $trigger . onclick = $mask . onclick = ( ) => SidebarUtil . toggle ( ) ;
2722}
Original file line number Diff line number Diff line change 6868 </ aside >
6969 </ div >
7070
71- < div id ="mask "> </ div >
71+ < div id ="mask " class =" d-none position-fixed w-100 h-100 z-1 " > </ div >
7272
7373 {% if site.pwa.enabled %}
7474 {% include_cached notification.html lang=lang %}
Original file line number Diff line number Diff line change @@ -688,7 +688,6 @@ $btn-mb: 0.5rem;
688688 height : 100% ;
689689 overflow-y : auto ;
690690 width : $sidebar-width ;
691- z-index : 99 ;
692691 background : var (--sidebar-bg );
693692 border-right : 1px solid var (--sidebar-border-color );
694693
@@ -1091,16 +1090,7 @@ search {
10911090}
10921091
10931092#mask {
1094- display : none ;
1095- position : fixed ;
10961093 inset : 0 0 0 0 ;
1097- height : 100% ;
1098- width : 100% ;
1099- z-index : 1 ;
1100-
1101- @at-root [#{$sidebar-display } ] & {
1102- display : block !important ;
1103- }
11041094}
11051095
11061096/* --- basic wrappers --- */
You can’t perform that action at this time.
0 commit comments