Skip to content

Commit 681bfb4

Browse files
committed
garden v2.3.0
1 parent b67b433 commit 681bfb4

23 files changed

+358
-116
lines changed

404.html

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
const path_to_root = "";
4040
const default_light_theme = "ayu";
4141
const default_dark_theme = "ayu";
42+
window.path_to_searchindex_js = "searchindex.js";
4243
</script>
4344
<!-- Start loading toc.js asap -->
4445
<script src="toc.js"></script>
@@ -95,10 +96,13 @@ <h2 class="mdbook-help-title">Keyboard shortcuts</h2>
9596
sidebar = sidebar || 'visible';
9697
} else {
9798
sidebar = 'hidden';
99+
sidebar_toggle.checked = false;
100+
}
101+
if (sidebar === 'visible') {
102+
sidebar_toggle.checked = true;
103+
} else {
104+
html.classList.remove('sidebar-visible');
98105
}
99-
sidebar_toggle.checked = sidebar === 'visible';
100-
html.classList.remove('sidebar-visible');
101-
html.classList.add("sidebar-" + sidebar);
102106
</script>
103107

104108
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
@@ -152,7 +156,12 @@ <h1 class="menu-title">Garden User Guide</h1>
152156

153157
<div id="search-wrapper" class="hidden">
154158
<form id="searchbar-outer" class="searchbar-outer">
155-
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
159+
<div class="search-wrapper">
160+
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
161+
<div class="spinner-wrapper">
162+
<i class="fa fa-spinner fa-spin"></i>
163+
</div>
164+
</div>
156165
</form>
157166
<div id="searchresults-outer" class="searchresults-outer hidden">
158167
<div id="searchresults-header" class="searchresults-header"></div>
@@ -219,6 +228,7 @@ <h1 id="document-not-found-404"><a class="header" href="#document-not-found-404"
219228
<!-- Custom JS scripts -->
220229

221230

231+
222232
</div>
223233
</body>
224234
</html>

book.js

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -515,17 +515,39 @@ aria-label="Show hidden lines"></button>';
515515
})();
516516

