Skip to content

Commit b8c2ac0

Browse files
author
Jacek Gębal
committed
Fixes to shared navigation
1 parent 12c6666 commit b8c2ac0

3 files changed

Lines changed: 14 additions & 17 deletions

File tree

docs/assets/topbar.css

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,9 @@
8686
top: 2rem !important;
8787
}
8888

89-
/* Hide drawer hamburger and logo — our topbar has both.
90-
Leave the search icon button intact so mobile search still works. */
91-
.md-header__button:not([for="__search"]) {
92-
display: none !important;
93-
}
94-
95-
/* Move palette toggle off-screen — our topbar handles theme switching */
96-
.md-header__option {
97-
position: absolute !important;
98-
left: -9999px !important;
99-
}
89+
/* NOTE: .md-header__button and .md-header__option hiding is intentionally
90+
NOT here — it is injected by topbar.js only after the topbar is built,
91+
so that a JS failure leaves Material's original navigation intact. */
10092

10193
/* ── Org-site only ────────────────────────────────────────────────────────
10294
The org site sets data-utplsql-site="org" on <html> in its template.

docs/assets/topbar.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115
updateThemeIcon();
116116
}
117117

118-
/* Updates the active class on nav links based on the current URL. */
119118
function injectDrawerNav() {
120119
/* Only needed on mobile — desktop shows links in the topbar itself. */
121120
if (!window.matchMedia('(max-width: 76.1875em)').matches) return;
@@ -231,12 +230,18 @@
231230
controls.appendChild(themeBtn);
232231
bar.appendChild(controls);
233232

234-
/* Inject back-to-top button offset so it clears the topbar + header.
235-
topbar.css covers the org site; this covers sub-sites that only load the JS. */
233+
/* Injected only after the topbar is successfully built so that a JS failure
234+
leaves Material's original header navigation intact as a fallback. */
236235
if (!document.getElementById('utplsql-topbar-style')) {
237236
var style = document.createElement('style');
238237
style.id = 'utplsql-topbar-style';
239-
style.textContent = '.md-top { top: 4.4rem !important; z-index: 11; }';
238+
style.textContent =
239+
/* Hide Material's hamburger/logo — our topbar has both */
240+
'.md-header__button:not([for="__search"]) { display: none !important; }' +
241+
/* Move palette toggle off-screen — our topbar handles theme switching */
242+
'.md-header__option { position: absolute !important; left: -9999px !important; }' +
243+
/* Back-to-top button: clear topbar + header */
244+
'.md-top { top: 4.4rem !important; z-index: 11; }';
240245
document.head.appendChild(style);
241246
}
242247

site-template/overrides/main.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77

88
{% block extrahead %}
99
{{ super() }}
10-
<link rel="stylesheet" href="https://utplsql.org/assets/topbar.css">
11-
<script src="https://utplsql.org/assets/topbar.js" defer></script>
10+
<link rel="stylesheet" href="https://www.utplsql.org/assets/topbar.css">
11+
<script src="https://www.utplsql.org/assets/topbar.js" defer></script>
1212
{% endblock %}

0 commit comments

Comments
 (0)