File tree 3 files changed +10
-25
lines changed
_javascript/modules/components
3 files changed +10
-25
lines changed Original file line number Diff line number Diff line change 2
2
* Expand or close the sidebar in mobile screens.
3
3
*/
4
4
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' ) ;
6
8
7
9
class SidebarUtil {
8
- static isExpanded = false ;
10
+ static # isExpanded = false ;
9
11
10
12
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) ;
18
17
}
19
18
}
20
19
21
20
export 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 ( ) ;
27
22
}
Original file line number Diff line number Diff line change 68
68
</ aside >
69
69
</ div >
70
70
71
- < div id ="mask "> </ div >
71
+ < div id ="mask " class =" d-none position-fixed w-100 h-100 z-1 " > </ div >
72
72
73
73
{% if site.pwa.enabled %}
74
74
{% include_cached notification.html lang=lang %}
Original file line number Diff line number Diff line change @@ -688,7 +688,6 @@ $btn-mb: 0.5rem;
688
688
height : 100% ;
689
689
overflow-y : auto ;
690
690
width : $sidebar-width ;
691
- z-index : 99 ;
692
691
background : var (--sidebar-bg );
693
692
border-right : 1px solid var (--sidebar-border-color );
694
693
@@ -1091,16 +1090,7 @@ search {
1091
1090
}
1092
1091
1093
1092
#mask {
1094
- display : none ;
1095
- position : fixed ;
1096
1093
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
- }
1104
1094
}
1105
1095
1106
1096
/* --- basic wrappers --- */
You can’t perform that action at this time.
0 commit comments