517517
(function sidebar() {
518-
const body = document.querySelector('body');
519518
const sidebar = document.getElementById('sidebar');
520519
const sidebarLinks = document.querySelectorAll('#sidebar a');
521520
const sidebarToggleButton = document.getElementById('sidebar-toggle');
522-
const sidebarToggleAnchor = document.getElementById('sidebar-toggle-anchor');
523521
const sidebarResizeHandle = document.getElementById('sidebar-resize-handle');
522+
const sidebarCheckbox = document.getElementById('sidebar-toggle-anchor');
524523
let firstContact = null;
525524

525+
526+
/* Because we cannot change the `display` using only CSS after/before the transition, we
527+
need JS to do it. We change the display to prevent the browsers search to find text inside
528+
the collapsed sidebar. */
529+
if (!document.documentElement.classList.contains('sidebar-visible')) {
530+
sidebar.style.display = 'none';
531+
}
532+
sidebar.addEventListener('transitionend', () => {
533+
/* We only change the display to "none" if we're collapsing the sidebar. */
534+
if (!sidebarCheckbox.checked) {
535+
sidebar.style.display = 'none';
536+
}
537+
});
538+
sidebarToggleButton.addEventListener('click', () => {
539+
/* To allow the sidebar expansion animation, we first need to put back the display. */
540+
if (!sidebarCheckbox.checked) {
541+
sidebar.style.display = '';
542+
// Workaround for Safari skipping the animation when changing
543+
// `display` and a transform in the same event loop. This forces a
544+
// reflow after updating the display.
545+
sidebar.offsetHeight;
546+
}
547+
});
548+
526549
function showSidebar() {
527-
body.classList.remove('sidebar-hidden');
528-
body.classList.add('sidebar-visible');
550+
document.documentElement.classList.add('sidebar-visible');
529551
Array.from(sidebarLinks).forEach(function(link) {
530552
link.setAttribute('tabIndex', 0);
531553
});
@@ -539,8 +561,7 @@ aria-label="Show hidden lines"></button>';
539561
}
540562

541563
function hideSidebar() {
542-
body.classList.remove('sidebar-visible');
543-
body.classList.add('sidebar-hidden');
564+
document.documentElement.classList.remove('sidebar-visible');
544565
Array.from(sidebarLinks).forEach(function(link) {
545566
link.setAttribute('tabIndex', -1);
546567
});
@@ -554,8 +575,8 @@ aria-label="Show hidden lines"></button>';
554575
}
555576

556577
// Toggle sidebar
557-
sidebarToggleAnchor.addEventListener('change', function sidebarToggle() {
558-
if (sidebarToggleAnchor.checked) {
578+
sidebarCheckbox.addEventListener('change', function sidebarToggle() {
579+
if (sidebarCheckbox.checked) {
559580
const current_width = parseInt(
560581
document.documentElement.style.getPropertyValue('--sidebar-target-width'), 10);
561582
if (current_width < 150) {
@@ -572,14 +593,14 @@ aria-label="Show hidden lines"></button>';
572593
function initResize() {
573594
window.addEventListener('mousemove', resize, false);
574595
window.addEventListener('mouseup', stopResize, false);
575-
body.classList.add('sidebar-resizing');
596+
document.documentElement.classList.add('sidebar-resizing');
576597
}
577598
function resize(e) {
578599
let pos = e.clientX - sidebar.offsetLeft;
579600
if (pos < 20) {
580601
hideSidebar();
581602
} else {
582-
if (body.classList.contains('sidebar-hidden')) {
603+
if (!document.documentElement.classList.contains('sidebar-visible')) {
583604
showSidebar();
584605
}
585606
pos = Math.min(pos, window.innerWidth - 100);
@@ -588,7 +609,7 @@ aria-label="Show hidden lines"></button>';
588609
}
589610
//on mouseup remove windows functions mousemove & mouseup
590611
function stopResize() {
591-
body.classList.remove('sidebar-resizing');
612+
document.documentElement.classList.remove('sidebar-resizing');
592613
window.removeEventListener('mousemove', resize, false);
593614
window.removeEventListener('mouseup', stopResize, false);
594615
}
@@ -765,7 +786,7 @@ aria-label="Show hidden lines"></button>';
765786
let scrollTop = document.scrollingElement.scrollTop;
766787
let prevScrollTop = scrollTop;
767788
const minMenuY = -menu.clientHeight - 50;
768-
// When the script loads, the page can be at any scroll (e.g. if you reforesh it).
789+
// When the script loads, the page can be at any scroll (e.g. if you refresh it).
769790
menu.style.top = scrollTop + 'px';
770791
// Same as parseInt(menu.style.top.slice(0, -2), but faster
771792
let topCache = menu.style.top.slice(0, -2);

changelog.html

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
const path_to_root = "";
3939
const default_light_theme = "ayu";
4040
const default_dark_theme = "ayu";
41+
window.path_to_searchindex_js = "searchindex.js";
4142
</script>
4243
<!-- Start loading toc.js asap -->
4344
<script src="toc.js"></script>
@@ -94,10 +95,13 @@ <h2 class="mdbook-help-title">Keyboard shortcuts</h2>
9495
sidebar = sidebar || 'visible';
9596
} else {
9697
sidebar = 'hidden';
98+
sidebar_toggle.checked = false;
99+
}
100+
if (sidebar === 'visible') {
101+
sidebar_toggle.checked = true;
102+
} else {
103+
html.classList.remove('sidebar-visible');
97104
}
98-
sidebar_toggle.checked = sidebar === 'visible';
99-
html.classList.remove('sidebar-visible');
100-
html.classList.add("sidebar-" + sidebar);
101105
</script>
102106

103107
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
@@ -145,7 +149,7 @@ <h1 class="menu-title">Garden User Guide</h1>
145149
<a href="https://gitlab.com/garden-rs/garden/tree/main/doc" title="Git repository" aria-label="Git repository">
146150
<i id="git-repository-button" class="fa fa-gitlab"></i>
147151
</a>
148-
<a href="https://gitlab.com/garden-rs/garden/edit/main/doc/src/changelog.md" title="Suggest an edit" aria-label="Suggest an edit">
152+
<a href="https://gitlab.com/garden-rs/garden/edit/main/doc/src/changelog.md" title="Suggest an edit" aria-label="Suggest an edit" rel="edit">
149153
<i id="git-edit-button" class="fa fa-edit"></i>
150154
</a>
151155

@@ -154,7 +158,12 @@ <h1 class="menu-title">Garden User Guide</h1>
154158

155159
<div id="search-wrapper" class="hidden">
156160
<form id="searchbar-outer" class="searchbar-outer">
157-
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
161+
<div class="search-wrapper">
162+
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
163+
<div class="spinner-wrapper">
164+
<i class="fa fa-spinner fa-spin"></i>
165+
</div>
166+
</div>
158167
</form>
159168
<div id="searchresults-outer" class="searchresults-outer hidden">
160169
<div id="searchresults-header" class="searchresults-header"></div>
@@ -1035,6 +1044,7 @@ <h2 id="v010"><a class="header" href="#v010">v0.1.0</a></h2>
10351044
<!-- Custom JS scripts -->
10361045

10371046

1047+
10381048
</div>
10391049
</body>
10401050
</html>

commands.html

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
const path_to_root = "";
3939
const default_light_theme = "ayu";
4040
const default_dark_theme = "ayu";
41+
window.path_to_searchindex_js = "searchindex.js";
4142
</script>
4243
<!-- Start loading toc.js asap -->
4344
<script src="toc.js"></script>
@@ -94,10 +95,13 @@ <h2 class="mdbook-help-title">Keyboard shortcuts</h2>
9495
sidebar = sidebar || 'visible';
9596
} else {
9697
sidebar = 'hidden';
98+
sidebar_toggle.checked = false;
99+
}
100+
if (sidebar === 'visible') {
101+
sidebar_toggle.checked = true;
102+
} else {
103+
html.classList.remove('sidebar-visible');
97104
}
98-
sidebar_toggle.checked = sidebar === 'visible';
99-
html.classList.remove('sidebar-visible');
100-
html.classList.add("sidebar-" + sidebar);
101105
</script>
102106

103107
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
@@ -145,7 +149,7 @@ <h1 class="menu-title">Garden User Guide</h1>
145149
<a href="https://gitlab.com/garden-rs/garden/tree/main/doc" title="Git repository" aria-label="Git repository">
146150
<i id="git-repository-button" class="fa fa-gitlab"></i>
147151
</a>
148-
<a href="https://gitlab.com/garden-rs/garden/edit/main/doc/src/commands.md" title="Suggest an edit" aria-label="Suggest an edit">
152+
<a href="https://gitlab.com/garden-rs/garden/edit/main/doc/src/commands.md" title="Suggest an edit" aria-label="Suggest an edit" rel="edit">
149153
<i id="git-edit-button" class="fa fa-edit"></i>
150154
</a>
151155

@@ -154,7 +158,12 @@ <h1 class="menu-title">Garden User Guide</h1>
154158

155159
<div id="search-wrapper" class="hidden">
156160
<form id="searchbar-outer" class="searchbar-outer">
157-
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
161+
<div class="search-wrapper">
162+
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
163+
<div class="spinner-wrapper">
164+
<i class="fa fa-spinner fa-spin"></i>
165+
</div>
166+
</div>
158167
</form>
159168
<div id="searchresults-outer" class="searchresults-outer hidden">
160169
<div id="searchresults-header" class="searchresults-header"></div>
@@ -1004,6 +1013,7 @@ <h3 id="future-shell-completion-enhancements"><a class="header" href="#future-sh
10041013
<!-- Custom JS scripts -->
10051014

10061015

1016+
10071017
</div>
10081018
</body>
10091019
</html>

configuration.html

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
const path_to_root = "";
3939
const default_light_theme = "ayu";
4040
const default_dark_theme = "ayu";
41+
window.path_to_searchindex_js = "searchindex.js";
4142
</script>
4243
<!-- Start loading toc.js asap -->
4344
<script src="toc.js"></script>
@@ -94,10 +95,13 @@ <h2 class="mdbook-help-title">Keyboard shortcuts</h2>
9495
sidebar = sidebar || 'visible';
9596
} else {
9697
sidebar = 'hidden';
98+
sidebar_toggle.checked = false;
99+
}
100+
if (sidebar === 'visible') {
101+
sidebar_toggle.checked = true;
102+
} else {
103+
html.classList.remove('sidebar-visible');
97104
}
98-
sidebar_toggle.checked = sidebar === 'visible';
99-
html.classList.remove('sidebar-visible');
100-
html.classList.add("sidebar-" + sidebar);
101105
</script>
102106

103107
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
@@ -145,7 +149,7 @@ <h1 class="menu-title">Garden User Guide</h1>
145149
<a href="https://gitlab.com/garden-rs/garden/tree/main/doc" title="Git repository" aria-label="Git repository">
146150
<i id="git-repository-button" class="fa fa-gitlab"></i>
147151
</a>
148-
<a href="https://gitlab.com/garden-rs/garden/edit/main/doc/src/configuration.md" title="Suggest an edit" aria-label="Suggest an edit">
152+
<a href="https://gitlab.com/garden-rs/garden/edit/main/doc/src/configuration.md" title="Suggest an edit" aria-label="Suggest an edit" rel="edit">
149153
<i id="git-edit-button" class="fa fa-edit"></i>
150154
</a>
151155

@@ -154,7 +158,12 @@ <h1 class="menu-title">Garden User Guide</h1>
154158

155159
<div id="search-wrapper" class="hidden">
156160
<form id="searchbar-outer" class="searchbar-outer">
157-
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
161+
<div class="search-wrapper">
162+
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
163+
<div class="spinner-wrapper">
164+
<i class="fa fa-spinner fa-spin"></i>
165+
</div>
166+
</div>
158167
</form>
159168
<div id="searchresults-outer" class="searchresults-outer hidden">
160169
<div id="searchresults-header" class="searchresults-header"></div>
@@ -885,6 +894,7 @@ <h2 id="grafts"><a class="header" href="#grafts">Grafts</a></h2>
885894
<!-- Custom JS scripts -->
886895

887896

897+
888898
</div>
889899
</body>
890900
</html>

css/chrome.css

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,34 @@ mark.fade-out {
344344
max-width: var(--content-max-width);
345345
}
346346

347+
#searchbar-outer.searching #searchbar {
348+
padding-right: 30px;
349+
}
350+
#searchbar-outer .spinner-wrapper {
351+
display: none;
352+
}
353+
#searchbar-outer.searching .spinner-wrapper {
354+
display: block;
355+
}
356+
357+
.search-wrapper {
358+
position: relative;
359+
}
360+
361+
.spinner-wrapper {
362+
--spinner-margin: 2px;
363+
position: absolute;
364+
margin-block-start: calc(var(--searchbar-margin-block-start) + var(--spinner-margin));
365+
right: var(--spinner-margin);
366+
top: 0;
367+
bottom: var(--spinner-margin);
368+
padding: 6px;
369+
background-color: var(--bg);
370+
}
371+
347372
#searchbar {
348373
width: 100%;
349-
margin-block-start: 5px;
374+
margin-block-start: var(--searchbar-margin-block-start);
350375
margin-block-end: 0;
351376
margin-inline-start: auto;
352377
margin-inline-end: auto;
@@ -505,7 +530,6 @@ html:not(.sidebar-resizing) .sidebar {
505530
/* sidebar-hidden */
506531
#sidebar-toggle-anchor:not(:checked) ~ .sidebar {
507532
transform: translateX(calc(0px - var(--sidebar-width) - var(--sidebar-resize-indicator-width)));
508-
z-index: -1;
509533
}
510534
[dir=rtl] #sidebar-toggle-anchor:not(:checked) ~ .sidebar {
511535
transform: translateX(calc(var(--sidebar-width) + var(--sidebar-resize-indicator-width)));

css/general.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,12 @@ h6:target::before {
8686
box-sizing: border-box;
8787
background-color: var(--bg);
8888
}
89-
.no-js .page-wrapper,
89+
html:not(.js) .page-wrapper,
9090
.js:not(.sidebar-resizing) .page-wrapper {
9191
transition: margin-left 0.3s ease, transform 0.3s ease; /* Animation: slide away */
9292
}
93-
[dir=rtl] .js:not(.sidebar-resizing) .page-wrapper {
93+
[dir=rtl]:not(.js) .page-wrapper,
94+
[dir=rtl].js:not(.sidebar-resizing) .page-wrapper {
9495
transition: margin-right 0.3s ease, transform 0.3s ease; /* Animation: slide away */
9596
}
9697

css/variables.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
--menu-bar-height: 50px;
1212
--mono-font: "Source Code Pro", Consolas, "Ubuntu Mono", Menlo, "DejaVu Sans Mono", monospace, monospace;
1313
--code-font-size: 0.875em; /* please adjust the ace font size accordingly in editor.js */
14+
--searchbar-margin-block-start: 5px;
1415
}
1516

1617
/* Themes */

0 commit comments

Comments
 (0)