Skip to content

Commit ad414ad

Browse files
authored
Merge branch 'master' into doc-left-nav-collapse
2 parents b9a6e4c + 77e5f4c commit ad414ad

File tree

8 files changed

+337
-16
lines changed

8 files changed

+337
-16
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/fonts.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!-- Preload the theme fonts -->
2+
3+
<link rel="preload" href="{{ pathto('_static/fonts/FreightSans/freight-sans-book.woff2', 1) }}" as="font" type="font/woff2" crossorigin="anonymous">
4+
<link rel="preload" href="{{ pathto('_static/fonts/FreightSans/freight-sans-medium.woff2', 1) }}" as="font" type="font/woff2" crossorigin="anonymous">
5+
<link rel="preload" href="{{ pathto('_static/fonts/IBMPlexMono/IBMPlexMono-Medium.woff2', 1) }}" as="font" type="font/woff2" crossorigin="anonymous">
6+
<link rel="preload" href="{{ pathto('_static/fonts/FreightSans/freight-sans-bold.woff2', 1) }}" as="font" type="font/woff2" crossorigin="anonymous">
7+
<link rel="preload" href="{{ pathto('_static/fonts/FreightSans/freight-sans-medium-italic.woff2', 1) }}" as="font" type="font/woff2" crossorigin="anonymous">
8+
<link rel="preload" href="{{ pathto('_static/fonts/IBMPlexMono/IBMPlexMono-SemiBold.woff2', 1) }}" as="font" type="font/woff2" crossorigin="anonymous">
9+
10+
<!-- Preload the katex fonts -->
11+
12+
<link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Math-Italic.woff2" as="font" type="font/woff2" crossorigin="anonymous">
13+
<link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Main-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
14+
<link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Main-Bold.woff2" as="font" type="font/woff2" crossorigin="anonymous">
15+
<link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Size1-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
16+
<link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Size4-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
17+
<link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Size2-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
18+
<link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Size3-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">
19+
<link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/fonts/KaTeX_Caligraphic-Regular.woff2" as="font" type="font/woff2" crossorigin="anonymous">

pytorch_sphinx_theme/layout.html

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878

7979
{# Keep modernizr in head - http://modernizr.com/docs/#installing #}
8080
<script src="{{ pathto('_static/js/modernizr.min.js', 1) }}"></script>
81+
82+
{% include "fonts.html" %}
8183
</head>
8284

8385
<div class="container-fluid header-holder tutorials-header" id="header-holder">
@@ -92,11 +94,25 @@
9294
</li>
9395

9496
<li>
95-
<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>
96112
</li>
97113

98114
<li>
99-
<a href="{{ theme_variables.external_urls['ecosystem'] }}">Ecosystem</a>
115+
<a href="{{ theme_variables.external_urls['mobile'] }}">Mobile</a>
100116
</li>
101117

102118
<li>
@@ -112,7 +128,21 @@
112128
</li>
113129

114130
<li>
115-
<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>
116146
</li>
117147

118148
<li>
@@ -416,15 +446,23 @@ <h2>Resources</h2>
416446
<div class="main-menu">
417447
<ul>
418448
<li>
419-
<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>
420458
</li>
421459

422460
<li>
423-
<a href="#">Features</a>
461+
<a href="{{ theme_variables.external_urls['mobile'] }}">Mobile</a>
424462
</li>
425463

426464
<li>
427-
<a href="#">Ecosystem</a>
465+
<a href="{{ theme_variables.external_urls['hub'] }}">PyTorch Hub</a>
428466
</li>
429467

430468
<li>
@@ -463,6 +501,7 @@ <h2>Resources</h2>
463501
sideMenus.bind();
464502
scrollToAnchor.bind();
465503
highlightNavigation.bind();
504+
mainMenuDropdown.bind();
466505

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

pytorch_sphinx_theme/static/css/theme.css

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

pytorch_sphinx_theme/static/js/theme.js

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,33 @@ window.highlightNavigation = {
220220
};
221221

222222
},{}],4:[function(require,module,exports){
223+
window.mainMenuDropdown = {
224+
bind: function() {
225+
$("[data-toggle='ecosystem-dropdown']").on("click", function() {
226+
toggleDropdown($(this).attr("data-toggle"));
227+
});
228+
229+
$("[data-toggle='resources-dropdown']").on("click", function() {
230+
toggleDropdown($(this).attr("data-toggle"));
231+
});
232+
233+
function toggleDropdown(menuToggle) {
234+
var showMenuClass = "show-menu";
235+
var menuClass = "." + menuToggle + "-menu";
236+
237+
if ($(menuClass).hasClass(showMenuClass)) {
238+
$(menuClass).removeClass(showMenuClass);
239+
} else {
240+
$("[data-toggle=" + menuToggle + "].show-menu").removeClass(
241+
showMenuClass
242+
);
243+
$(menuClass).addClass(showMenuClass);
244+
}
245+
}
246+
}
247+
};
248+
249+
},{}],5:[function(require,module,exports){
223250
window.mobileMenu = {
224251
bind: function() {
225252
$("[data-behavior='open-mobile-menu']").on('click', function(e) {
@@ -251,7 +278,7 @@ window.mobileMenu = {
251278
}
252279
};
253280

254-
},{}],5:[function(require,module,exports){
281+
},{}],6:[function(require,module,exports){
255282
window.mobileTOC = {
256283
bind: function() {
257284
$("[data-behavior='toggle-table-of-contents']").on("click", function(e) {
@@ -272,7 +299,7 @@ window.mobileTOC = {
272299
}
273300
}
274301

275-
},{}],6:[function(require,module,exports){
302+
},{}],7:[function(require,module,exports){
276303
window.pytorchAnchors = {
277304
bind: function() {
278305
// Replace Sphinx-generated anchors with anchorjs ones
@@ -292,7 +319,7 @@ window.pytorchAnchors = {
292319
}
293320
};
294321

295-
},{}],7:[function(require,module,exports){
322+
},{}],8:[function(require,module,exports){
296323
// Modified from https://stackoverflow.com/a/13067009
297324
// Going for a JS solution to scrolling to an anchor so we can benefit from
298325
// less hacky css and smooth scrolling.
@@ -393,7 +420,7 @@ window.scrollToAnchor = {
393420
}
394421
};
395422

396-
},{}],8:[function(require,module,exports){
423+
},{}],9:[function(require,module,exports){
397424
window.sideMenus = {
398425
rightMenuIsOnScreen: function() {
399426
return document.getElementById("pytorch-content-right").offsetParent !== null;
@@ -880,5 +907,4 @@ if ($("p.caption:first").text() == "Notes") {
880907
$("p.caption:first").next("ul").toggle();
881908
});
882909
}
883-
884-
},{"jquery":"jquery"}]},{},[1,2,3,4,5,6,7,8,"pytorch-sphinx-theme"]);
910+
},{"jquery":"jquery"}]},{},[1,2,3,4,5,6,7,8,9,"pytorch-sphinx-theme"]);

pytorch_sphinx_theme/theme_variables.jinja

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
'ecosystem': 'https://pytorch.org/ecosystem',
1616
'blog': 'https://pytorch.org/blog/',
1717
'resources': 'https://pytorch.org/resources',
18-
'support': 'https://pytorch.org/support'
18+
'support': 'https://pytorch.org/support',
19+
'mobile': 'https://pytorch.org/mobile',
20+
'hub': 'https://pytorch.org/hub'
1921
}
20-
-%}
22+
-%}

0 commit comments

Comments
 (0)