Skip to content

Commit 3f242a1

Browse files
authored
Merge pull request #62 from shiftlab/doc-left-nav-collapse
Notes is now collaspible
2 parents 77e5f4c + ad414ad commit 3f242a1

File tree

6 files changed

+143
-5
lines changed

6 files changed

+143
-5
lines changed

images/chevron-down-orange.svg

Lines changed: 16 additions & 0 deletions
Loading

js/theme.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,17 @@ if (downloadNote.length >= 1) {
261261
} else {
262262
$(".pytorch-call-to-action-links").hide();
263263
}
264+
265+
//This code makes the Notes section of the Docs Left Nav collapsible
266+
267+
if ($("p.caption:first").text() == "Notes") {
268+
269+
$("p.caption:first").addClass("left-nav-top-caption");
270+
$("span.caption-text:first").addClass("pytorch-left-nav-collapsed");
271+
$("p.caption:first").next("ul").hide();
272+
273+
$("span.caption-text:first").on("click", function() {
274+
$(this).toggleClass("pytorch-left-nav-collapsible pytorch-left-nav-collapsed");
275+
$("p.caption:first").next("ul").toggle();
276+
});
277+
}

pytorch_sphinx_theme/static/css/theme.css

Lines changed: 42 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 0 deletions
Loading

pytorch_sphinx_theme/static/js/theme.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,4 +894,17 @@ if (downloadNote.length >= 1) {
894894
$(".pytorch-call-to-action-links").hide();
895895
}
896896

897+
//This code makes the Notes section of the Docs Left Nav collapsible
898+
899+
if ($("p.caption:first").text() == "Notes") {
900+
901+
$("p.caption:first").addClass("left-nav-top-caption");
902+
$("span.caption-text:first").addClass("pytorch-left-nav-collapsed");
903+
$("p.caption:first").next("ul").hide();
904+
905+
$("span.caption-text:first").on("click", function() {
906+
$(this).toggleClass("pytorch-left-nav-collapsible pytorch-left-nav-collapsed");
907+
$("p.caption:first").next("ul").toggle();
908+
});
909+
}
897910
},{"jquery":"jquery"}]},{},[1,2,3,4,5,6,7,8,9,"pytorch-sphinx-theme"]);

scss/_sphinx_layout.scss

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
display: none;
122122
background-color: $light_grey;
123123
color: $slate;
124+
overflow: scroll;
124125

125126
@include sphinx-medium-size {
126127
display: block;
@@ -147,14 +148,53 @@
147148
}
148149
}
149150

151+
.pytorch-left-nav-collapsible {
152+
display: block;
153+
background-image: url(../images/chevron-down-orange.svg);
154+
background-repeat: no-repeat;
155+
background-size: 15px 8px;
156+
background-position: 46px 9px;
157+
width: 25%;
158+
}
159+
160+
.pytorch-left-nav-collapsible:hover {
161+
cursor: pointer;
162+
}
163+
164+
.pytorch-left-nav-collapsed {
165+
display: block;
166+
background-image: url(../images/chevron-right-orange.svg);
167+
background-repeat: no-repeat;
168+
background-size: 15px 11px;
169+
background-position: 46px 7px;
170+
width: 25%;
171+
}
172+
173+
.pytorch-left-nav-collapsed:hover {
174+
cursor: pointer;
175+
}
176+
177+
.left-nav-top-caption {
178+
padding-top: 1rem;
179+
}
180+
181+
@media screen and (max-width: 767px) {
182+
.pytorch-left-nav-collapsible {
183+
background-size: 11px 8px;
184+
background-position: 43px 5px;
185+
}
186+
.pytorch-left-nav-collapsed {
187+
background-size: 10px 9px;
188+
background-position: 45px 4px;
189+
}
190+
}
191+
150192
.pytorch-left-menu p.caption {
151193
color: $not_quite_black;
152194
display: block;
153-
display: inline-block;
154195
font-size: rem(16px);
155196
line-height: rem(22px);
156197
margin-bottom: rem(16px);
157-
padding: 0;
158198
text-transform: none;
159199
white-space: nowrap;
160200
}

0 commit comments

Comments
 (0)