File tree Expand file tree Collapse file tree 3 files changed +52
-2
lines changed Expand file tree Collapse file tree 3 files changed +52
-2
lines changed Original file line number Diff line number Diff line change @@ -526,8 +526,46 @@ nav {
526
526
column-gap : var (--grid-column-gutter );
527
527
}
528
528
529
- .sidebar-layout {
530
- display : none;
529
+ body : has (# sidebar-v2 [style *= "block" ]) {
530
+ overflow-y : hidden;
531
+ }
532
+
533
+ .main-layout {
534
+ display : flex;
535
+ flex-direction : column;
536
+ position : relative;
537
+
538
+ .sidebar-layout {
539
+ min-height : fit-content;
540
+ position : sticky;
541
+ top : 0 ;
542
+ padding : 1rem ;
543
+ background-color : white;
544
+ width : calc (100% + 4rem );
545
+ margin-left : -2rem ;
546
+ overflow-y : scroll;
547
+
548
+ & ::before {
549
+ display : none;
550
+ }
551
+
552
+ .sidebar-mobile-toggle {
553
+ background-color : oklch (var (--color-brand ));
554
+ color : white;
555
+ border : none;
556
+ display : block !important ;
557
+ }
558
+
559
+ nav {
560
+ width : 100% ;
561
+ height : 100vh ;
562
+ display : none;
563
+
564
+ .sidebar__container {
565
+ width : 100% ;
566
+ }
567
+ }
568
+ }
531
569
}
532
570
533
571
main {
Original file line number Diff line number Diff line change 1
1
document . addEventListener ( 'click' , ( e ) => {
2
2
const toggle = e . target . closest ( '.sidebar__toggle' ) ;
3
+ const sidebarMobileToggle = e . target . closest ( '.sidebar-mobile-toggle' ) ;
3
4
if ( toggle ) {
4
5
const chevron = toggle . querySelector ( '.sidebar__chevron' ) ;
5
6
const expanded = toggle . getAttribute ( 'aria-expanded' ) === 'true' ;
@@ -14,5 +15,15 @@ document.addEventListener('click', (e) => {
14
15
if ( chevron ) {
15
16
chevron . classList . toggle ( 'sidebar__chevron--open' , ! expanded ) ;
16
17
}
18
+ } else if ( sidebarMobileToggle ) {
19
+ // Show the sidebar
20
+ const sidebar = document . getElementById ( 'sidebar-v2' ) ;
21
+ const expanded =
22
+ sidebarMobileToggle . getAttribute ( 'aria-expanded' ) === 'true' ;
23
+ sidebarMobileToggle . setAttribute ( 'aria-expanded' , String ( ! expanded ) ) ;
24
+ sidebar . setAttribute (
25
+ 'style' ,
26
+ ! expanded ? 'display: block;' : 'display: none;'
27
+ ) ;
17
28
}
18
29
} ) ;
Original file line number Diff line number Diff line change 69
69
70
70
< section class ="main-layout ">
71
71
< div class ="sidebar-layout " id ="sidebar-layout ">
72
+ < button class ="sidebar-mobile-toggle " aria-expanded ="false " style ="display: none; "> < p > Click</ p > </ button >
72
73
< nav data-mf ="true " id ="sidebar-v2 " class ="sidebar " style ="display:none; ">
73
74
{{ partial "sidebar-v2.html" . }}
74
75
</ nav >
You can’t perform that action at this time.
0 commit comments