Skip to content

Commit a2997e8

Browse files
Allow keyboard to toggle menu expansion (#1167)
Co-authored-by: Aaron Carlisle <[email protected]>
1 parent da86e4d commit a2997e8

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/sass/_theme_layout.sass

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,17 @@ html
6464
padding-left: 0
6565
padding-right: 0
6666
// Expand links
67-
span.toctree-expand
67+
button.toctree-expand
6868
display: block
6969
float: left
7070
margin-left: -1.2em
7171
@extend .fa
7272
@extend .fa-plus-square-o
7373
line-height: 18px
7474
color: darken($menu-link-medium, 20%)
75+
border: none
76+
background: none
77+
padding: 0
7578

7679
// On state for the first level
7780
li.on a, li.current > a
@@ -85,9 +88,9 @@ html
8588
+font-smooth
8689
&:hover
8790
background: $menu-vertical-background-color
88-
span.toctree-expand
91+
button.toctree-expand
8992
color: $menu-link-medium
90-
span.toctree-expand
93+
button.toctree-expand
9194
@extend .fa
9295
@extend .fa-minus-square-o
9396
display: block
@@ -134,7 +137,7 @@ html
134137
@extend %display_current_toctree_element
135138
padding: ($gutter / 4) ($gutter * ($toc_level + 0.5))
136139
padding-right: $gutter
137-
a:hover span.toctree-expand
140+
a:hover button.toctree-expand
138141
@extend %toctree_hover_link_color
139142
@if $toc_level > 2 and $toc_level < 5
140143
li.toctree-l#{$toc_level}
@@ -146,15 +149,15 @@ html
146149
background: darken($menu-vertical-background-color, 20%)
147150
li.toctree-l3 > a
148151
background: darken($menu-vertical-background-color, 20%)
149-
span.toctree-expand
152+
button.toctree-expand
150153
color: darken($menu-vertical-background-color, 35%)
151154
li.toctree-l3
152155
&.current
153156
> a
154157
background: darken($menu-vertical-background-color, 25%)
155158
li.toctree-l4 > a
156159
background: darken($menu-vertical-background-color, 25%)
157-
span.toctree-expand
160+
button.toctree-expand
158161
color: darken($menu-vertical-background-color, 40%)
159162

160163
li.current ul
@@ -176,13 +179,13 @@ html
176179
&:hover
177180
background-color: lighten($menu-background-color, 10%)
178181
cursor: pointer
179-
span.toctree-expand
182+
button.toctree-expand
180183
color: $menu-link-light
181184
&:active
182185
background-color: $menu-logo-color
183186
cursor: pointer
184187
color: $menu-link-active
185-
span.toctree-expand
188+
button.toctree-expand
186189
color: $menu-link-active
187190

188191
.wy-side-nav-search

src/theme.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ function ThemeNav () {
112112
// Add expand links to all parents of nested ul
113113
$('.wy-menu-vertical ul').not('.simple').siblings('a').each(function () {
114114
var link = $(this);
115-
expand = $('<span class="toctree-expand"></span>');
115+
expand =
116+
$('<button class="toctree-expand" title="Open/close menu"></button>');
116117
expand.on('click', function (ev) {
117118
self.toggleCurrent(link);
118119
ev.stopPropagation();

0 commit comments

Comments
 (0)