mirror of
https://github.com/alex-shpak/hugo-book.git
synced 2025-07-16 11:41:27 +00:00
Merge 01b52eaa95
into f2c703e155
This commit is contained in:
commit
7920cb650c
@ -305,9 +305,16 @@ body[dir="rtl"] .book-menu {
|
||||
}
|
||||
|
||||
@media screen and (max-width: $mobile-breakpoint) {
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
scroll-margin-top: 3rem;
|
||||
}
|
||||
|
||||
#menu-control,
|
||||
#toc-control {
|
||||
display: inline;
|
||||
// prevents scrolling to top when inputs focused
|
||||
position: fixed;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.book-menu {
|
||||
@ -321,7 +328,16 @@ body[dir="rtl"] .book-menu {
|
||||
}
|
||||
|
||||
.book-header {
|
||||
background: var(--body-background);
|
||||
border-bottom: 2px solid var(--color-visited-link);
|
||||
display: block;
|
||||
max-height: 100vh;
|
||||
overflow: auto;
|
||||
padding: .35rem 0;
|
||||
position: sticky;
|
||||
top: -1px;
|
||||
// prevent background from being transparent
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
#menu-control:focus ~ main label[for="menu-control"] {
|
||||
|
18
assets/book-header.js
Normal file
18
assets/book-header.js
Normal file
@ -0,0 +1,18 @@
|
||||
(function () {
|
||||
let tocLinks = document.querySelectorAll("#TableOfContents li");
|
||||
let tocInput = document.getElementById("toc-control");
|
||||
tocLinks.forEach(l =>
|
||||
l.addEventListener("click",
|
||||
() => tocInput.checked = false));
|
||||
})();
|
||||
(function () {
|
||||
let menuLabel = document.querySelector("label[for='menu-control']");
|
||||
let menuInput = document.getElementById("menu-control");
|
||||
let tocInput = document.getElementById("toc-control");
|
||||
menuLabel.addEventListener("click",
|
||||
function () {
|
||||
if (!menuInput.checked) {
|
||||
tocInput.checked = false;
|
||||
}
|
||||
});
|
||||
})();
|
@ -21,6 +21,13 @@
|
||||
|
||||
{{ partial "docs/inject/content-before" . }}
|
||||
{{ template "main" . }} <!-- Page Content -->
|
||||
|
||||
<!-- Improve .book-header usability on mobile devices -->
|
||||
{{ $script := resources.Get "book-header.js" | resources.Minify }}
|
||||
{{ with $script.Content }}
|
||||
<script>{{ . | safeJS }}</script>
|
||||
{{ end }}
|
||||
|
||||
{{ partial "docs/inject/content-after" . }}
|
||||
|
||||
<footer class="book-footer">
|
||||
|
Loading…
Reference in New Issue
Block a user