Skip to content

Commit 9e76b28

Browse files
authored
Merge pull request #54 from shiftlab/update-nav-menu-undo-revert
Update nav menu
2 parents 4a0a2f7 + efa4341 commit 9e76b28

File tree

6 files changed

+13073
-10
lines changed

6 files changed

+13073
-10
lines changed

js/main-menu-dropdown.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
window.mainMenuDropdown = {
2+
bind: function() {
3+
$("[data-toggle='ecosystem-dropdown']").on("click", function() {
4+
toggleDropdown($(this).attr("data-toggle"));
5+
});
6+
7+
$("[data-toggle='resources-dropdown']").on("click", function() {
8+
toggleDropdown($(this).attr("data-toggle"));
9+
});
10+
11+
function toggleDropdown(menuToggle) {
12+
var showMenuClass = "show-menu";
13+
var menuClass = "." + menuToggle + "-menu";
14+
15+
if ($(menuClass).hasClass(showMenuClass)) {
16+
$(menuClass).removeClass(showMenuClass);
17+
} else {
18+
$("[data-toggle=" + menuToggle + "].show-menu").removeClass(
19+
showMenuClass
20+
);
21+
$(menuClass).addClass(showMenuClass);
22+
}
23+
}
24+
}
25+
};

pytorch_sphinx_theme/layout.html

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,25 @@
9494
</li>
9595

9696
<li>
97-
<a href="{{ theme_variables.external_urls['features'] }}">Features</a>
97+
<div class="ecosystem-dropdown">
98+
<a id="dropdownMenuButton" data-toggle="ecosystem-dropdown">
99+
Ecosystem
100+
</a>
101+
<div class="ecosystem-dropdown-menu">
102+
<a class="nav-dropdown-item" href="{{ theme_variables.external_urls['hub'] }}"">
103+
<span class=dropdown-title>Models (Beta)</span>
104+
<p>Discover, publish, and reuse pre-trained models</p>
105+
</a>
106+
<a class="nav-dropdown-item" href="{{ theme_variables.external_urls['ecosystem'] }}">
107+
<span class=dropdown-title>Tools & Libraries</span>
108+
<p>Explore the ecosystem of tools and libraries</p>
109+
</a>
110+
</div>
111+
</div>
98112
</li>
99113

100114
<li>
101-
<a href="{{ theme_variables.external_urls['ecosystem'] }}">Ecosystem</a>
115+
<a href="{{ theme_variables.external_urls['mobile'] }}">Mobile</a>
102116
</li>
103117

104118
<li>
@@ -114,7 +128,21 @@
114128
</li>
115129

116130
<li>
117-
<a href="{{ theme_variables.external_urls['resources'] }}">Resources</a>
131+
<div class="resources-dropdown">
132+
<a id="resourcesDropdownButton" data-toggle="resources-dropdown">
133+
Resources
134+
</a>
135+
<div class="resources-dropdown-menu">
136+
<a class="nav-dropdown-item" href="{{ theme_variables.external_urls['resources'] }}"">
137+
<span class=dropdown-title>Developer Resources</span>
138+
<p>Find resources and get questions answered</p>
139+
</a>
140+
<a class="nav-dropdown-item" href="{{ theme_variables.external_urls['features'] }}">
141+
<span class=dropdown-title>About</span>
142+
<p>Learn about PyTorch’s features and capabilities</p>
143+
</a>
144+
</div>
145+
</div>
118146
</li>
119147

120148
<li>
@@ -418,15 +446,23 @@ <h2>Resources</h2>
418446
<div class="main-menu">
419447
<ul>
420448
<li>
421-
<a href="#">Get Started</a>
449+
<a href="{{ theme_variables.external_urls['get_started'] }}">Get Started</a>
450+
</li>
451+
452+
<li>
453+
<a href="{{ theme_variables.external_urls['features'] }}">Features</a>
454+
</li>
455+
456+
<li>
457+
<a href="{{ theme_variables.external_urls['ecosystem'] }}">Ecosystem</a>
422458
</li>
423459

424460
<li>
425-
<a href="#">Features</a>
461+
<a href="{{ theme_variables.external_urls['mobile'] }}">Mobile</a>
426462
</li>
427463

428464
<li>
429-
<a href="#">Ecosystem</a>
465+
<a href="{{ theme_variables.external_urls['hub'] }}">PyTorch Hub</a>
430466
</li>
431467

432468
<li>
@@ -465,6 +501,7 @@ <h2>Resources</h2>
465501
sideMenus.bind();
466502
scrollToAnchor.bind();
467503
highlightNavigation.bind();
504+
mainMenuDropdown.bind();
468505

469506
// Add class to links that have code blocks, since we cannot create links in code blocks
470507
$("article.pytorch-article a span.pre").each(function(e) {

pytorch_sphinx_theme/static/css/theme.css

Lines changed: 11991 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)