File tree Expand file tree Collapse file tree 3 files changed +63
-34
lines changed Expand file tree Collapse file tree 3 files changed +63
-34
lines changed Original file line number Diff line number Diff line change @@ -768,7 +768,7 @@ button:has(~ .product-selector[style*="none"]) > .product-selector-button-icon {
768768 padding : 0 ;
769769 list-style : none;
770770 font-weight : 400 ;
771- font-size : 1 rem ;
771+ font-size : 0.875 rem ;
772772}
773773
774774.sidebar__container button {
@@ -788,15 +788,36 @@ button:has(~ .product-selector[style*="none"]) > .product-selector-button-icon {
788788}
789789
790790.sidebar__toggle {
791+ display : flex;
792+ align-items : center;
793+ gap : 0.25rem ;
791794 cursor : pointer;
792795 background : none;
793796 border : none;
794797 width : 100% ;
795798 text-align : left;
796- padding : 0.25rem 0.75 rem ;
799+ padding : 0.25rem 0.5 rem ;
797800 border-radius : 5px ;
798801}
799802
803+ .sidebar__chevron {
804+ display : flex;
805+ align-items : center;
806+ }
807+
808+ .sidebar__chevron svg {
809+ margin-right : -0.325rem ;
810+ stroke-width : 1.5 ;
811+ }
812+
813+ .sidebar__chevron--open {
814+ transform : rotate (90deg );
815+ }
816+
817+ .sidebar__toggle : has (.sidebar__chevron ) {
818+ padding-left : .4rem ;
819+ }
820+
800821.sidebar__link {
801822 display : block;
802823 padding : 0.25rem 0.75rem ;
@@ -810,6 +831,7 @@ button:has(~ .product-selector[style*="none"]) > .product-selector-button-icon {
810831 color : oklch (var (--color-brand ) / 1 );
811832 background-color : oklch (var (--color-brand ) / 0.1 );
812833 font-weight : 600 ;
834+ width : fit-content;
813835}
814836
815837.sidebar__toc {
Original file line number Diff line number Diff line change 1- document . addEventListener ( 'DOMContentLoaded' , ( ) => {
2- const toggles = document . querySelectorAll ( '.sidebar__toggle' ) ;
1+ document . addEventListener ( 'click' , ( e ) => {
2+ const toggle = e . target . closest ( '.sidebar__toggle' ) ;
3+ if ( toggle ) {
4+ const chevron = toggle . querySelector ( '.sidebar__chevron' ) ;
5+ const expanded = toggle . getAttribute ( 'aria-expanded' ) === 'true' ;
6+ const panel = document . getElementById ( toggle . getAttribute ( 'aria-controls' ) ) ;
37
4- toggles . forEach ( ( toggle ) => {
5- const parent = toggle . closest ( 'li.sidebar__section' ) ;
6- const children = parent . querySelector ( '.sidebar__children' ) ;
8+ // Toggle the expanded state
9+ toggle . setAttribute ( 'aria-expanded' , String ( ! expanded ) ) ;
710
8- toggle . addEventListener ( 'click' , ( ) => {
9- const isExpanded = toggle . getAttribute ( 'aria-expanded' ) === 'true' ;
10- toggle . setAttribute ( 'aria-expanded' , ! isExpanded ) ;
11- children . hidden = isExpanded ;
12- } ) ;
13- } ) ;
11+ // Toggle visibility of the content
12+ if ( panel ) {
13+ panel . hidden = expanded ;
14+ }
15+
16+ // Toggle chevron direction class
17+ if ( chevron ) {
18+ chevron . classList . toggle ( 'sidebar__chevron--open' , ! expanded ) ;
19+ }
20+ }
1421} ) ;
Original file line number Diff line number Diff line change 99 {{- $isAncestor := .IsAncestor $currentPage -}}
1010 {{- $shouldExpand := or $onPage $isAncestor -}}
1111 {{- $sectionID := printf "section-%s" (urlize .Permalink) -}}
12-
1312 {{ if eq .Kind "section" }}
14- < li class ="sidebar__section ">
15- < button
16- class ="sidebar__toggle "
17- aria-expanded ="{{ $shouldExpand }} "
18- aria-controls ="{{ $sectionID }} "
19- >
20- {{ .Title }}
21- </ button >
22-
23- < div
24- id =" {{ $sectionID }} "
25- class =" sidebar__children "
26- {{ if not $shouldExpand }}hidden{{ end }}
27- >
28- {{ partial "sidebar-list.html" (dict
29- "firstSection" . "currentUrl" $currentUrl "currentPage" $currentPage)
30- }}
31- </ div >
32- </ li >
33-
13+ < li class ="sidebar__section ">
14+ < button
15+ class ="sidebar__toggle "
16+ aria-expanded ="{{ $shouldExpand }} "
17+ aria-controls ="{{ $sectionID }} "
18+ >
19+ < span class =" sidebar__chevron {{ if $shouldExpand }}sidebar__chevron--open{{ end }} " >
20+ {{ partial "lucide" (dict "context" . "icon" "chevron-right") }}
21+ </ span >
22+ < span class =" sidebar__toggle-text " > {{ .Title }} </ span >
23+ </ button >
24+ < div
25+ id =" {{ $sectionID }} "
26+ class =" sidebar__children "
27+ {{ if not $shouldExpand }}hidden {{ end }}
28+ >
29+ {{ partial "sidebar-list.html" (dict
30+ "firstSection" . "currentUrl" $currentUrl "currentPage" $currentPage) }}
31+ </ div >
32+ </ li >
3433 {{ else if eq .Kind "page" }}
3534 < li class ="sidebar__page ">
3635 < a
4645 {{ end }}
4746 {{ end }}
4847 </ li >
48+
4949 {{ end }}
5050 {{ end }}
5151</ ul >
You can’t perform that action at this time.
0 commit comments